diff --git a/docs/site/.gitignore b/docs/site/.gitignore index 12fe96bab3c..8336c7f1d7d 100644 --- a/docs/site/.gitignore +++ b/docs/site/.gitignore @@ -2,3 +2,4 @@ /assets/json /assets/vendor /sitemap.xml +/sitemap.md diff --git a/docs/site/_layouts/page.html b/docs/site/_layouts/page.html index 01c2cc7fbe2..04417382ece 100644 --- a/docs/site/_layouts/page.html +++ b/docs/site/_layouts/page.html @@ -16,10 +16,8 @@ -
This navigation UI is temporary, just to give access to the pages.
+
This navigation UI is temporary, just to give access to the pages.
Site Map
- diff --git a/docs/site/assets/js/build.mjs b/docs/site/assets/js/build.mjs index 8156cd7b9c1..4603cb10c8b 100644 --- a/docs/site/assets/js/build.mjs +++ b/docs/site/assets/js/build.mjs @@ -7,7 +7,7 @@ import { default as matter } from "gray-matter"; import { SitemapStream, streamToPromise } from "sitemap"; import { Readable } from "node:stream"; -const SKIP_THESE = /(node_modules|\.jekyll-cache)/; +const SKIP_THESE = /(node_modules|\.jekyll-cache|^sitemap.*)/; async function processFile(d, fullPath, out) { const f = await fs.readFile(fullPath, "utf-8"); @@ -43,9 +43,9 @@ async function traverse(d, out) { } -/** replace a/b/c.md with a/b/c.html */ -function md2html(p) { - return p.replace(/\.md$/, ".html"); +/** replace a/b/c.md with a/b/c */ +function dropmd(p) { + return p.replace(/\.md$/, ""); } @@ -54,7 +54,7 @@ async function writeSiteMaps(out) { const links = await Promise.all(out.all.map(async ({ fullPath, title }) => { const stat = await fs.stat(fullPath); return { - url: md2html(`/${fullPath}`), + url: dropmd(`/${fullPath}`), lastmod: stat.mtime.toISOString(), }; })); @@ -62,6 +62,12 @@ async function writeSiteMaps(out) { const data = (await streamToPromise(Readable.from(links).pipe(stream))).toString(); await fs.writeFile('./sitemap.xml', data, 'utf-8'); console.log('Wrote sitemap.xml'); + const coll = new Intl.Collator(['und']); + const allSorted = [...out.all].sort((a, b) => coll.compare(a.fullPath, b.fullPath)); + await fs.writeFile('./sitemap.md', `---\ntitle: Site Map\n---\n\n` + + allSorted.map(({fullPath, title})=> + `- [/${fullPath}](/${dropmd(fullPath)}) - ${title}`).join('\n'), 'utf-8'); + console.log('Wrote sitemap.md'); } async function main() {