diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 9595a75622..cc53d52d50 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,5 +1,7 @@ import { defineConfig } from 'vitepress' +const DEPLOYED_HOSTNAME = 'https://kongponents.konghq.com' // Ensure this does NOT end with a trailing-slash + const KONG_SVG = 'Kong API Gateway and Service Connectivity Platform' export default defineConfig({ @@ -20,6 +22,21 @@ export default defineConfig({ // Algolia Search // ['link', { rel: 'preconnect', href: 'https://6MM6JXMAAD-dsn.algolia.net', crossorigin: 'true' }], ], + transformPageData(pageData) { + // Add canonical URLs + const canonicalUrl = `${DEPLOYED_HOSTNAME}/${pageData.relativePath}` + .replace(/index\.md$/, '') + .replace(/\.md$/, '.html') + + pageData.frontmatter.head ??= [] + pageData.frontmatter.head.push([ + 'link', + { rel: 'canonical', href: canonicalUrl } + ]) + }, + sitemap: { + hostname: DEPLOYED_HOSTNAME, + }, lastUpdated: true, markdown: { lineNumbers: true, @@ -136,10 +153,12 @@ export default defineConfig({ { text: 'v9-alpha', link: 'https://alpha--kongponents.netlify.app', + rel: 'nofollow' }, { text: 'v7.x', - link: 'https://legacy.kongponents.konghq.com', + link: 'https://v7--kongponents.netlify.app', + rel: 'nofollow' }, ], }, diff --git a/netlify.toml b/netlify.toml index 2800f257fe..dd0b6add7a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -9,11 +9,11 @@ environment = { NODE_VERSION = "18.17.1", YARN_FLAGS="--frozen-lockfile --ignore-optional" } # ############################## -# 'legacy' branch +# 'v7' branch # ############################## -# 'legacy' branch context -[context.legacy] +# 'v7' branch context +[context.v7] base = "/" command = "yarn docs:build" publish = "docs/.vitepress/dist"