From e6c18a3a7abe46b75b03c9790a6027c37b0950b1 Mon Sep 17 00:00:00 2001 From: Djeex Date: Tue, 11 Aug 2026 23:14:20 +0200 Subject: [PATCH] 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. --- plugins/canonical.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 plugins/canonical.ts diff --git a/plugins/canonical.ts b/plugins/canonical.ts new file mode 100644 index 0000000..8199726 --- /dev/null +++ b/plugins/canonical.ts @@ -0,0 +1,14 @@ +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 } + ] + }) +})