Skip to content

Commit 0514b26

Browse files
jaysin586claude
andcommitted
feat(header): add hideNpm config to hide the npm icon
Sites that aren't published as an npm package (e.g. standalone product sites) can set `hideNpm: true` on DocsKitConfig to render only the GitHub icon in the header. Gated in both HeaderV2 and the v1 Header. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5de65c4 commit 0514b26

3 files changed

Lines changed: 38 additions & 28 deletions

File tree

src/lib/components/Header.svelte

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,23 @@
9191
<GitHubIcon class="size-3.5" />
9292
</MotionDiv>
9393
</a>
94-
<a
95-
href={npmUrl}
96-
target="_blank"
97-
rel="noopener noreferrer"
98-
class="inline-flex items-center justify-center text-text-muted hover:text-text-secondary"
99-
aria-label="NPM"
100-
>
101-
<MotionDiv
102-
class="inline-flex size-6 items-center justify-center rounded-full border border-border-muted transition-colors hover:border-border-mid"
103-
whileTap={tapScale}
104-
whileHover={hoverScaleIcon}
94+
{#if !config.hideNpm}
95+
<a
96+
href={npmUrl}
97+
target="_blank"
98+
rel="noopener noreferrer"
99+
class="inline-flex items-center justify-center text-text-muted hover:text-text-secondary"
100+
aria-label="NPM"
105101
>
106-
<NpmIcon class="size-3.5" />
107-
</MotionDiv>
108-
</a>
102+
<MotionDiv
103+
class="inline-flex size-6 items-center justify-center rounded-full border border-border-muted transition-colors hover:border-border-mid"
104+
whileTap={tapScale}
105+
whileHover={hoverScaleIcon}
106+
>
107+
<NpmIcon class="size-3.5" />
108+
</MotionDiv>
109+
</a>
110+
{/if}
109111
</div>
110112
</header>
111113
</div>

src/lib/components/HeaderV2.svelte

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,23 @@
190190
<GitHubIcon class="size-3.5" />
191191
</MotionDiv>
192192
</a>
193-
<a
194-
href={npmUrl}
195-
target="_blank"
196-
rel="noopener noreferrer"
197-
class="dk-icon-link dk-npm-link"
198-
aria-label="NPM"
199-
>
200-
<MotionDiv
201-
class="dk-icon-square"
202-
whileTap={tapScale}
203-
whileHover={hoverScaleIcon}
193+
{#if !config.hideNpm}
194+
<a
195+
href={npmUrl}
196+
target="_blank"
197+
rel="noopener noreferrer"
198+
class="dk-icon-link dk-npm-link"
199+
aria-label="NPM"
204200
>
205-
<NpmIcon class="size-3.5" />
206-
</MotionDiv>
207-
</a>
201+
<MotionDiv
202+
class="dk-icon-square"
203+
whileTap={tapScale}
204+
whileHover={hoverScaleIcon}
205+
>
206+
<NpmIcon class="size-3.5" />
207+
</MotionDiv>
208+
</a>
209+
{/if}
208210
</div>
209211
</div>
210212

src/lib/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export interface DocsKitConfig {
77
npmPackage: string
88
/** Optional override for the header npm icon URL */
99
npmUrl?: string
10+
/**
11+
* Hide the npm icon in the header. Set this on sites that aren't
12+
* published as an npm package (e.g. a standalone product site) so the
13+
* header shows only the GitHub icon.
14+
*/
15+
hideNpm?: boolean
1016
/** GitHub repo in owner/name format, e.g. 'humanspeak/svelte-markdown' */
1117
repo: string
1218
/** Optional override for the header GitHub icon URL */

0 commit comments

Comments
 (0)