From d989132b79e1799341bf498151eeeb1e5d4945c3 Mon Sep 17 00:00:00 2001 From: skirtle <65301168+skirtles-code@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:32:52 +0000 Subject: [PATCH] Add canonical URLs for SEO --- docs/.vitepress/config.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/.vitepress/config.mjs b/docs/.vitepress/config.mjs index b510acb..505769f 100644 --- a/docs/.vitepress/config.mjs +++ b/docs/.vitepress/config.mjs @@ -9,6 +9,16 @@ export default defineConfigWithTheme({ description: 'Examples of Vue patterns and basic components', appearance: false, + transformHead({ page, siteData: { base } }) { + if (page !== '404.md') { + const canonicalUrl = `https://skirtles-code.github.io${base}${page}` + .replace(/index\.md$/, '') + .replace(/\.md$/, '') + + return [['link', { rel: 'canonical', href: canonicalUrl }]] + } + }, + themeConfig: { search: { provider: 'local'