Skip to content

Commit

Permalink
feat: icons in the navbar (#75)
Browse files Browse the repository at this point in the history
* feat: icons in the navbar

* fix: types
  • Loading branch information
TitusKirch authored Dec 24, 2024
1 parent 9d0e5e6 commit 5bd4ae5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
2 changes: 2 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ export default defineAppConfig({
title: 'Getting Started',
to: '/getting-started',
description: 'Start building your document with shadcn-docs-nuxt',
icon: 'lucide:book',
}, {
title: 'API',
to: '/api',
description: 'Discover the configurations and exposed APIs.',
target: '_self',
icon: 'lucide:code',
}],
}, {
title: 'Credits',
Expand Down
16 changes: 10 additions & 6 deletions components/layout/Header/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
<NuxtLink
:to="link.to"
:target="link.target"
class="mb-1 block w-full gap-2 rounded-md px-3 py-2 transition-all hover:bg-muted"
class="mb-1 flex w-full gap-2 rounded-md px-3 py-2 transition-all hover:bg-muted"
>
<div class="font-semibold">
{{ link.title }}
</div>
<div class="text-sm text-muted-foreground">
{{ link.description }}
<SmartIcon v-if="link?.icon" :name="link.icon" :size="16" class="mt-1 min-w-5" />

<div>
<div class="font-semibold">
{{ link.title }}
</div>
<div class="text-sm text-muted-foreground">
{{ link.description }}
</div>
</div>
</NuxtLink>
</li>
Expand Down
16 changes: 10 additions & 6 deletions components/layout/Header/NavMobileItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
<NuxtLink
:to="link.to"
:target="link.to"
class="mb-1 block w-full gap-2 rounded-md px-3 py-2 transition-all hover:bg-muted"
class="mb-1 flex w-full gap-2 rounded-md px-3 py-2 transition-all hover:bg-muted"
>
<div class="font-semibold">
{{ link.title }}
</div>
<div class="text-sm text-muted-foreground">
{{ link.description }}
<SmartIcon v-if="link.icon" :name="link.icon" :size="16" class="mt-1 min-w-5" />

<div>
<div class="font-semibold">
{{ link.title }}
</div>
<div class="text-sm text-muted-foreground">
{{ link.description }}
</div>
</div>
</NuxtLink>
</li>
Expand Down
12 changes: 6 additions & 6 deletions composables/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,32 +163,32 @@ export function useConfig() {
...header,
...navKeyFromPath(route.path, 'header', navigation.value || []),
...page.value?.header,
} as typeof header,
} as (typeof header & DefaultConfig['header']),
banner: {
...banner,
...navKeyFromPath(route.path, 'banner', navigation.value || []),
...page.value?.banner,
} as typeof banner,
} as (typeof banner & DefaultConfig['banner']),
main: {
...main,
...navKeyFromPath(route.path, 'main', navigation.value || []),
...page.value?.main,
} as typeof main,
} as (typeof main & DefaultConfig['main']),
aside: {
...aside,
...navKeyFromPath(route.path, 'aside', navigation.value || []),
...page.value?.aside,
} as typeof aside,
} as (typeof aside & DefaultConfig['aside']),
toc: {
...toc,
...navKeyFromPath(route.path, 'toc', navigation.value || []),
...page.value?.toc,
} as typeof toc,
} as (typeof toc & DefaultConfig['toc']),
footer: {
...footer,
...navKeyFromPath(route.path, 'footer', navigation.value || []),
...page.value?.footer,
} as typeof footer,
} as (typeof footer & DefaultConfig['footer']),
};
},
);
Expand Down
2 changes: 1 addition & 1 deletion content/3.api/1.configuration/1.shadcn-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ILink {

interface INav {
title: string;
links?: (ILink & { description: string })[];
links?: (ILink & { description: string; icon: string })[];
to?: string;
target?: Target;
}
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface DefaultConfig {
to: string;
target: string;
description: string;
icon?: string;
})[];
})[];
links: ({
Expand Down

0 comments on commit 5bd4ae5

Please sign in to comment.