- <SeoBreadcrumbs> (UI-SPEC L1): the resolve answer's trail as nav > ol with server-rendered links and the last item as aria-current text; nothing with fewer than two items, with page meta seo.breadcrumbs false or with the option seo.breadcrumbs false; props items, label, hideCurrent, locale - one trail per page: the first rendered instance claims it (seoClaimBreadcrumbs, kept per path) - seoSitePath: same-origin CMS URLs become paths, non-http(s) URLs are never links; useSeoLabels takes an optional locale - L1 default styles with CSS-generated separators
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
// The layer's labels (UI-SPEC L8) in the page's content locale: the resolve
|
|
// answer's locale, then html_lang's primary subtag, then en. An app
|
|
// overrides or adds locales in its app.config.ts:
|
|
//
|
|
// export default defineAppConfig({ seo: { labels: { pl: { sitemap: { title: 'Spis stron' } } } } })
|
|
//
|
|
// Component props override both.
|
|
|
|
import type { ComputedRef, MaybeRefOrGetter } from 'vue'
|
|
import { pickLabels, type SeoLabelOverrides, type SeoLabels } from '../utils/labels.ts'
|
|
|
|
/**
|
|
* The labels of the page's content locale, or of `locale` when given and
|
|
* not empty (the HTML sitemap pages know theirs from the route).
|
|
*/
|
|
export function useSeoLabels(locale?: MaybeRefOrGetter<string | undefined | null>): ComputedRef<SeoLabels> {
|
|
const answer = useSeoAnswer()
|
|
const appConfig = useAppConfig() as { seo?: { labels?: SeoLabelOverrides } }
|
|
return computed(() => {
|
|
const own = toValue(locale)
|
|
if (own) return pickLabels(own, '', appConfig.seo?.labels ?? {})
|
|
return pickLabels(answer.value?.locale, answer.value?.html_lang, appConfig.seo?.labels ?? {})
|
|
})
|
|
}
|