@@ -12,6 +12,10 @@ export default defineConfig({
1212 description : "MAVLink Developer Guide" ,
1313 //base: process.env.BRANCH_NAME ? "/" + process.env.BRANCH_NAME + "/" : "", //Build doesn't use branches!
1414 base : "" ,
15+ lastUpdated : true ,
16+ sitemap : {
17+ hostname : "https://mavlink.io" ,
18+ } ,
1519 srcExclude : [
1620 "de/**/*.md" ,
1721 "ja/**/*.md" ,
@@ -115,8 +119,36 @@ export default defineConfig({
115119 } ,
116120 } ,
117121 //Logs every page loaded on build. Good way to catch errors not caught by other things.
122+ //Also injects per-page SEO metadata (description, OpenGraph, canonical) into the
123+ //server-rendered <head> so message pages are better crawled/snippeted by search engines.
118124 async transformPageData ( pageData , { siteConfig } ) {
119125 console . log ( pageData . filePath ) ;
126+
127+ const desc =
128+ pageData . frontmatter . description ||
129+ pageData . description ||
130+ ( pageData . title
131+ ? `${ pageData . title } — MAVLink message, enum and command reference.`
132+ : "MAVLink Developer Guide" ) ;
133+
134+ // Set pageData.description so VitePress's own <meta name="description"> uses it
135+ // (pushing a second description tag in head would be deduped in favour of the default).
136+ pageData . description = desc ;
137+
138+ const url =
139+ "https://mavlink.io/" +
140+ pageData . relativePath
141+ . replace ( / ( ^ | \/ ) i n d e x \. m d $ / , "$1" )
142+ . replace ( / \. m d $ / , ".html" ) ;
143+
144+ pageData . frontmatter . head ??= [ ] ;
145+ pageData . frontmatter . head . push (
146+ [ "meta" , { property : "og:title" , content : pageData . title } ] ,
147+ [ "meta" , { property : "og:description" , content : desc } ] ,
148+ [ "meta" , { property : "og:type" , content : "article" } ] ,
149+ [ "meta" , { property : "og:url" , content : url } ] ,
150+ [ "link" , { rel : "canonical" , href : url } ]
151+ ) ;
120152 } ,
121153
122154 //
0 commit comments