Skip to content

Commit

Permalink
docs: add canonical url in head (#15984)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrygrFlzr authored Feb 20, 2024
1 parent a839c14 commit cc388d9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,16 @@ export default defineConfig({
level: [2, 3],
},
},
transformPageData(pageData) {
const canonicalUrl = `${ogUrl}/${pageData.relativePath}`
.replace(/\/index\.md$/, '/')
.replace(/\.md$/, '/')
pageData.frontmatter.head ??= []
pageData.frontmatter.head.unshift([
'link',
{ rel: 'canonical', href: canonicalUrl },
])
return pageData
},
buildEnd,
})

0 comments on commit cc388d9

Please sign in to comment.