@alauda/doom 0.23.3 → 0.23.4
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.
|
@@ -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) {
|