mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2024-12-23 23:29:19 +01:00
feat: add sitemap
This commit is contained in:
parent
32457fc466
commit
be60bf39b0
@ -1,7 +1,33 @@
|
||||
import { createWriteStream } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { SitemapStream } from "sitemap";
|
||||
import { defineConfig } from "vitepress";
|
||||
|
||||
const links = [];
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
// sitemap.xml
|
||||
transformHtml: (_, id, { pageData }) => {
|
||||
if (!/[\\/]404\.html$/.test(id))
|
||||
links.push({
|
||||
// you might need to change this if not using clean urls mode
|
||||
url: pageData.relativePath.replace(/((^|\/)index)?\.md$/, "$2.html"),
|
||||
lastmod: pageData.lastUpdated,
|
||||
});
|
||||
},
|
||||
buildEnd: async ({ outDir }) => {
|
||||
const sitemap = new SitemapStream({
|
||||
hostname: "https://nixos-and-flakes.thiscute.world/",
|
||||
});
|
||||
const writeStream = createWriteStream(resolve(outDir, "sitemap.xml"));
|
||||
sitemap.pipe(writeStream);
|
||||
links.forEach((link) => sitemap.write(link));
|
||||
sitemap.end();
|
||||
await new Promise((r) => writeStream.on("finish", r));
|
||||
},
|
||||
|
||||
// markdown options
|
||||
markdown: {
|
||||
theme: "material-theme-palenight",
|
||||
lineNumbers: true,
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"sitemap": "^7.1.1",
|
||||
"vitepress": "1.0.0-beta.3"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -6,6 +6,9 @@ dependencies:
|
||||
version: 3.0.3
|
||||
|
||||
devDependencies:
|
||||
sitemap:
|
||||
specifier: ^7.1.1
|
||||
version: 7.1.1
|
||||
vitepress:
|
||||
specifier: 1.0.0-beta.3
|
||||
version: 1.0.0-beta.3(@algolia/client-search@4.17.2)(search-insights@2.6.0)
|
||||
@ -415,6 +418,16 @@ packages:
|
||||
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
|
||||
dev: true
|
||||
|
||||
/@types/node@17.0.45:
|
||||
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
|
||||
dev: true
|
||||
|
||||
/@types/sax@1.2.4:
|
||||
resolution: {integrity: sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==}
|
||||
dependencies:
|
||||
'@types/node': 17.0.45
|
||||
dev: true
|
||||
|
||||
/@types/web-bluetooth@0.0.17:
|
||||
resolution: {integrity: sha512-4p9vcSmxAayx72yn70joFoL44c9MO/0+iVEBIQXe3v2h2SiAsEIo/G5v6ObFWvNKRFjbrVadNf9LqEEZeQPzdA==}
|
||||
dev: true
|
||||
@ -615,6 +628,10 @@ packages:
|
||||
resolution: {integrity: sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==}
|
||||
dev: true
|
||||
|
||||
/arg@5.0.2:
|
||||
resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==}
|
||||
dev: true
|
||||
|
||||
/body-scroll-lock@4.0.0-beta.0:
|
||||
resolution: {integrity: sha512-a7tP5+0Mw3YlUJcGAKUqIBkYYGlYxk2fnCasq/FUph1hadxlTRjF+gAcZksxANnaMnALjxEddmSi/H3OR8ugcQ==}
|
||||
dev: true
|
||||
@ -725,6 +742,10 @@ packages:
|
||||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/sax@1.2.4:
|
||||
resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==}
|
||||
dev: true
|
||||
|
||||
/search-insights@2.6.0:
|
||||
resolution: {integrity: sha512-vU2/fJ+h/Mkm/DJOe+EaM5cafJv/1rRTZpGJTuFPf/Q5LjzgMDsqPdSaZsAe+GAWHHsfsu+rQSAn6c8IGtBEVw==}
|
||||
engines: {node: '>=8.16.0'}
|
||||
@ -739,6 +760,17 @@ packages:
|
||||
vscode-textmate: 8.0.0
|
||||
dev: true
|
||||
|
||||
/sitemap@7.1.1:
|
||||
resolution: {integrity: sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==}
|
||||
engines: {node: '>=12.0.0', npm: '>=5.6.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@types/node': 17.0.45
|
||||
'@types/sax': 1.2.4
|
||||
arg: 5.0.2
|
||||
sax: 1.2.4
|
||||
dev: true
|
||||
|
||||
/source-map-js@1.0.2:
|
||||
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
Loading…
Reference in New Issue
Block a user