blume 0.6.4 → 0.6.6
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.
|
@@ -60,7 +60,7 @@ navigation: {
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
- **`flat`** (default) — a non-collapsible header with its pages listed beneath. Pages that aren't in any group always list first, above the group sections, so they can't be mistaken for a group's children.
|
|
63
|
-
- **`group`** — a collapsible `<details>` disclosure per group.
|
|
63
|
+
- **`group`** — a collapsible `<details>` disclosure per group. Groups start collapsed by default; a group containing the current page always starts open, so only the section you're in is expanded. Set `collapsed: false` in [folder meta](/docs/content/meta) to force a group open regardless.
|
|
64
64
|
- **`page`** — each group is a single row that, when clicked, slides the sidebar into a sub-panel showing only that group's items, with a back arrow at the top. The panel is route-aware, so landing directly on a page inside the group opens straight to it.
|
|
65
65
|
|
|
66
66
|
:::tip
|
package/package.json
CHANGED
|
@@ -70,7 +70,7 @@ const tagList = Array.isArray(tags) ? tags : tags ? [tags] : [];
|
|
|
70
70
|
)
|
|
71
71
|
}
|
|
72
72
|
</header>
|
|
73
|
-
<div class="text-muted-foreground text-sm leading-6 [&_a]:font-medium [&_a]:text-foreground [&_a]:underline [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_h2]:mt-
|
|
73
|
+
<div class="text-muted-foreground text-sm leading-6 [&_a]:font-medium [&_a]:text-foreground [&_a]:underline [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_h2]:mt-6 [&_h2]:border-t-0! [&_h2]:pt-0! [&_h2]:text-base [&_h2]:font-semibold [&_h2]:text-foreground [&_h3]:mt-4 [&_h3]:font-semibold [&_h3]:text-foreground [&_img]:rounded-blume [&_li]:my-1 [&_p]:my-3 [&>:first-child]:mt-0! [&>:last-child]:mb-0!">
|
|
74
74
|
<slot />
|
|
75
75
|
</div>
|
|
76
76
|
</article>
|
|
@@ -218,7 +218,9 @@ const initialId =
|
|
|
218
218
|
// `group`: a collapsible `<details>` disclosure.
|
|
219
219
|
if (display === "group") {
|
|
220
220
|
const active = hasActivePage(item);
|
|
221
|
-
|
|
221
|
+
// Default every group closed; open only those on the active path (so
|
|
222
|
+
// the current page's ancestors stay expanded) or forced open via meta.
|
|
223
|
+
const open = active || item.collapsed === false;
|
|
222
224
|
return (
|
|
223
225
|
<li class={spacing}>
|
|
224
226
|
<details class="group" open={open}>
|
package/src/core/navigation.ts
CHANGED
|
@@ -184,16 +184,42 @@ const sortNodes = (nodes: MutableNode[]): void => {
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
187
|
+
* Hoist loose pages above groups so root-level pages read as top-level entries
|
|
188
|
+
* rather than a group's trailing children (relative order otherwise preserved).
|
|
189
|
+
* All display modes hoist the root level. Flat additionally recurses into every
|
|
190
|
+
* group: there a group renders as a plain section header, so a loose page sorted
|
|
191
|
+
* after a group would visually read as that group's last child.
|
|
190
192
|
*/
|
|
191
|
-
const hoistPages = (nodes: MutableNode[]): void => {
|
|
193
|
+
const hoistPages = (nodes: MutableNode[], recurse: boolean): void => {
|
|
192
194
|
const pages = nodes.filter((node) => node.kind === "page");
|
|
193
195
|
const groups = nodes.filter((node) => node.kind === "group");
|
|
194
196
|
nodes.splice(0, nodes.length, ...pages, ...groups);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
if (recurse) {
|
|
198
|
+
for (const group of groups) {
|
|
199
|
+
hoistPages(group.children, recurse);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* With tabs configured, the sidebar shown under a tab is that tab-section
|
|
206
|
+
* group's *children*, not the tree root — so hoisting only the root leaves a
|
|
207
|
+
* tab section's loose pages interleaved with its groups. Hoist the top level of
|
|
208
|
+
* every group that owns a tab (matched on its URL path), mirroring the root.
|
|
209
|
+
*/
|
|
210
|
+
const hoistTabSections = (
|
|
211
|
+
nodes: MutableNode[],
|
|
212
|
+
tabPaths: Set<string>,
|
|
213
|
+
recurse: boolean
|
|
214
|
+
): void => {
|
|
215
|
+
for (const node of nodes) {
|
|
216
|
+
if (node.kind !== "group") {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (node.routePath !== undefined && tabPaths.has(node.routePath)) {
|
|
220
|
+
hoistPages(node.children, recurse);
|
|
221
|
+
}
|
|
222
|
+
hoistTabSections(node.children, tabPaths, recurse);
|
|
197
223
|
}
|
|
198
224
|
};
|
|
199
225
|
|
|
@@ -227,7 +253,8 @@ const buildFileSystemSidebar = (
|
|
|
227
253
|
folderMeta: Map<string, FolderMeta>,
|
|
228
254
|
sharedMeta: Map<string, FolderMeta>,
|
|
229
255
|
metaPrefix: string,
|
|
230
|
-
display: SidebarDisplay
|
|
256
|
+
display: SidebarDisplay,
|
|
257
|
+
tabPaths: Set<string>
|
|
231
258
|
): NavNode[] => {
|
|
232
259
|
const root = createGroup("", "", "", 0);
|
|
233
260
|
|
|
@@ -280,9 +307,8 @@ const buildFileSystemSidebar = (
|
|
|
280
307
|
|
|
281
308
|
applyFolderMeta(root, folderMeta, sharedMeta, metaPrefix);
|
|
282
309
|
sortNodes(root.children);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
310
|
+
hoistPages(root.children, display === "flat");
|
|
311
|
+
hoistTabSections(root.children, tabPaths, display === "flat");
|
|
286
312
|
return root.children.map((child) => toNavNode(child, display));
|
|
287
313
|
};
|
|
288
314
|
|
|
@@ -432,7 +458,8 @@ export const buildNavigation = (
|
|
|
432
458
|
options.folderMeta,
|
|
433
459
|
sharedFolderMeta,
|
|
434
460
|
metaPrefix,
|
|
435
|
-
display
|
|
461
|
+
display,
|
|
462
|
+
new Set(tabs.map((tab) => tab.path).filter((path) => path !== "/"))
|
|
436
463
|
),
|
|
437
464
|
tabs,
|
|
438
465
|
};
|