mirror of
https://github.com/ryan4yin/nixos-and-flakes-book
synced 2024-11-23 04:33:08 +00:00
Merge pull request #25 from ryan4yin/add-pdf
feat: generate pdf for this book
This commit is contained in:
commit
a8c599fbce
6 changed files with 1489 additions and 220 deletions
7
docs/.vitepress/style/print.css
Normal file
7
docs/.vitepress/style/print.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
@media print {
|
||||
.VPNav,
|
||||
.VPLocalNav,
|
||||
.VPDocFooter {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
10
docs/.vitepress/theme/index.ts
Normal file
10
docs/.vitepress/theme/index.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
// .vitepress/theme/index.ts
|
||||
import DefaultTheme from "vitepress/theme";
|
||||
|
||||
// custom CSS
|
||||
import "../style/print.css";
|
||||
|
||||
export default {
|
||||
// Extending the Default Theme
|
||||
...DefaultTheme,
|
||||
};
|
30
docs/.vitepress/vitepress-pdf.config.ts
Normal file
30
docs/.vitepress/vitepress-pdf.config.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { defineUserConfig } from "vitepress-export-pdf";
|
||||
import config from './config'
|
||||
|
||||
|
||||
// convert `config.themeConfig?.sidebar` to a list of routes
|
||||
let routeOrder = [];
|
||||
const sidebar = config.locales.root.themeConfig?.sidebar;
|
||||
if (sidebar) {
|
||||
sidebar.forEach((it) => {
|
||||
if (it.items) {
|
||||
it.items.forEach((subItem) => {
|
||||
routeOrder.push(subItem.link.replace(/\.md$/, ""));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// print routeOrder in terminal
|
||||
console.log("routeOrder: ", routeOrder);
|
||||
|
||||
export default defineUserConfig({
|
||||
routePatterns: ["!/zh/**"], // exclude zh-CN pages
|
||||
sorter: (pageA, pageB) => {
|
||||
const aIndex = routeOrder.findIndex(route => route === pageA.path);
|
||||
const bIndex = routeOrder.findIndex(route => route === pageB.path);
|
||||
const index = aIndex - bIndex;
|
||||
// console.log(`sorter: ${pageA.path} vs ${pageB.path} = ${index}`);
|
||||
return index;
|
||||
},
|
||||
});
|
|
@ -29,7 +29,12 @@
|
|||
|
||||
shellHook = ''
|
||||
echo "node `${pkgs.nodejs}/bin/node --version`"
|
||||
|
||||
# Set Puppeteer to not download Chrome, cause it doesn't work on NixOS
|
||||
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
|
||||
# Set Puppeteer to use Chromium from Nixpkgs
|
||||
export PUPPETEER_EXECUTABLE_PATH=${pkgs.chromium.outPath}/bin/chromium
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"vitepress": "1.0.0-beta.5"
|
||||
"vitepress": "1.0.0-beta.7",
|
||||
"vitepress-export-pdf": "1.0.0-beta.0"
|
||||
},
|
||||
"scripts": {
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs"
|
||||
"docs:preview": "vitepress preview docs",
|
||||
"export-pdf": "press-export-pdf export ./docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"markdown-it-footnote": "^3.0.3",
|
||||
"sitemap-ts": "^1.4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1647
pnpm-lock.yaml
1647
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue