feat: add canonical URL and og:url
Docus doesn't generate canonical links or og:url natively. A plugin now injects rel=canonical and og:url per route using nuxt-site-config's withSiteUrl, which reads site.url from nuxt.config.ts.
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
export default defineNuxtPlugin(() => {
|
||||||
|
const route = useRoute()
|
||||||
|
const canonicalUrl = withSiteUrl(computed(() => route.path), { canonical: true })
|
||||||
|
|
||||||
|
useHead({
|
||||||
|
link: [
|
||||||
|
{ rel: 'canonical', href: canonicalUrl }
|
||||||
|
],
|
||||||
|
meta: [
|
||||||
|
{ property: 'og:url', content: canonicalUrl }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user