Files
docudjeex/plugins/canonical.ts
T
DjeexandClaude Sonnet 5 921780d0d2 feat: add canonical URL and og:url
Docus doesn't generate canonical links or og:url natively. This
branch has no @nuxtjs/sitemap/nuxt-site-config, so the plugin reads
the base URL from docus.url in app.config.ts (already includes the
/fr prefix) instead of hardcoding it, and combines it with the
current route path.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-11 23:14:20 +02:00

15 lines
326 B
TypeScript

export default defineNuxtPlugin(() => {
const route = useRoute()
const { docus } = useAppConfig()
const canonicalUrl = computed(() => `${docus.url}${route.path}`)
useHead({
link: [
{ rel: 'canonical', href: canonicalUrl }
],
meta: [
{ property: 'og:url', content: canonicalUrl }
]
})
})