Skip to content

Commit 8afaeaf

Browse files
committed
Add PDF export plugin for docs
Experiment to see if build if PDF export of docs could be viable.
1 parent 7129665 commit 8afaeaf

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

docs/.vuepress/styles/index.scss

+25
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,28 @@ html.dark .DocSearch {
238238
--docsearch-footer-shadow: inset 0 1px 0 0 rgba(73, 76, 106, 0.5),
239239
0 -4px 8px 0 rgba(0, 0, 0, 0.2);
240240
}
241+
242+
// ----------------------------------------------------------------------------------------------- //
243+
// Print / PDF
244+
// ----------------------------------------------------------------------------------------------- //
245+
246+
@media print {
247+
.navbar,
248+
.sidebar,
249+
.sidebar-mask,
250+
.page-edit,
251+
.page-nav,
252+
.page-meta {
253+
display: none;
254+
}
255+
256+
.theme-default-content {
257+
max-width: 98%;
258+
margin-left: 0.5em;
259+
margin-right: 0.5em;
260+
}
261+
262+
.page {
263+
padding-left: 0;
264+
}
265+
}

docs/.vuepress/vuepress-pdf.config.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineUserConfig } from "@condorhero/vuepress-plugin-export-pdf-v2";
2+
3+
/**
4+
* Export PDF configuration
5+
*
6+
* @see https://www.npmjs.com/package/@condorhero/vuepress-plugin-export-pdf-v2
7+
*/
8+
export default defineUserConfig({
9+
//theme: "@vuepress/theme-default",
10+
11+
/**
12+
* WARNING: Adapt these settings such that only desired version(s)
13+
* are exported...
14+
*/
15+
routePatterns: [
16+
'/archive/v1x/**',
17+
18+
'!/archive/v2x/**',
19+
'!/archive/v3x/**',
20+
'!/archive/v4x/**',
21+
'!/archive/v5x/**',
22+
'!/archive/v6x/**',
23+
'!/archive/v7x/**',
24+
'!/archive/current/**',
25+
'!/archive/next/**',
26+
],
27+
outDir: 'docs/.vuepress/public/pdf',
28+
pdfOptions: {
29+
displayHeaderFooter: true,
30+
31+
// @see https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.pdfoptions.md
32+
footerTemplate: '<div class="page-nav"><p class="inner"><span class="pageNumber"></span> / <span class="totalPages"></span> </p></div>',
33+
scale: 0.8
34+
},
35+
pdfOutlines: true,
36+
});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"scripts": {
1616
"docs:dev": "cross-env NODE_ENV=development vuepress dev docs --config docs/.vuepress/config.ts",
1717
"docs:build": "cross-env NODE_ENV=development vuepress build docs --config docs/.vuepress/config.ts",
18-
"docs:build-prod": "cross-env NODE_ENV=production vuepress build docs --config docs/.vuepress/config.ts"
18+
"docs:build-prod": "cross-env NODE_ENV=production vuepress build docs --config docs/.vuepress/config.ts",
19+
"docs:export-pdf": "press-export-pdf export --config docs/.vuepress/vuepress-pdf.config.ts"
1920
}
2021
}

0 commit comments

Comments
 (0)