Improve search-engine crawlability of docs (#719)

This commit is contained in:
Claudio Chies
2026-06-17 03:10:13 +02:00
committed by GitHub
parent ef25584ed0
commit 487d2528cb
3 changed files with 35 additions and 1 deletions
+32
View File
@@ -12,6 +12,10 @@ export default defineConfig({
description: "MAVLink Developer Guide",
//base: process.env.BRANCH_NAME ? "/" + process.env.BRANCH_NAME + "/" : "", //Build doesn't use branches!
base: "",
lastUpdated: true,
sitemap: {
hostname: "https://mavlink.io",
},
srcExclude: [
"de/**/*.md",
"ja/**/*.md",
@@ -115,8 +119,36 @@ export default defineConfig({
},
},
//Logs every page loaded on build. Good way to catch errors not caught by other things.
//Also injects per-page SEO metadata (description, OpenGraph, canonical) into the
//server-rendered <head> so message pages are better crawled/snippeted by search engines.
async transformPageData(pageData, { siteConfig }) {
console.log(pageData.filePath);
const desc =
pageData.frontmatter.description ||
pageData.description ||
(pageData.title
? `${pageData.title} — MAVLink message, enum and command reference.`
: "MAVLink Developer Guide");
// Set pageData.description so VitePress's own <meta name="description"> uses it
// (pushing a second description tag in head would be deduped in favour of the default).
pageData.description = desc;
const url =
"https://mavlink.io/" +
pageData.relativePath
.replace(/(^|\/)index\.md$/, "$1")
.replace(/\.md$/, ".html");
pageData.frontmatter.head ??= [];
pageData.frontmatter.head.push(
["meta", { property: "og:title", content: pageData.title }],
["meta", { property: "og:description", content: desc }],
["meta", { property: "og:type", content: "article" }],
["meta", { property: "og:url", content: url }],
["link", { rel: "canonical", href: url }]
);
},
//
-1
View File
@@ -9,7 +9,6 @@
"docs:buildwin": "set NODE_OPTIONS=--max_old_space_size=8192 && vitepress build .",
"docs:build_ubuntu": "NODE_OPTIONS='--max-old-space-size=8192' vitepress build .",
"docs:preview": "vitepress preview .",
"docs:sitemap": "python3 ./scripts/gen_sitemap.py",
"docs:gen_alt_sidebar_ubuntu": "python3 ./scripts/gen_alt_sidebar.py",
"docs:get_alt_sidebar_windows": "python ./scripts/gen_alt_sidebar.py",
"start": "yarn docs:dev",
+3
View File
@@ -0,0 +1,3 @@
User-agent: *
Sitemap: https://mavlink.io/sitemap.xml