diff --git a/README.md b/README.md index 88bba20..fb4a0b6 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ pnpm check # lint + 类型检查 + token 契约检查 ## 文档站 -https://ui-a09.pages.dev +https://ui.froq.me `docs/` 用 Nuxt Content。静态产物在仓库根目录的 `dist/`。部署到 Cloudflare Workers(Worker 名 `ui`):Workers Builds 连本仓库,生产分支 `main`,环境变量 `NODE_VERSION=22`,构建命令 `pnpm generate`,生产部署 `pnpm exec cf deploy`,非生产预览 `pnpm exec cf previews deploy`。 diff --git a/docs/app/composables/useShareMeta.ts b/docs/app/composables/useShareMeta.ts new file mode 100644 index 0000000..2bbd5e8 --- /dev/null +++ b/docs/app/composables/useShareMeta.ts @@ -0,0 +1,30 @@ +import type { MaybeRefOrGetter } from 'vue' +import { canonicalUrl, shareTitle } from '../../shared/site' + +/** Document title plus Open Graph / Twitter tags for the current route. */ +export function useShareMeta(input: { + title?: MaybeRefOrGetter + description?: MaybeRefOrGetter + type?: MaybeRefOrGetter<'website' | 'article' | undefined> +} = {}): void { + const route = useRoute() + const title = computed(() => shareTitle(toValue(input.title))) + const description = computed(() => { + const value = input.description == null ? undefined : toValue(input.description) + return value || undefined + }) + + useHead({ + title: () => input.title == null ? undefined : toValue(input.title) || undefined, + }) + + useSeoMeta({ + description, + ogTitle: title, + twitterTitle: title, + ogDescription: description, + twitterDescription: description, + ogUrl: () => canonicalUrl(route.path), + ogType: () => toValue(input.type) ?? 'website', + }) +} diff --git a/docs/app/error.vue b/docs/app/error.vue index 127a015..ac8476d 100644 --- a/docs/app/error.vue +++ b/docs/app/error.vue @@ -1,12 +1,15 @@