Skip to content

Commit 09c48c6

Browse files
sserrataclaude
andcommitted
fix(palette-picker): swizzle NavbarItem/index instead of ComponentTypes
ComponentTypes swizzle was silently not loading. Replacing it with a NavbarItem/index wrapper that intercepts custom-PalettePicker before the ComponentTypes lookup, which is more reliable across Docusaurus theme chain configurations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 47e8e91 commit 09c48c6

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

demo/src/theme/NavbarItem/ComponentTypes.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* ============================================================================
2+
* NavbarItem swizzle — intercepts custom-PalettePicker before
3+
* ComponentTypes lookup so no registry change is needed.
4+
* ========================================================================== */
5+
6+
import React from "react";
7+
8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9+
import OriginalNavbarItem from "@theme-original/NavbarItem";
10+
11+
import PalettePicker from "@site/src/components/PalettePicker";
12+
13+
type OriginalProps = React.ComponentProps<typeof OriginalNavbarItem>;
14+
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16+
export default function NavbarItem(props: OriginalProps): JSX.Element {
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18+
if ((props as any).type === "custom-PalettePicker") {
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20+
return <PalettePicker mobile={(props as any).mobile} />;
21+
}
22+
return <OriginalNavbarItem {...props} />;
23+
}

0 commit comments

Comments
 (0)