Skip to content

Commit

Permalink
feat: page authors
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Jan 19, 2025
1 parent 3ee6c8e commit 0ec49fd
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
23 changes: 23 additions & 0 deletions components/layout/Title.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@
</UiBadge>
</NuxtLink>
</div>

<div v-if="authors" class="-mx-4 flex divide-x pt-4">
<NuxtLink v-for="author in authors" :key="author.name" :to="author.to" :target="author.target" class="flex items-center gap-2 px-4">
<UiAvatar v-if="author.avatar" class="size-8">
<UiAvatarImage :src="author.avatar" :alt="author.name" />
</UiAvatar>
<div>
<div class="text-sm font-semibold">
{{ author.name }}
</div>
<div v-if="author.username" class="text-xs font-medium leading-4 text-muted-foreground">
@{{ author.username }}
</div>
</div>
</NuxtLink>
</div>
</div>
</template>

Expand All @@ -35,5 +51,12 @@ defineProps<{
type?: 'default' | 'info' | 'warning' | 'success' | 'danger' | 'lime';
variant?: 'default' | 'secondary' | 'destructive' | 'outline';
}[];
authors?: {
name: string;
username?: string;
avatar?: string;
to?: string;
target?: Target;
}[];
}>();
</script>
49 changes: 49 additions & 0 deletions content/1.getting-started/3.writing/2.pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ icon: lucide:file
title: Front Matter
description: Front matter attributes used in shadcn-docs-nuxt.
icon: lucide:book-type

navTruncate: false
navBadges:
- value: New
type: lime

badges:
- value: Docus
to: https://docus.dev/api/components#alert
Expand All @@ -21,11 +23,55 @@ badges:
icon: lucide:code
to: https://github.com/ZTL-UwU/shadcn-docs-nuxt/blob/main/components/content/Alert.vue
target: _blank

authors:
- name: Tony Zhang
username: ZTL-UwU
avatar: https://www.github.com/ZTL-UwU.png
to: https://github.com/ZTL-UwU
target: _blank
---

<!-- Content of the page -->
```

## Showcases

::tabs{variant="line"}
::stack{label="badges"}
![badges-showcase](/front-matter-showcase/badges.png){class="w-full"}
```yml
badges:
- value: 0.8.10
- value: Source
icon: lucide:code
to: https://github.com/ZTL-UwU/shadcn-docs-nuxt/blob/main/components/content/FileTree.vue
target: _blank
```
::
::stack{label="authors"}
![authors-showcase](/front-matter-showcase/authors.png){class="w-full"}
```yml
authors:
- name: Tony Zhang
username: ZTL-UwU
avatar: https://www.github.com/ZTL-UwU.png
to: https://github.com/ZTL-UwU
target: _blank
```
::
::stack{label="navBadges"}
![nav-badges-showcase](/front-matter-showcase/nav-badges.png){class="w-full"}
```yml
navBadges:
- value: New
type: lime
```
::
::
## Parameters
::field-group
Expand All @@ -50,6 +96,9 @@ badges:
::field{name="badges" type="[]"}
A list of badges shown at the bottom of page title.
::
::field{name="authors" type="[]"}
A list of authors shown at the bottom of page title.
::
::field{name="toc" type="boolean" default-value="true"}
Whether to show the toc section for this page.
::
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@iconify-json/lucide": "^1.2.23",
"@iconify-json/lucide": "^1.2.24",
"@iconify-json/vscode-icons": "^1.2.10",
"@nuxt/content": "^2.13.4",
"@nuxt/icon": "^1.10.3",
Expand All @@ -72,7 +72,7 @@
"@vueuse/core": "^12.4.0",
"@vueuse/nuxt": "^12.4.0",
"eslint": "^9.18.0",
"eslint-plugin-tailwindcss": "^3.17.5",
"eslint-plugin-tailwindcss": "^3.18.0",
"shiki": "^1.27.2",
"vue-tsc": "^2.2.0"
}
Expand Down
1 change: 1 addition & 0 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
:title="page?.title"
:description="page?.description"
:badges="page?.badges"
:authors="page?.authors"
/>

<Alert
Expand Down
Binary file added public/front-matter-showcase/authors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/front-matter-showcase/badges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/front-matter-showcase/nav-badges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ec49fd

Please sign in to comment.