@writedocs/generator 0.10.20 → 0.11.1

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.
Files changed (53) hide show
  1. package/astro.config.mjs +32 -8
  2. package/package.json +3 -1
  3. package/src/cli/astro-output.js +44 -11
  4. package/src/cli/base-path-layout.js +44 -0
  5. package/src/cli/build.js +18 -9
  6. package/src/cli/check-built-styles.js +41 -33
  7. package/src/cli/dev.js +21 -4
  8. package/src/cli/run-pagefind.js +154 -148
  9. package/src/cli/write-mcp-files.js +103 -96
  10. package/src/cli/write-redirects-file.js +25 -8
  11. package/src/components/AppIcon.astro +51 -50
  12. package/src/components/Card.astro +193 -192
  13. package/src/components/CopyPageMenu.astro +374 -370
  14. package/src/components/Hint.astro +188 -187
  15. package/src/components/Icon.astro +72 -71
  16. package/src/components/Image.astro +3 -2
  17. package/src/components/Tile.astro +67 -66
  18. package/src/components/Video.astro +137 -136
  19. package/src/layout/BaseLayout.astro +21 -12
  20. package/src/layout/components/AnalyticsScripts.astro +6 -2
  21. package/src/layout/components/Breadcrumbs.astro +98 -97
  22. package/src/layout/components/ConsentBanner.astro +119 -118
  23. package/src/layout/components/MobileMenu.astro +229 -228
  24. package/src/layout/components/NavTree.astro +393 -392
  25. package/src/layout/components/Sidebar.astro +232 -231
  26. package/src/layout/components/SiteFooter.astro +87 -86
  27. package/src/layout/components/TopBar.astro +386 -385
  28. package/src/lib/agent-markdown.js +164 -162
  29. package/src/lib/asset-dimensions.js +89 -89
  30. package/src/lib/base-path.js +90 -0
  31. package/src/lib/config-schema.js +10 -0
  32. package/src/lib/config-schema.ts +17 -0
  33. package/src/lib/config.ts +1314 -1289
  34. package/src/lib/consent.js +108 -102
  35. package/src/lib/json-schema-descriptions.js +1 -0
  36. package/src/lib/link-check.js +7 -2
  37. package/src/lib/llms-index.ts +90 -88
  38. package/src/lib/mcp-dev-integration.js +65 -60
  39. package/src/lib/mcp-index.ts +102 -101
  40. package/src/lib/project-files-integration.js +2 -2
  41. package/src/lib/rehype-base-path.js +62 -0
  42. package/src/lib/robots-txt.js +21 -16
  43. package/src/lib/seo-tags.js +155 -140
  44. package/src/lib/site-base.ts +27 -0
  45. package/src/lib/styles-asset-integration.js +23 -10
  46. package/src/lib/wdignore-cases.json +195 -195
  47. package/src/lib/wdignore.js +177 -177
  48. package/src/pages/404.astro +63 -62
  49. package/src/pages/[...slug].astro +1604 -1597
  50. package/src/pages/[...slug].md.ts +93 -93
  51. package/src/pages/llms-full.txt.ts +88 -86
  52. package/src/scripts/search.ts +245 -237
  53. package/writedocs.schema.json +6 -0
@@ -1,228 +1,229 @@
1
- ---
2
- // The <= 860px overlay drawer that TopBar.astro's own hamburger button
3
- // opens - everything that's a side-by-side control on desktop (the
4
- // brand-row switchers, the tabs bar, the always-visible global dropdowns)
5
- // plus the sidebar itself collapses into this one panel below 860px.
6
- // Reuses the exact same `selectors`/`globalDropdowns` props TopBar.astro
7
- // renders its own desktop switchers/tabs from (see its own
8
- // switcherSelectors/tabSelectors) rather than a filtered subset - unlike
9
- // TopBar's switcherSelectors (which deliberately *drops* a dropdown
10
- // selector nested directly under a tab, since desktop folds it into that
11
- // tab's own dropdown-trigger button), this renders every entry of
12
- // `selectors` in root-to-leaf order as its own accordion row. That's what
13
- // makes "a tab with its own dropdowns gets a second selector right below
14
- // it" fall out for free: when the active page is under such a tab,
15
- // `selectors` already contains that nested dropdown as its own array
16
- // entry immediately following the tab's entry (see buildSelectors() in
17
- // lib/config.ts, which walks the active PathSegment[] in that exact
18
- // order) - no tab-specific branching needed here at all.
19
- //
20
- // The sidebar itself is the `sidebar` slot, forwarded straight through
21
- // from whatever BaseLayout.astro received - rendered a second time
22
- // (Astro renders the same passed-in slot content at every place it's
23
- // referenced, not just once); the first copy is in BaseLayout's own
24
- // `.wd-sidebar-col`, for desktop. Both copies exist in the DOM on every
25
- // load; only one is ever visible at a time (mobile-menu.css hides this
26
- // whole panel above 860px, base.css hides .wd-sidebar-col at/below it),
27
- // so there's no duplicate-content flash either way.
28
- //
29
- // Split out of BaseLayout.astro, which had grown to ~2200 lines covering
30
- // several unrelated concerns in one file - see that component's own
31
- // comment for the fuller rationale.
32
- import { isExternalHref, type DocsConfig, type Selector, type GlobalDropdownView } from '../../lib/config';
33
- import AppIcon from '../../components/AppIcon.astro';
34
- import { logoWidth } from '../../lib/image-size.js';
35
- import { hasMobileMenu, currentOption } from '../../lib/selector-placement.js';
36
- import '../styles/dropdown.css';
37
- import '../styles/topbar.css';
38
- import '../styles/mobile-menu.css';
39
-
40
- interface Props {
41
- config: DocsConfig;
42
- selectors: Selector[];
43
- globalDropdowns: GlobalDropdownView[];
44
- // Whether this page would show a sidebar at all (mode === 'default' or
45
- // 'wide') - this whole component renders nothing otherwise, same
46
- // condition TopBar.astro gates its own hamburger toggle on.
47
- showSidebarCol: boolean;
48
- logoLight?: string;
49
- logoDark?: string;
50
- brandLabel?: string;
51
- }
52
- const { config, selectors, globalDropdowns, showSidebarCol, logoLight, logoDark, brandLabel } = Astro.props as Props;
53
- // A page without a sidebar (`mode: custom`) still gets the menu when it has
54
- // tabs, switchers or global dropdowns to reach - just without the sidebar part.
55
- const showMenu = hasMobileMenu({ sidebar: showSidebarCol, selectors, globalDropdowns });
56
- ---
57
- {showMenu && (
58
- <div class="wd-mobile-menu" id="wd-mobile-menu" inert>
59
- <div class="wd-mobile-menu-backdrop" data-mobile-menu-backdrop></div>
60
- <div class="wd-mobile-menu-panel" role="dialog" aria-modal="true" aria-label="Navigation">
61
- {/* The panel reaches all the way to the top of the viewport (see
62
- mobile-menu.css) rather than stopping below the real topbar -
63
- the real topbar's own height varies (one row, or two once
64
- tabs/global dropdowns/a wrapped search box are involved), which
65
- made lining this panel up under it a fragile approximation.
66
- Instead this header replicates the topbar's own brand/close/
67
- theme row *inside* the panel, at a fixed height the panel fully
68
- controls, so it reads as "the same navbar" occupying the same
69
- spot rather than a separate floating piece underneath one of
70
- variable size. The real topbar is still there underneath, just
71
- no longer relied on for anything while the menu is open - it's
72
- covered by this panel's own opaque background (or dimmed by the
73
- backdrop, past the panel's own width). */}
74
- <div class="wd-mobile-menu-header">
75
- <button
76
- type="button"
77
- class="wd-mobile-menu-close"
78
- aria-label="Close menu"
79
- data-mobile-menu-close
80
- >
81
- <svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true">
82
- <path d="M4 4L14 14M14 4L4 14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
83
- </svg>
84
- </button>
85
- <a class="wd-topbar-brand" href="/">
86
- {logoLight && <img src={logoLight} alt={config.name} height="24" width={logoWidth(logoLight)} class="wd-logo-light" />}
87
- {logoDark && <img src={logoDark} alt={config.name} height="24" width={logoWidth(logoDark)} class="wd-logo-dark" />}
88
- {brandLabel && <span>{brandLabel}</span>}
89
- </a>
90
- {/* Same class as the real topbar's own theme button -
91
- initThemeToggle() (src/scripts/theme-toggle.ts, wired below)
92
- wires up every `.wd-theme-toggle` it finds (not just the
93
- first), and both stay in sync for free since [data-theme] on
94
- <html> - not per-button JS state - is what actually drives
95
- which icon shows. */}
96
- <button type="button" class="wd-theme-toggle" aria-label="Toggle color theme">
97
- <AppIcon icon="sun" class="wd-theme-icon wd-theme-icon-sun" />
98
- <AppIcon icon="moon" class="wd-theme-icon wd-theme-icon-moon" />
99
- </button>
100
- </div>
101
- <div class="wd-mobile-menu-scroll">
102
- {(selectors.some((sel) => !sel.hidden) || globalDropdowns.length > 0) && (
103
- <div class="wd-mobile-menu-selectors">
104
- {selectors.filter((sel) => !sel.hidden).map((sel) => {
105
- // The level under an item whose own page this is, with nothing
106
- // chosen yet (landingSelectors() in lib/config.ts): its options
107
- // as an open list - a closed one would repeat the item's name,
108
- // already on the level above.
109
- if (sel.placeholder && !sel.options.some((opt) => opt.active)) {
110
- return (
111
- <nav class="wd-mobile-menu-choices" aria-label={sel.placeholder.label}>
112
- {sel.options.map((opt) => (
113
- <a
114
- href={opt.href}
115
- target={isExternalHref(opt.href) ? '_blank' : undefined}
116
- rel={isExternalHref(opt.href) ? 'noopener noreferrer' : undefined}
117
- >
118
- <AppIcon icon={opt.icon} class="wd-tab-icon" />
119
- <span class="wd-mobile-accordion-option-label">{opt.label}</span>
120
- {opt.tag && <span class="wd-selector-tag">{opt.tag}</span>}
121
- </a>
122
- ))}
123
- </nav>
124
- );
125
- }
126
- const current = currentOption(sel);
127
- return (
128
- <details class="wd-mobile-accordion" name="wd-mobile-accordion">
129
- <summary class="wd-mobile-accordion-trigger">
130
- <AppIcon icon={current.icon} class="wd-tab-icon" />
131
- <span class="wd-mobile-accordion-label">{current.label}</span>
132
- {current.tag && <span class="wd-selector-tag">{current.tag}</span>}
133
- <svg class="wd-mobile-accordion-caret" width="12" height="12" viewBox="0 0 10 10" aria-hidden="true">
134
- <path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round" />
135
- </svg>
136
- </summary>
137
- <div class="wd-mobile-accordion-options">
138
- <div class="wd-mobile-accordion-options-panel">
139
- {sel.options.map((opt) => (
140
- <a
141
- href={opt.href}
142
- class={opt.active ? 'active' : ''}
143
- target={isExternalHref(opt.href) ? '_blank' : undefined}
144
- rel={isExternalHref(opt.href) ? 'noopener noreferrer' : undefined}
145
- >
146
- <AppIcon icon={opt.icon} class="wd-tab-icon" />
147
- <span class="wd-mobile-accordion-option-label">{opt.label}</span>
148
- {opt.tag && <span class="wd-selector-tag">{opt.tag}</span>}
149
- {opt.active && (
150
- <svg class="wd-mobile-accordion-check" width="14" height="14" viewBox="0 0 14 14" aria-hidden="true">
151
- <path d="M3 7.5L6 10.5L11 4.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round" />
152
- </svg>
153
- )}
154
- </a>
155
- ))}
156
- </div>
157
- </div>
158
- </details>
159
- );
160
- })}
161
- {globalDropdowns.map((d) =>
162
- d.href !== null ? (
163
- <a
164
- href={d.href}
165
- class="wd-mobile-menu-link"
166
- target={isExternalHref(d.href) ? '_blank' : undefined}
167
- rel={isExternalHref(d.href) ? 'noopener noreferrer' : undefined}
168
- >
169
- <AppIcon icon={d.icon} class="wd-tab-icon" />
170
- <span class="wd-mobile-accordion-option-label">{d.label}</span>
171
- </a>
172
- ) : (
173
- <details class="wd-mobile-accordion" name="wd-mobile-accordion">
174
- <summary class="wd-mobile-accordion-trigger">
175
- <AppIcon icon={d.icon} class="wd-tab-icon" />
176
- <span class="wd-mobile-accordion-label">{d.label}</span>
177
- <svg class="wd-mobile-accordion-caret" width="12" height="12" viewBox="0 0 10 10" aria-hidden="true">
178
- <path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round" />
179
- </svg>
180
- </summary>
181
- <div class="wd-mobile-accordion-options">
182
- <div class="wd-mobile-accordion-options-panel">
183
- {d.items.map((item) => (
184
- <a href={item.href} class={item.active ? 'active' : ''}>
185
- <span class="wd-mobile-accordion-option-label">{item.label}</span>
186
- {item.active && (
187
- <svg class="wd-mobile-accordion-check" width="14" height="14" viewBox="0 0 14 14" aria-hidden="true">
188
- <path d="M3 7.5L6 10.5L11 4.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round" />
189
- </svg>
190
- )}
191
- </a>
192
- ))}
193
- </div>
194
- </div>
195
- </details>
196
- )
197
- )}
198
- </div>
199
- )}
200
- {showSidebarCol && (
201
- <div class="wd-mobile-menu-sidebar">
202
- <slot name="sidebar" />
203
- </div>
204
- )}
205
- </div>
206
- </div>
207
- </div>
208
- )}
209
- <script>
210
- import { initMobileMenu } from '../../scripts/mobile-menu';
211
- import { initThemeToggle } from '../../scripts/theme-toggle';
212
- // Not required by any markup this component currently renders (its own
213
- // accordion rows are plain <details>, not .wd-dropdown), but imported
214
- // and called anyway so both this file and TopBar.astro consistently own
215
- // wiring up whatever interactive primitives their own markup might use
216
- // - safe/idempotent regardless of how many components call it, see
217
- // src/scripts/dropdowns.ts's own comment.
218
- import { initDropdowns } from '../../scripts/dropdowns';
219
-
220
- initMobileMenu(document);
221
- initThemeToggle(document);
222
- initDropdowns(document);
223
- document.addEventListener('astro:page-load', () => {
224
- initMobileMenu(document);
225
- initThemeToggle(document);
226
- initDropdowns(document);
227
- });
228
- </script>
1
+ ---
2
+ // The <= 860px overlay drawer that TopBar.astro's own hamburger button
3
+ // opens - everything that's a side-by-side control on desktop (the
4
+ // brand-row switchers, the tabs bar, the always-visible global dropdowns)
5
+ // plus the sidebar itself collapses into this one panel below 860px.
6
+ // Reuses the exact same `selectors`/`globalDropdowns` props TopBar.astro
7
+ // renders its own desktop switchers/tabs from (see its own
8
+ // switcherSelectors/tabSelectors) rather than a filtered subset - unlike
9
+ // TopBar's switcherSelectors (which deliberately *drops* a dropdown
10
+ // selector nested directly under a tab, since desktop folds it into that
11
+ // tab's own dropdown-trigger button), this renders every entry of
12
+ // `selectors` in root-to-leaf order as its own accordion row. That's what
13
+ // makes "a tab with its own dropdowns gets a second selector right below
14
+ // it" fall out for free: when the active page is under such a tab,
15
+ // `selectors` already contains that nested dropdown as its own array
16
+ // entry immediately following the tab's entry (see buildSelectors() in
17
+ // lib/config.ts, which walks the active PathSegment[] in that exact
18
+ // order) - no tab-specific branching needed here at all.
19
+ //
20
+ // The sidebar itself is the `sidebar` slot, forwarded straight through
21
+ // from whatever BaseLayout.astro received - rendered a second time
22
+ // (Astro renders the same passed-in slot content at every place it's
23
+ // referenced, not just once); the first copy is in BaseLayout's own
24
+ // `.wd-sidebar-col`, for desktop. Both copies exist in the DOM on every
25
+ // load; only one is ever visible at a time (mobile-menu.css hides this
26
+ // whole panel above 860px, base.css hides .wd-sidebar-col at/below it),
27
+ // so there's no duplicate-content flash either way.
28
+ //
29
+ // Split out of BaseLayout.astro, which had grown to ~2200 lines covering
30
+ // several unrelated concerns in one file - see that component's own
31
+ // comment for the fuller rationale.
32
+ import { isExternalHref, type DocsConfig, type Selector, type GlobalDropdownView } from '../../lib/config';
33
+ import AppIcon from '../../components/AppIcon.astro';
34
+ import { logoWidth } from '../../lib/image-size.js';
35
+ import { hasMobileMenu, currentOption } from '../../lib/selector-placement.js';
36
+ import '../styles/dropdown.css';
37
+ import '../styles/topbar.css';
38
+ import '../styles/mobile-menu.css';
39
+ import { siteHref } from '../../lib/site-base';
40
+
41
+ interface Props {
42
+ config: DocsConfig;
43
+ selectors: Selector[];
44
+ globalDropdowns: GlobalDropdownView[];
45
+ // Whether this page would show a sidebar at all (mode === 'default' or
46
+ // 'wide') - this whole component renders nothing otherwise, same
47
+ // condition TopBar.astro gates its own hamburger toggle on.
48
+ showSidebarCol: boolean;
49
+ logoLight?: string;
50
+ logoDark?: string;
51
+ brandLabel?: string;
52
+ }
53
+ const { config, selectors, globalDropdowns, showSidebarCol, logoLight, logoDark, brandLabel } = Astro.props as Props;
54
+ // A page without a sidebar (`mode: custom`) still gets the menu when it has
55
+ // tabs, switchers or global dropdowns to reach - just without the sidebar part.
56
+ const showMenu = hasMobileMenu({ sidebar: showSidebarCol, selectors, globalDropdowns });
57
+ ---
58
+ {showMenu && (
59
+ <div class="wd-mobile-menu" id="wd-mobile-menu" inert>
60
+ <div class="wd-mobile-menu-backdrop" data-mobile-menu-backdrop></div>
61
+ <div class="wd-mobile-menu-panel" role="dialog" aria-modal="true" aria-label="Navigation">
62
+ {/* The panel reaches all the way to the top of the viewport (see
63
+ mobile-menu.css) rather than stopping below the real topbar -
64
+ the real topbar's own height varies (one row, or two once
65
+ tabs/global dropdowns/a wrapped search box are involved), which
66
+ made lining this panel up under it a fragile approximation.
67
+ Instead this header replicates the topbar's own brand/close/
68
+ theme row *inside* the panel, at a fixed height the panel fully
69
+ controls, so it reads as "the same navbar" occupying the same
70
+ spot rather than a separate floating piece underneath one of
71
+ variable size. The real topbar is still there underneath, just
72
+ no longer relied on for anything while the menu is open - it's
73
+ covered by this panel's own opaque background (or dimmed by the
74
+ backdrop, past the panel's own width). */}
75
+ <div class="wd-mobile-menu-header">
76
+ <button
77
+ type="button"
78
+ class="wd-mobile-menu-close"
79
+ aria-label="Close menu"
80
+ data-mobile-menu-close
81
+ >
82
+ <svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true">
83
+ <path d="M4 4L14 14M14 4L4 14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
84
+ </svg>
85
+ </button>
86
+ <a class="wd-topbar-brand" href={siteHref("/")}>
87
+ {logoLight && <img src={siteHref(logoLight)} alt={config.name} height="24" width={logoWidth(logoLight)} class="wd-logo-light" />}
88
+ {logoDark && <img src={siteHref(logoDark)} alt={config.name} height="24" width={logoWidth(logoDark)} class="wd-logo-dark" />}
89
+ {brandLabel && <span>{brandLabel}</span>}
90
+ </a>
91
+ {/* Same class as the real topbar's own theme button -
92
+ initThemeToggle() (src/scripts/theme-toggle.ts, wired below)
93
+ wires up every `.wd-theme-toggle` it finds (not just the
94
+ first), and both stay in sync for free since [data-theme] on
95
+ <html> - not per-button JS state - is what actually drives
96
+ which icon shows. */}
97
+ <button type="button" class="wd-theme-toggle" aria-label="Toggle color theme">
98
+ <AppIcon icon="sun" class="wd-theme-icon wd-theme-icon-sun" />
99
+ <AppIcon icon="moon" class="wd-theme-icon wd-theme-icon-moon" />
100
+ </button>
101
+ </div>
102
+ <div class="wd-mobile-menu-scroll">
103
+ {(selectors.some((sel) => !sel.hidden) || globalDropdowns.length > 0) && (
104
+ <div class="wd-mobile-menu-selectors">
105
+ {selectors.filter((sel) => !sel.hidden).map((sel) => {
106
+ // The level under an item whose own page this is, with nothing
107
+ // chosen yet (landingSelectors() in lib/config.ts): its options
108
+ // as an open list - a closed one would repeat the item's name,
109
+ // already on the level above.
110
+ if (sel.placeholder && !sel.options.some((opt) => opt.active)) {
111
+ return (
112
+ <nav class="wd-mobile-menu-choices" aria-label={sel.placeholder.label}>
113
+ {sel.options.map((opt) => (
114
+ <a
115
+ href={siteHref(opt.href)}
116
+ target={isExternalHref(opt.href) ? '_blank' : undefined}
117
+ rel={isExternalHref(opt.href) ? 'noopener noreferrer' : undefined}
118
+ >
119
+ <AppIcon icon={opt.icon} class="wd-tab-icon" />
120
+ <span class="wd-mobile-accordion-option-label">{opt.label}</span>
121
+ {opt.tag && <span class="wd-selector-tag">{opt.tag}</span>}
122
+ </a>
123
+ ))}
124
+ </nav>
125
+ );
126
+ }
127
+ const current = currentOption(sel);
128
+ return (
129
+ <details class="wd-mobile-accordion" name="wd-mobile-accordion">
130
+ <summary class="wd-mobile-accordion-trigger">
131
+ <AppIcon icon={current.icon} class="wd-tab-icon" />
132
+ <span class="wd-mobile-accordion-label">{current.label}</span>
133
+ {current.tag && <span class="wd-selector-tag">{current.tag}</span>}
134
+ <svg class="wd-mobile-accordion-caret" width="12" height="12" viewBox="0 0 10 10" aria-hidden="true">
135
+ <path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round" />
136
+ </svg>
137
+ </summary>
138
+ <div class="wd-mobile-accordion-options">
139
+ <div class="wd-mobile-accordion-options-panel">
140
+ {sel.options.map((opt) => (
141
+ <a
142
+ href={siteHref(opt.href)}
143
+ class={opt.active ? 'active' : ''}
144
+ target={isExternalHref(opt.href) ? '_blank' : undefined}
145
+ rel={isExternalHref(opt.href) ? 'noopener noreferrer' : undefined}
146
+ >
147
+ <AppIcon icon={opt.icon} class="wd-tab-icon" />
148
+ <span class="wd-mobile-accordion-option-label">{opt.label}</span>
149
+ {opt.tag && <span class="wd-selector-tag">{opt.tag}</span>}
150
+ {opt.active && (
151
+ <svg class="wd-mobile-accordion-check" width="14" height="14" viewBox="0 0 14 14" aria-hidden="true">
152
+ <path d="M3 7.5L6 10.5L11 4.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round" />
153
+ </svg>
154
+ )}
155
+ </a>
156
+ ))}
157
+ </div>
158
+ </div>
159
+ </details>
160
+ );
161
+ })}
162
+ {globalDropdowns.map((d) =>
163
+ d.href !== null ? (
164
+ <a
165
+ href={siteHref(d.href)}
166
+ class="wd-mobile-menu-link"
167
+ target={isExternalHref(d.href) ? '_blank' : undefined}
168
+ rel={isExternalHref(d.href) ? 'noopener noreferrer' : undefined}
169
+ >
170
+ <AppIcon icon={d.icon} class="wd-tab-icon" />
171
+ <span class="wd-mobile-accordion-option-label">{d.label}</span>
172
+ </a>
173
+ ) : (
174
+ <details class="wd-mobile-accordion" name="wd-mobile-accordion">
175
+ <summary class="wd-mobile-accordion-trigger">
176
+ <AppIcon icon={d.icon} class="wd-tab-icon" />
177
+ <span class="wd-mobile-accordion-label">{d.label}</span>
178
+ <svg class="wd-mobile-accordion-caret" width="12" height="12" viewBox="0 0 10 10" aria-hidden="true">
179
+ <path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round" />
180
+ </svg>
181
+ </summary>
182
+ <div class="wd-mobile-accordion-options">
183
+ <div class="wd-mobile-accordion-options-panel">
184
+ {d.items.map((item) => (
185
+ <a href={siteHref(item.href)} class={item.active ? 'active' : ''}>
186
+ <span class="wd-mobile-accordion-option-label">{item.label}</span>
187
+ {item.active && (
188
+ <svg class="wd-mobile-accordion-check" width="14" height="14" viewBox="0 0 14 14" aria-hidden="true">
189
+ <path d="M3 7.5L6 10.5L11 4.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round" />
190
+ </svg>
191
+ )}
192
+ </a>
193
+ ))}
194
+ </div>
195
+ </div>
196
+ </details>
197
+ )
198
+ )}
199
+ </div>
200
+ )}
201
+ {showSidebarCol && (
202
+ <div class="wd-mobile-menu-sidebar">
203
+ <slot name="sidebar" />
204
+ </div>
205
+ )}
206
+ </div>
207
+ </div>
208
+ </div>
209
+ )}
210
+ <script>
211
+ import { initMobileMenu } from '../../scripts/mobile-menu';
212
+ import { initThemeToggle } from '../../scripts/theme-toggle';
213
+ // Not required by any markup this component currently renders (its own
214
+ // accordion rows are plain <details>, not .wd-dropdown), but imported
215
+ // and called anyway so both this file and TopBar.astro consistently own
216
+ // wiring up whatever interactive primitives their own markup might use
217
+ // - safe/idempotent regardless of how many components call it, see
218
+ // src/scripts/dropdowns.ts's own comment.
219
+ import { initDropdowns } from '../../scripts/dropdowns';
220
+
221
+ initMobileMenu(document);
222
+ initThemeToggle(document);
223
+ initDropdowns(document);
224
+ document.addEventListener('astro:page-load', () => {
225
+ initMobileMenu(document);
226
+ initThemeToggle(document);
227
+ initDropdowns(document);
228
+ });
229
+ </script>