@baybreezy/docd 0.0.11 → 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
  *
@@ -59,11 +59,15 @@
59
59
  * Optional icon name to display next to the filename
60
60
  */
61
61
  icon?: string;
62
+ /**
63
+ * Format the filename: strip the file extension and apply title case
64
+ */
65
+ format?: boolean;
62
66
  }>();
63
67
 
64
68
  /**
65
69
  * Parse meta string and create a lowercase key map for easy checking
66
- * Example: "noFormat hideHeader icon='lucide:code'" => Map { 'noformat' => true, 'hideheader' => true, 'icon' => 'lucide:code' }
70
+ * Example: "format hideHeader icon='lucide:code'" => Map { 'format' => true, 'hideheader' => true, 'icon' => 'lucide:code' }
67
71
  */
68
72
  const metaMap = computed(() => {
69
73
  const map = new Map<string, string | boolean>();
@@ -90,7 +94,7 @@
90
94
  });
91
95
 
92
96
  const hideCopyButton = ref(false);
93
- const noFormatMeta = computed(() => metaMap.value.has("noformat"));
97
+ const formatMeta = computed(() => metaMap.value.has("format"));
94
98
  const hideHeaderMeta = computed(
95
99
  () => metaMap.value.has("hideheader") || metaMap.value.has("noheader")
96
100
  );
@@ -107,7 +111,7 @@
107
111
 
108
112
  const fileNameEdited = computed(() => {
109
113
  if (!props.filename) return;
110
- if (noFormatMeta.value) return props.filename;
114
+ if (!props.format && !formatMeta.value) return props.filename;
111
115
 
112
116
  let processedName = props.filename;
113
117
 
@@ -50,7 +50,7 @@
50
50
  <!-- Collapsible item -->
51
51
  <UiCollapsible
52
52
  v-else
53
- :default-open="route.path.includes(group.item.path)"
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 class="gap-4 first:mt-2" :items="group.item.children!" :nested="true" />
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[] }
@@ -10,7 +10,7 @@ export const useDocPage = async () => {
10
10
 
11
11
  const [{ data: page }, { data: surround }, { data: navigation }] = await Promise.all([
12
12
  useAsyncData(
13
- kebabCase(route.path),
13
+ kebabCase(route.path) || "root",
14
14
  () =>
15
15
  isLandingRoute
16
16
  ? queryCollection("landing" as keyof Collections)
@@ -22,7 +22,7 @@ export const useDocPage = async () => {
22
22
  { watch: [() => route.path] }
23
23
  ),
24
24
  useAsyncData(
25
- `${kebabCase(route.path)}-surround`,
25
+ `${kebabCase(route.path) || "root"}-surround`,
26
26
  () => {
27
27
  if (isLandingRoute) {
28
28
  return Promise.resolve(null);
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baybreezy/docd",
3
- "version": "0.0.11",
3
+ "version": "0.1.0",
4
4
  "description": "A Nuxt layer for building documentation sites with UI Thing.",
5
5
  "repository": {
6
6
  "type": "git",