@baybreezy/docd 0.0.12 → 0.1.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/app/app.config.ts
CHANGED
|
@@ -202,6 +202,14 @@ export type DocdConfig = {
|
|
|
202
202
|
* The color mode to use for the site by default.
|
|
203
203
|
*/
|
|
204
204
|
colorMode?: "light" | "dark";
|
|
205
|
+
/**
|
|
206
|
+
* Controls which collapsible sections in the navigation sidebar are expanded by default.
|
|
207
|
+
*
|
|
208
|
+
* - `true`: expand all collapsibles
|
|
209
|
+
* - `number`: expand the collapsible at this 1-based position (e.g. `2` = second group)
|
|
210
|
+
* - `number[]`: expand collapsibles at these 1-based positions (e.g. `[2, 3]` = second and third groups)
|
|
211
|
+
*/
|
|
212
|
+
expandNav?: true | number | number[];
|
|
205
213
|
/**
|
|
206
214
|
* Page transition configuration. Set `name` to `"none"` to disable transitions entirely.
|
|
207
215
|
*
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
<!-- Collapsible item -->
|
|
51
51
|
<UiCollapsible
|
|
52
52
|
v-else
|
|
53
|
-
:default-open="
|
|
53
|
+
:default-open="isDefaultOpen(group.item, gi)"
|
|
54
54
|
class="flex flex-col border-b pb-4"
|
|
55
55
|
:class="[
|
|
56
56
|
isDashed ? 'border-dashed' : '',
|
|
@@ -76,7 +76,12 @@
|
|
|
76
76
|
<div
|
|
77
77
|
class="relative pt-1 pl-8 before:absolute before:left-2 before:h-[calc(100%-23px)] before:w-px before:bg-border dark:before:bg-accent"
|
|
78
78
|
>
|
|
79
|
-
<DocsNav
|
|
79
|
+
<DocsNav
|
|
80
|
+
class="gap-4 first:mt-2"
|
|
81
|
+
:items="group.item.children!"
|
|
82
|
+
:nested="true"
|
|
83
|
+
:depth="(props.depth ?? 1) + 1"
|
|
84
|
+
/>
|
|
80
85
|
</div>
|
|
81
86
|
</UiCollapsibleContent>
|
|
82
87
|
</UiCollapsible>
|
|
@@ -127,10 +132,26 @@
|
|
|
127
132
|
const props = defineProps<{
|
|
128
133
|
items: ContentNavigationItem[];
|
|
129
134
|
nested?: boolean;
|
|
135
|
+
depth?: number;
|
|
130
136
|
}>();
|
|
131
137
|
|
|
132
138
|
const route = useRoute();
|
|
133
139
|
const { isDashed } = useDocd();
|
|
140
|
+
const expandNav = useUIConfig("expandNav");
|
|
141
|
+
|
|
142
|
+
function isDefaultOpen(item: ContentNavigationItem, gi: number): boolean {
|
|
143
|
+
if (route.path.includes(item.path)) return true;
|
|
144
|
+
const cfg = expandNav.value;
|
|
145
|
+
if (cfg === true) return true;
|
|
146
|
+
// 1-based index among collapsible groups only
|
|
147
|
+
let collapsibleIdx = 0;
|
|
148
|
+
for (let i = 0; i <= gi; i++) {
|
|
149
|
+
if (groups.value[i]?.type === "collapsible") collapsibleIdx++;
|
|
150
|
+
}
|
|
151
|
+
if (typeof cfg === "number") return collapsibleIdx === cfg;
|
|
152
|
+
if (Array.isArray(cfg)) return cfg.includes(collapsibleIdx);
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
134
155
|
|
|
135
156
|
type Group =
|
|
136
157
|
| { type: "flat"; items: ContentNavigationItem[] }
|
|
@@ -17,6 +17,7 @@ interface DocdUIMap {
|
|
|
17
17
|
borderType: BorderType;
|
|
18
18
|
transition: DocdTransitionConfig;
|
|
19
19
|
extraLinks: DocdExtraLink[];
|
|
20
|
+
expandNav: true | number | number[] | undefined;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function useUIConfig<K extends keyof DocdUIMap>(section: K): ComputedRef<DocdUIMap[K]> {
|
|
@@ -33,4 +34,5 @@ const defaultValues: DocdUIMap = {
|
|
|
33
34
|
borderType: "dashed",
|
|
34
35
|
transition: { name: "fade", duration: 0.35, easing: "easeOut" },
|
|
35
36
|
extraLinks: [],
|
|
37
|
+
expandNav: undefined,
|
|
36
38
|
};
|