astro-better-docs-sidebar 0.1.0 → 0.2.0
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.
- package/Sidebar.astro +19 -16
- package/package.json +1 -1
package/Sidebar.astro
CHANGED
|
@@ -52,27 +52,30 @@ function buildTree(pages: any[]) {
|
|
|
52
52
|
|
|
53
53
|
if (part === 'index') {
|
|
54
54
|
const effective: FolderBehavior = pageFolderBehavior || folderBehavior;
|
|
55
|
-
const href = `${basePath}/${slug.replace(/\/index$/, "")}`.replace(/\/+/g, '/').replace(/\/$/, "");
|
|
56
55
|
|
|
57
56
|
current.title = label || dataTitle || current.title;
|
|
58
57
|
if (order !== undefined) current.order = order;
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
// route: false pages still contribute title/order but produce no link
|
|
60
|
+
if (page.data?.route !== false) {
|
|
61
|
+
const href = `${basePath}/${slug.replace(/\/index$/, "")}`.replace(/\/+/g, '/').replace(/\/$/, "");
|
|
62
|
+
if (effective === 'page') {
|
|
63
|
+
current.href = href;
|
|
64
|
+
} else if (effective === 'overview') {
|
|
65
|
+
// inject a synthetic first child that links to the index page
|
|
66
|
+
current.children['__sidebar_overview__'] = {
|
|
67
|
+
name: '__sidebar_overview__',
|
|
68
|
+
title: overviewLabel,
|
|
69
|
+
href,
|
|
70
|
+
children: {},
|
|
71
|
+
sortedChildren: [],
|
|
72
|
+
isOpen: false,
|
|
73
|
+
isActive: false,
|
|
74
|
+
order: -Infinity,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// 'unclickable': no href set, no overview child
|
|
74
78
|
}
|
|
75
|
-
// 'unclickable': no href set, no overview child
|
|
76
79
|
break;
|
|
77
80
|
}
|
|
78
81
|
|