Skip to content

Commit

Permalink
fix: canonical
Browse files Browse the repository at this point in the history
  • Loading branch information
bojanrajh committed Dec 11, 2024
1 parent 4b36031 commit f1d7314
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,18 @@ const addCanonicalTags = (head, context) => {
if (context.page.startsWith('docs/v6.')) {
// remove version parameter from url
const [docs, skip, ...rest] = context.page.split('/')
let href = `/${docs}/${rest.join('/')}`
if (href.endsWith('/index.md')) {
href = href.substring(0, href.length - 'index.md'.length)
} else if (href.endsWith('.md')) {
href = `${href.substring(0, href.length - '.md'.length)}.html`
}

head.push([
'link',
{
rel: 'canonical',
href: `/${docs}/${rest.join('/')}`,
href,
}
]);
}
Expand Down

0 comments on commit f1d7314

Please sign in to comment.