Skip to content

Commit

Permalink
docs(main): fix seo issues [KHCP-10667] (#2007)
Browse files Browse the repository at this point in the history
* fix(docs): seo [KHCP-10667]

* fix: update link
  • Loading branch information
adamdehaven committed Feb 9, 2024
1 parent 00c25c8 commit d5aca1e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 20 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -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 = '<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><title>Kong API Gateway and Service Connectivity Platform</title><path fill-rule="evenodd" clip-rule="evenodd" d="m16.28 36.66 1-1.3h7.45l3.88 4.96-.7 1.68h-9.6l.24-1.68-2.27-3.66Z" fill="#169FCC"/><path fill-rule="evenodd" clip-rule="evenodd" d="m18.55 19.75 3.6-6.21h4.19L45.1 35.35 43.65 42H35.6l.5-1.87-17.55-20.38Z" fill="#14B59A"/><path fill-rule="evenodd" clip-rule="evenodd" d="m22.92 12.36 1.72-3.19L29.8 5l8.85 6.94-1.15 1.17 1.54 2.13v2.28l-4.4 3.6-7.4-8.76h-4.32Z" fill="#1BC263"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9.25 26.23h2.33l6.1-5.1 8.08 9.4-2.28 3.41h-7.46l-5.15 6.55L9.7 42H3v-8.03l6.25-7.74Z" fill="#16BDCC"/></svg>'

export default defineConfig({
Expand All @@ -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,
Expand Down Expand Up @@ -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'
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d5aca1e

Please sign in to comment.