@alauda/doom 0.23.3 → 0.23.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -74,7 +74,7 @@ export async function generatePdf({ pages, tempDir, port, host, outFile, outDir,
|
|
|
74
74
|
singleBar.stop();
|
|
75
75
|
await printer.closeBrowser();
|
|
76
76
|
const exportedPath = await mergePDF(normalizePages, outFile, outDir, allOutlines);
|
|
77
|
-
const message =
|
|
77
|
+
const message = `Exported to ${yellow(exportedPath)}\n`;
|
|
78
78
|
process.stdout.write(message);
|
|
79
79
|
await fs.rm(tempDir, { force: true, recursive: true });
|
|
80
80
|
return exportedPath;
|
|
@@ -112,7 +112,7 @@ export async function mergePDF(pages, outFile, outDir, pdfOutlines) {
|
|
|
112
112
|
}
|
|
113
113
|
const saveFilePath = join(saveDirPath, outFile);
|
|
114
114
|
if (pages.length === 0) {
|
|
115
|
-
process.
|
|
115
|
+
process.stderr.write(red('The website has no pages, please check whether the export path is set correctly'));
|
|
116
116
|
process.exit(1);
|
|
117
117
|
}
|
|
118
118
|
else if (pages.length === 1) {
|
package/lib/cli/export.js
CHANGED
|
@@ -85,9 +85,10 @@ export const exportCommand = new Command('export')
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
const exportPdf = async (sidebarItems, lang = config.lang) => {
|
|
88
|
-
|
|
88
|
+
const pages = collectPages(sidebarItems);
|
|
89
|
+
logger.start(`Exporting ${lang} language documents with ${pages.length} pages...`);
|
|
89
90
|
await generatePdf({
|
|
90
|
-
pages
|
|
91
|
+
pages,
|
|
91
92
|
outFile: getPdfName(lang, config.userBase, config.title),
|
|
92
93
|
...commonOptions,
|
|
93
94
|
});
|
|
@@ -11,9 +11,15 @@ const sidebarSorter = (a, b) => {
|
|
|
11
11
|
const bWeight = 'weight' in b && b.weight != null ? b.weight : 100;
|
|
12
12
|
return aWeight - bWeight;
|
|
13
13
|
};
|
|
14
|
+
const isExcluded = (onlyIncludeRoutes, excludeRoutes, fileKey) => {
|
|
15
|
+
const included = !onlyIncludeRoutes.length ||
|
|
16
|
+
onlyIncludeRoutes.some((glob) => picomatch.isMatch(fileKey, glob));
|
|
17
|
+
return (!included || excludeRoutes.some((glob) => picomatch.isMatch(fileKey, glob)));
|
|
18
|
+
};
|
|
14
19
|
/**
|
|
15
20
|
* 1. Split sideMeta into two parts: `index` and `others` and sort `others` by weight
|
|
16
|
-
* 2. filter
|
|
21
|
+
* 2. filter only include routes if `onlyIncludeRoutes` is not empty
|
|
22
|
+
* 3. filter out `excludeRoutes`
|
|
17
23
|
*/
|
|
18
24
|
const processSideMeta = (sideMeta, extensions, onlyIncludeRoutes, excludeRoutes) => {
|
|
19
25
|
const result = sideMeta.reduce((acc, curr) => {
|
|
@@ -24,10 +30,7 @@ const processSideMeta = (sideMeta, extensions, onlyIncludeRoutes, excludeRoutes)
|
|
|
24
30
|
acc.others.push(curr);
|
|
25
31
|
return acc;
|
|
26
32
|
}
|
|
27
|
-
const
|
|
28
|
-
onlyIncludeRoutes.some((glob) => picomatch.isMatch(curr._fileKey, glob));
|
|
29
|
-
const excluded = !included ||
|
|
30
|
-
excludeRoutes.some((glob) => picomatch.isMatch(curr._fileKey, glob));
|
|
33
|
+
const excluded = isExcluded(onlyIncludeRoutes, excludeRoutes, curr._fileKey);
|
|
31
34
|
let filePart;
|
|
32
35
|
if ((filePart = curr._fileKey.split(/[\\/]/).at(-1)) &&
|
|
33
36
|
extensions.some((ext) => filePart === `index${ext}`)) {
|
|
@@ -210,7 +213,9 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
|
|
|
210
213
|
// and generate the nav and sidebar config
|
|
211
214
|
export async function walk(workDir, routePrefix = '/', docsDir, extensions, onlyIncludeRoutes = [], excludeRoutes = [], collapsed) {
|
|
212
215
|
const { index, others } = await scanSideMeta(workDir, workDir, docsDir, routePrefix, extensions, ['assets', 'public', 'shared'], onlyIncludeRoutes, excludeRoutes);
|
|
213
|
-
const
|
|
216
|
+
const isIndexExcluded = !!index?._fileKey &&
|
|
217
|
+
isExcluded(onlyIncludeRoutes, excludeRoutes, index._fileKey);
|
|
218
|
+
const sidebars = index && !isIndexExcluded ? [index, ...others] : others;
|
|
214
219
|
if (collapsed != null) {
|
|
215
220
|
for (const sidebarItem of sidebars) {
|
|
216
221
|
if ('items' in sidebarItem && sidebarItem.items.length) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
7
7
|
"homepage": "https://github.com/alauda/doom#readme",
|
|
8
|
-
"funding": "https://opencollective.com/alauda",
|
|
9
8
|
"license": "MIT",
|
|
10
9
|
"engines": {
|
|
11
10
|
"node": ">=18.17.0 <20 || >=20.1.0"
|