@writedocs/generator 0.13.3 → 0.13.5

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 (87) hide show
  1. package/README.md +28 -28
  2. package/astro.config.mjs +645 -645
  3. package/bin/writedocs.js +43 -12
  4. package/package.json +99 -99
  5. package/src/cli/base-path-layout.js +44 -44
  6. package/src/cli/build-auth.js +135 -135
  7. package/src/cli/build.js +203 -203
  8. package/src/cli/check-built-styles.js +41 -41
  9. package/src/cli/convert.js +1 -1
  10. package/src/cli/dev.js +268 -268
  11. package/src/cli/exit-when-flushed.js +4 -0
  12. package/src/cli/generate-api-pages.js +507 -507
  13. package/src/cli/og-image-worker.js +20 -20
  14. package/src/cli/og-images.js +70 -70
  15. package/src/cli/page-list-watch.js +69 -69
  16. package/src/cli/run-astro.js +97 -97
  17. package/src/cli/run-pagefind.js +154 -154
  18. package/src/cli/write-mcp-files.js +103 -103
  19. package/src/cli/write-redirects-file.js +158 -158
  20. package/src/components/ApiReferencePanel.astro +1792 -1792
  21. package/src/components/AppIcon.astro +51 -51
  22. package/src/components/Card.astro +193 -193
  23. package/src/components/CodeGroup.astro +63 -39
  24. package/src/components/CopyPageMenu.astro +374 -374
  25. package/src/components/Hint.astro +188 -188
  26. package/src/components/Icon.astro +72 -72
  27. package/src/components/Image.astro +165 -165
  28. package/src/components/Tile.astro +67 -67
  29. package/src/components/Video.astro +137 -137
  30. package/src/content.config.ts +203 -203
  31. package/src/layout/BaseLayout.astro +908 -908
  32. package/src/layout/components/AnalyticsScripts.astro +49 -49
  33. package/src/layout/components/Breadcrumbs.astro +98 -98
  34. package/src/layout/components/ConsentBanner.astro +119 -119
  35. package/src/layout/components/MobileMenu.astro +225 -225
  36. package/src/layout/components/NavTree.astro +408 -408
  37. package/src/layout/components/Sidebar.astro +232 -232
  38. package/src/layout/components/SiteFooter.astro +87 -87
  39. package/src/layout/components/TopBar.astro +386 -386
  40. package/src/layout/styles/base.css +332 -326
  41. package/src/layout/styles/mobile-menu.css +285 -285
  42. package/src/lib/agent-markdown.js +164 -164
  43. package/src/lib/asset-dimensions.js +89 -89
  44. package/src/lib/base-path.js +90 -90
  45. package/src/lib/cli-report.js +22 -22
  46. package/src/lib/code-line-numbers.js +13 -0
  47. package/src/lib/config-schema.js +414 -75
  48. package/src/lib/config-schema.ts +2509 -1905
  49. package/src/lib/config.ts +1316 -1314
  50. package/src/lib/consent.js +108 -108
  51. package/src/lib/content-store-reload-integration.js +101 -101
  52. package/src/lib/icon-data-dev.js +53 -53
  53. package/src/lib/image-size.js +152 -152
  54. package/src/lib/json-schema-descriptions.js +228 -228
  55. package/src/lib/link-check.js +544 -544
  56. package/src/lib/llms-index.ts +90 -90
  57. package/src/lib/mcp-dev-integration.js +65 -65
  58. package/src/lib/mcp-index.ts +102 -102
  59. package/src/lib/mintlify-convert.js +605 -605
  60. package/src/lib/moved-api-pages.js +49 -49
  61. package/src/lib/og-cards.js +33 -33
  62. package/src/lib/og-image.js +235 -235
  63. package/src/lib/openapi-dev-status.js +80 -80
  64. package/src/lib/openapi-reload-integration.js +193 -193
  65. package/src/lib/pages.js +312 -312
  66. package/src/lib/project-files-integration.js +116 -116
  67. package/src/lib/project-files.js +137 -137
  68. package/src/lib/rehype-base-path.js +62 -62
  69. package/src/lib/rehype-image-loading.js +71 -71
  70. package/src/lib/robots-txt.js +21 -21
  71. package/src/lib/search-scope.js +44 -44
  72. package/src/lib/selector-placement.js +50 -50
  73. package/src/lib/seo-tags.js +155 -155
  74. package/src/lib/shiki-code-block.js +7 -1
  75. package/src/lib/site-base.ts +27 -27
  76. package/src/lib/styles-asset-integration.js +291 -291
  77. package/src/lib/wdignore-cases.json +195 -195
  78. package/src/lib/wdignore.js +177 -177
  79. package/src/pages/404.astro +63 -63
  80. package/src/pages/[...slug].astro +1762 -1608
  81. package/src/pages/[...slug].md.ts +93 -93
  82. package/src/pages/llms-full.txt.ts +88 -88
  83. package/src/pages/og/[...slug].png.ts +63 -63
  84. package/src/scripts/mobile-menu.ts +80 -80
  85. package/src/scripts/search.ts +245 -245
  86. package/src/scripts/sidebar-scroll.ts +61 -61
  87. package/src/styles/global.css +40 -40
@@ -1,232 +1,232 @@
1
- ---
2
- import { isExternalHref, type NavTreeNode, type Selector } from "../../lib/config";
3
- import NavTree from "./NavTree.astro";
4
- import { currentOption } from "../../lib/selector-placement.js";
5
- import AppIcon from "../../components/AppIcon.astro";
6
- // Two colorways of the same "Powered by writedocs" mark, not a
7
- // theme-matched pair in the wd-logo-light/wd-logo-dark sense (that
8
- // convention names each file by which theme it's *shown in*) - these
9
- // are named by the mark's own ink color instead, and the darker one
10
- // (wd_watermark_dark.png) is actually the better-contrast choice
11
- // against the light theme's near-white background, while the lighter,
12
- // unsuffixed one reads better against the dark theme's near-black one.
13
- // Imported (not referenced by string path) since this is a
14
- // framework-bundled asset living in src/assets, not something any
15
- // individual site's own public/ folder provides - astro.config.mjs
16
- // points publicDir at the site's public/ instead, so a plain <img
17
- // src="/..."> here would 404 on every real site build.
18
- import watermarkForLightTheme from "../../assets/wd_watermark_dark.png";
19
- import watermarkForDarkTheme from "../../assets/wd_watermark.png";
20
- import { siteHref } from '../../lib/site-base';
21
-
22
- // Deploy-time-only opt-out, not a writedocs.json field: a site's own writedocs.json
23
- // is part of its checked-in content (something the author controls), while
24
- // this is meant to be set by whatever's actually running the build (CI,
25
- // hosting platform env config, etc.) without touching that content - the
26
- // same reasoning as WRITEDOCS_CONTENT_DIR/WRITEDOCS_PACKAGE_ROOT already
27
- // being plain process.env reads rather than config fields (see
28
- // astro.config.mjs and this component's sibling files). Any value other
29
- // than the literal string "true" leaves the watermark showing, so an
30
- // unset/misspelled var fails toward the visible, "unmodified" default
31
- // rather than silently hiding it.
32
- const watermarkDisabled = process.env.WRITEDOCS_DISABLE_WATERMARK === "true";
33
-
34
- interface Props {
35
- navTree: NavTreeNode[];
36
- hrefForSlug: (slug: string) => string;
37
- currentSlug: string;
38
- // Switchers that sit at the top of the sidebar instead of the top bar -
39
- // products inside a tab or dropdown (lib/selector-placement.js).
40
- switchers?: Selector[];
41
- }
42
- const { navTree, hrefForSlug, currentSlug, switchers = [] } = Astro.props as Props;
43
- ---
44
-
45
- <nav class="wd-sidebar">
46
- {switchers.map((sel) => {
47
- const current = currentOption(sel);
48
- return (
49
- <div class="wd-dropdown wd-sidebar-switcher" data-selector-kind={sel.kind}>
50
- <button type="button" class="wd-dropdown-trigger wd-sidebar-switcher-trigger" aria-expanded="false">
51
- <AppIcon icon={current.icon} class="wd-tab-icon wd-sidebar-switcher-icon" />
52
- <span class="wd-sidebar-switcher-text">
53
- <span class="wd-sidebar-switcher-label">{current.label}</span>
54
- {current.description && <span class="wd-sidebar-switcher-desc">{current.description}</span>}
55
- </span>
56
- <svg class="wd-sidebar-switcher-chevrons" width="12" height="12" viewBox="0 0 12 12" aria-hidden="true">
57
- <path d="M3.5 4.5L6 2L8.5 4.5M3.5 7.5L6 10L8.5 7.5" stroke="currentColor" stroke-width="1.3" fill="none" stroke-linecap="round" stroke-linejoin="round" />
58
- </svg>
59
- </button>
60
- <div class="wd-dropdown-menu wd-sidebar-switcher-menu">
61
- <div class="wd-dropdown-menu-panel">
62
- {sel.options.map((opt) => (
63
- <a
64
- href={siteHref(opt.href)}
65
- class={opt.active ? "active" : ""}
66
- aria-current={opt.active ? "true" : undefined}
67
- target={isExternalHref(opt.href) ? "_blank" : undefined}
68
- rel={isExternalHref(opt.href) ? "noopener noreferrer" : undefined}
69
- >
70
- <AppIcon icon={opt.icon} class="wd-tab-icon wd-sidebar-switcher-icon" />
71
- <span class="wd-sidebar-switcher-text">
72
- <span class="wd-sidebar-switcher-label">{opt.label}</span>
73
- {opt.description && <span class="wd-sidebar-switcher-desc">{opt.description}</span>}
74
- </span>
75
- </a>
76
- ))}
77
- </div>
78
- </div>
79
- </div>
80
- );
81
- })}
82
- <NavTree nodes={navTree} hrefForSlug={hrefForSlug} currentSlug={currentSlug} />
83
- {!watermarkDisabled && (
84
- <div class="wd-sidebar-watermark">
85
- <img src={watermarkForLightTheme.src} alt="Powered by writedocs" class="wd-watermark-light" width={watermarkForLightTheme.width} height={watermarkForLightTheme.height} loading="lazy" decoding="async" />
86
- <img src={watermarkForDarkTheme.src} alt="Powered by writedocs" class="wd-watermark-dark" width={watermarkForDarkTheme.width} height={watermarkForDarkTheme.height} loading="lazy" decoding="async" />
87
- </div>
88
- )}
89
- </nav>
90
- <style>
91
- /* The product switcher at the top of the sidebar - Mintlify's place for
92
- it. Full width, the current product (and its description) on the
93
- button, every product in the menu. It opens on click only: the shared
94
- hover-to-open (dropdown.css) would pop it open every time the pointer
95
- crosses the sidebar. */
96
- .wd-sidebar-switcher {
97
- margin-bottom: 1rem;
98
- }
99
- .wd-sidebar-switcher-trigger {
100
- width: 100%;
101
- box-sizing: border-box;
102
- gap: 0.6rem;
103
- padding: 0.5rem 0.65rem;
104
- border: 1px solid var(--wd-border);
105
- border-radius: 0.5rem;
106
- color: var(--wd-text);
107
- text-align: left;
108
- }
109
- .wd-sidebar-switcher-trigger:hover {
110
- background: var(--wd-surface);
111
- }
112
- .wd-sidebar-switcher-text {
113
- display: flex;
114
- flex-direction: column;
115
- flex: 1;
116
- min-width: 0;
117
- }
118
- .wd-sidebar-switcher-label {
119
- font-size: 0.88rem;
120
- font-weight: 600;
121
- overflow: hidden;
122
- text-overflow: ellipsis;
123
- white-space: nowrap;
124
- }
125
- .wd-sidebar-switcher-desc {
126
- font-size: 0.75rem;
127
- font-weight: 400;
128
- color: var(--wd-text-muted);
129
- }
130
- .wd-sidebar-switcher-trigger .wd-sidebar-switcher-desc {
131
- overflow: hidden;
132
- text-overflow: ellipsis;
133
- white-space: nowrap;
134
- }
135
- .wd-sidebar-switcher-chevrons {
136
- flex-shrink: 0;
137
- color: var(--wd-text-muted);
138
- }
139
- .wd-sidebar-switcher:not(.open) .wd-sidebar-switcher-menu {
140
- display: none;
141
- }
142
- .wd-sidebar-switcher-menu {
143
- right: 0;
144
- }
145
- .wd-sidebar-switcher-menu .wd-dropdown-menu-panel {
146
- min-width: 0;
147
- }
148
- .wd-sidebar-switcher-menu a {
149
- align-items: flex-start;
150
- }
151
- .wd-sidebar-switcher-menu .wd-sidebar-switcher-icon {
152
- margin-top: 0.2rem;
153
- }
154
- /* The mobile menu already lists every level as its own row above the
155
- sidebar (once moved in there) - no second switcher there. */
156
- :global(#wd-mobile-menu) .wd-sidebar-switcher {
157
- display: none;
158
- }
159
- /* Sticky + its own scrollbar, not just "moves along until it runs out
160
- of column to stick within" (position: sticky's default behavior,
161
- which is what this had before - a tall nav tree would eventually
162
- unstick and get carried away by the page's own scroll once
163
- .wd-sidebar-col's bottom edge passed the viewport). max-height caps
164
- it to the visible area below the topbar and overflow-y gives it an
165
- independent scrollbar, so the page scrolls its content while the
166
- sidebar scrolls itself - same treatment TableOfContents.astro's
167
- .wd-toc already has (deliberately matching its `top`/`max-height`
168
- values exactly, so both columns start scrolling at the same height
169
- when a page has both). Reset back to normal (non-sticky, no cap) on
170
- narrow screens in BaseLayout.astro's `@media (max-width: 860px)`
171
- block, where the sidebar stacks full-width above the content instead
172
- of sitting beside it. */
173
- .wd-sidebar {
174
- padding: 1.5rem 1rem 1.5rem 0;
175
- position: sticky;
176
- /* --wd-topbar-offset (src/scripts/topbar-offset.ts) is the topbar's
177
- real measured height - a fixed 5rem (this var()'s own fallback)
178
- only matched the topbar's simplest, single-row case; matched
179
- exactly by TableOfContents.astro's own .wd-toc, see this file's
180
- own comment above on why that pairing matters. */
181
- top: var(--wd-topbar-offset, 5rem);
182
- max-height: calc(100vh - var(--wd-topbar-offset, 5rem));
183
- overflow-y: auto;
184
- }
185
- /* Desktop only (see the :global(.wd-sidebar-col) guard) - turns the
186
- sidebar into a fixed-height flex column so .wd-sidebar-watermark's
187
- margin-top: auto below can push it all the way to the bottom of the
188
- visible area when the nav tree doesn't fill it, instead of sitting
189
- right after the last nav item with a gap of empty space beneath it.
190
- height (not just the max-height above) is what makes this work -
191
- max-height alone only caps how tall the box *can* get, it doesn't
192
- force it to actually be that tall when content is shorter, which is
193
- exactly the "empty space below the watermark" case this replaces.
194
- Scoped to .wd-sidebar-col specifically (not the plain .wd-sidebar
195
- this component always renders) so the sidebar is untouched once the
196
- menu's script moves it into MobileMenu.astro's scrollable panel - forcing a
197
- tall fixed height there would leave an awkward blank stretch inside
198
- the mobile drawer under a short nav list, where "pinned to the
199
- bottom of the screen" isn't really representative of a panel the
200
- reader can already see the bottom of by scrolling. */
201
- :global(.wd-sidebar-col) .wd-sidebar {
202
- height: calc(100vh - var(--wd-topbar-offset, 5rem));
203
- display: flex;
204
- flex-direction: column;
205
- }
206
- /* Last thing in the nav column. margin-top: auto only has real estate
207
- to push into on desktop (where the rule above gives .wd-sidebar a
208
- real fixed height) - inside the mobile menu's panel, .wd-
209
- sidebar is never a flex container, so this margin resolves to 0 and
210
- the watermark just falls in after the last nav item instead, same
211
- as before that rule existed. Either way, padding-top + border-top
212
- stay unconditional, so there's always at least that much separation
213
- from the nav items above it. */
214
- .wd-sidebar-watermark {
215
- margin-top: auto;
216
- padding-top: 1rem;
217
- border-top: 1px solid var(--wd-border);
218
- }
219
- /* No `display` here - that's the base.css wd-watermark-light/-dark
220
- toggle's job alone (default display:none on the inactive one,
221
- display:block on the active one). This rule's own selector
222
- specificity (a class + an attribute-scoping selector + a type
223
- selector) is higher than that toggle's plain single/double-class
224
- rules, so a `display: block` here would win the cascade
225
- unconditionally on BOTH images regardless of [data-theme] -
226
- exactly the "both always visible" bug this replaces. */
227
- .wd-sidebar-watermark img {
228
- height: 14px;
229
- width: auto;
230
- opacity: 0.7;
231
- }
232
- </style>
1
+ ---
2
+ import { isExternalHref, type NavTreeNode, type Selector } from "../../lib/config";
3
+ import NavTree from "./NavTree.astro";
4
+ import { currentOption } from "../../lib/selector-placement.js";
5
+ import AppIcon from "../../components/AppIcon.astro";
6
+ // Two colorways of the same "Powered by writedocs" mark, not a
7
+ // theme-matched pair in the wd-logo-light/wd-logo-dark sense (that
8
+ // convention names each file by which theme it's *shown in*) - these
9
+ // are named by the mark's own ink color instead, and the darker one
10
+ // (wd_watermark_dark.png) is actually the better-contrast choice
11
+ // against the light theme's near-white background, while the lighter,
12
+ // unsuffixed one reads better against the dark theme's near-black one.
13
+ // Imported (not referenced by string path) since this is a
14
+ // framework-bundled asset living in src/assets, not something any
15
+ // individual site's own public/ folder provides - astro.config.mjs
16
+ // points publicDir at the site's public/ instead, so a plain <img
17
+ // src="/..."> here would 404 on every real site build.
18
+ import watermarkForLightTheme from "../../assets/wd_watermark_dark.png";
19
+ import watermarkForDarkTheme from "../../assets/wd_watermark.png";
20
+ import { siteHref } from '../../lib/site-base';
21
+
22
+ // Deploy-time-only opt-out, not a writedocs.json field: a site's own writedocs.json
23
+ // is part of its checked-in content (something the author controls), while
24
+ // this is meant to be set by whatever's actually running the build (CI,
25
+ // hosting platform env config, etc.) without touching that content - the
26
+ // same reasoning as WRITEDOCS_CONTENT_DIR/WRITEDOCS_PACKAGE_ROOT already
27
+ // being plain process.env reads rather than config fields (see
28
+ // astro.config.mjs and this component's sibling files). Any value other
29
+ // than the literal string "true" leaves the watermark showing, so an
30
+ // unset/misspelled var fails toward the visible, "unmodified" default
31
+ // rather than silently hiding it.
32
+ const watermarkDisabled = process.env.WRITEDOCS_DISABLE_WATERMARK === "true";
33
+
34
+ interface Props {
35
+ navTree: NavTreeNode[];
36
+ hrefForSlug: (slug: string) => string;
37
+ currentSlug: string;
38
+ // Switchers that sit at the top of the sidebar instead of the top bar -
39
+ // products inside a tab or dropdown (lib/selector-placement.js).
40
+ switchers?: Selector[];
41
+ }
42
+ const { navTree, hrefForSlug, currentSlug, switchers = [] } = Astro.props as Props;
43
+ ---
44
+
45
+ <nav class="wd-sidebar">
46
+ {switchers.map((sel) => {
47
+ const current = currentOption(sel);
48
+ return (
49
+ <div class="wd-dropdown wd-sidebar-switcher" data-selector-kind={sel.kind}>
50
+ <button type="button" class="wd-dropdown-trigger wd-sidebar-switcher-trigger" aria-expanded="false">
51
+ <AppIcon icon={current.icon} class="wd-tab-icon wd-sidebar-switcher-icon" />
52
+ <span class="wd-sidebar-switcher-text">
53
+ <span class="wd-sidebar-switcher-label">{current.label}</span>
54
+ {current.description && <span class="wd-sidebar-switcher-desc">{current.description}</span>}
55
+ </span>
56
+ <svg class="wd-sidebar-switcher-chevrons" width="12" height="12" viewBox="0 0 12 12" aria-hidden="true">
57
+ <path d="M3.5 4.5L6 2L8.5 4.5M3.5 7.5L6 10L8.5 7.5" stroke="currentColor" stroke-width="1.3" fill="none" stroke-linecap="round" stroke-linejoin="round" />
58
+ </svg>
59
+ </button>
60
+ <div class="wd-dropdown-menu wd-sidebar-switcher-menu">
61
+ <div class="wd-dropdown-menu-panel">
62
+ {sel.options.map((opt) => (
63
+ <a
64
+ href={siteHref(opt.href)}
65
+ class={opt.active ? "active" : ""}
66
+ aria-current={opt.active ? "true" : undefined}
67
+ target={isExternalHref(opt.href) ? "_blank" : undefined}
68
+ rel={isExternalHref(opt.href) ? "noopener noreferrer" : undefined}
69
+ >
70
+ <AppIcon icon={opt.icon} class="wd-tab-icon wd-sidebar-switcher-icon" />
71
+ <span class="wd-sidebar-switcher-text">
72
+ <span class="wd-sidebar-switcher-label">{opt.label}</span>
73
+ {opt.description && <span class="wd-sidebar-switcher-desc">{opt.description}</span>}
74
+ </span>
75
+ </a>
76
+ ))}
77
+ </div>
78
+ </div>
79
+ </div>
80
+ );
81
+ })}
82
+ <NavTree nodes={navTree} hrefForSlug={hrefForSlug} currentSlug={currentSlug} />
83
+ {!watermarkDisabled && (
84
+ <div class="wd-sidebar-watermark">
85
+ <img src={watermarkForLightTheme.src} alt="Powered by writedocs" class="wd-watermark-light" width={watermarkForLightTheme.width} height={watermarkForLightTheme.height} loading="lazy" decoding="async" />
86
+ <img src={watermarkForDarkTheme.src} alt="Powered by writedocs" class="wd-watermark-dark" width={watermarkForDarkTheme.width} height={watermarkForDarkTheme.height} loading="lazy" decoding="async" />
87
+ </div>
88
+ )}
89
+ </nav>
90
+ <style>
91
+ /* The product switcher at the top of the sidebar - Mintlify's place for
92
+ it. Full width, the current product (and its description) on the
93
+ button, every product in the menu. It opens on click only: the shared
94
+ hover-to-open (dropdown.css) would pop it open every time the pointer
95
+ crosses the sidebar. */
96
+ .wd-sidebar-switcher {
97
+ margin-bottom: 1rem;
98
+ }
99
+ .wd-sidebar-switcher-trigger {
100
+ width: 100%;
101
+ box-sizing: border-box;
102
+ gap: 0.6rem;
103
+ padding: 0.5rem 0.65rem;
104
+ border: 1px solid var(--wd-border);
105
+ border-radius: 0.5rem;
106
+ color: var(--wd-text);
107
+ text-align: left;
108
+ }
109
+ .wd-sidebar-switcher-trigger:hover {
110
+ background: var(--wd-surface);
111
+ }
112
+ .wd-sidebar-switcher-text {
113
+ display: flex;
114
+ flex-direction: column;
115
+ flex: 1;
116
+ min-width: 0;
117
+ }
118
+ .wd-sidebar-switcher-label {
119
+ font-size: 0.88rem;
120
+ font-weight: 600;
121
+ overflow: hidden;
122
+ text-overflow: ellipsis;
123
+ white-space: nowrap;
124
+ }
125
+ .wd-sidebar-switcher-desc {
126
+ font-size: 0.75rem;
127
+ font-weight: 400;
128
+ color: var(--wd-text-muted);
129
+ }
130
+ .wd-sidebar-switcher-trigger .wd-sidebar-switcher-desc {
131
+ overflow: hidden;
132
+ text-overflow: ellipsis;
133
+ white-space: nowrap;
134
+ }
135
+ .wd-sidebar-switcher-chevrons {
136
+ flex-shrink: 0;
137
+ color: var(--wd-text-muted);
138
+ }
139
+ .wd-sidebar-switcher:not(.open) .wd-sidebar-switcher-menu {
140
+ display: none;
141
+ }
142
+ .wd-sidebar-switcher-menu {
143
+ right: 0;
144
+ }
145
+ .wd-sidebar-switcher-menu .wd-dropdown-menu-panel {
146
+ min-width: 0;
147
+ }
148
+ .wd-sidebar-switcher-menu a {
149
+ align-items: flex-start;
150
+ }
151
+ .wd-sidebar-switcher-menu .wd-sidebar-switcher-icon {
152
+ margin-top: 0.2rem;
153
+ }
154
+ /* The mobile menu already lists every level as its own row above the
155
+ sidebar (once moved in there) - no second switcher there. */
156
+ :global(#wd-mobile-menu) .wd-sidebar-switcher {
157
+ display: none;
158
+ }
159
+ /* Sticky + its own scrollbar, not just "moves along until it runs out
160
+ of column to stick within" (position: sticky's default behavior,
161
+ which is what this had before - a tall nav tree would eventually
162
+ unstick and get carried away by the page's own scroll once
163
+ .wd-sidebar-col's bottom edge passed the viewport). max-height caps
164
+ it to the visible area below the topbar and overflow-y gives it an
165
+ independent scrollbar, so the page scrolls its content while the
166
+ sidebar scrolls itself - same treatment TableOfContents.astro's
167
+ .wd-toc already has (deliberately matching its `top`/`max-height`
168
+ values exactly, so both columns start scrolling at the same height
169
+ when a page has both). Reset back to normal (non-sticky, no cap) on
170
+ narrow screens in BaseLayout.astro's `@media (max-width: 860px)`
171
+ block, where the sidebar stacks full-width above the content instead
172
+ of sitting beside it. */
173
+ .wd-sidebar {
174
+ padding: 1.5rem 1rem 1.5rem 0;
175
+ position: sticky;
176
+ /* --wd-topbar-offset (src/scripts/topbar-offset.ts) is the topbar's
177
+ real measured height - a fixed 5rem (this var()'s own fallback)
178
+ only matched the topbar's simplest, single-row case; matched
179
+ exactly by TableOfContents.astro's own .wd-toc, see this file's
180
+ own comment above on why that pairing matters. */
181
+ top: var(--wd-topbar-offset, 5rem);
182
+ max-height: calc(100vh - var(--wd-topbar-offset, 5rem));
183
+ overflow-y: auto;
184
+ }
185
+ /* Desktop only (see the :global(.wd-sidebar-col) guard) - turns the
186
+ sidebar into a fixed-height flex column so .wd-sidebar-watermark's
187
+ margin-top: auto below can push it all the way to the bottom of the
188
+ visible area when the nav tree doesn't fill it, instead of sitting
189
+ right after the last nav item with a gap of empty space beneath it.
190
+ height (not just the max-height above) is what makes this work -
191
+ max-height alone only caps how tall the box *can* get, it doesn't
192
+ force it to actually be that tall when content is shorter, which is
193
+ exactly the "empty space below the watermark" case this replaces.
194
+ Scoped to .wd-sidebar-col specifically (not the plain .wd-sidebar
195
+ this component always renders) so the sidebar is untouched once the
196
+ menu's script moves it into MobileMenu.astro's scrollable panel - forcing a
197
+ tall fixed height there would leave an awkward blank stretch inside
198
+ the mobile drawer under a short nav list, where "pinned to the
199
+ bottom of the screen" isn't really representative of a panel the
200
+ reader can already see the bottom of by scrolling. */
201
+ :global(.wd-sidebar-col) .wd-sidebar {
202
+ height: calc(100vh - var(--wd-topbar-offset, 5rem));
203
+ display: flex;
204
+ flex-direction: column;
205
+ }
206
+ /* Last thing in the nav column. margin-top: auto only has real estate
207
+ to push into on desktop (where the rule above gives .wd-sidebar a
208
+ real fixed height) - inside the mobile menu's panel, .wd-
209
+ sidebar is never a flex container, so this margin resolves to 0 and
210
+ the watermark just falls in after the last nav item instead, same
211
+ as before that rule existed. Either way, padding-top + border-top
212
+ stay unconditional, so there's always at least that much separation
213
+ from the nav items above it. */
214
+ .wd-sidebar-watermark {
215
+ margin-top: auto;
216
+ padding-top: 1rem;
217
+ border-top: 1px solid var(--wd-border);
218
+ }
219
+ /* No `display` here - that's the base.css wd-watermark-light/-dark
220
+ toggle's job alone (default display:none on the inactive one,
221
+ display:block on the active one). This rule's own selector
222
+ specificity (a class + an attribute-scoping selector + a type
223
+ selector) is higher than that toggle's plain single/double-class
224
+ rules, so a `display: block` here would win the cascade
225
+ unconditionally on BOTH images regardless of [data-theme] -
226
+ exactly the "both always visible" bug this replaces. */
227
+ .wd-sidebar-watermark img {
228
+ height: 14px;
229
+ width: auto;
230
+ opacity: 0.7;
231
+ }
232
+ </style>
@@ -1,87 +1,87 @@
1
- ---
2
- // writedocs.json's `footer.columns`/`socials` - see footerSchema/`socials` in
3
- // lib/config.ts. Renders nothing at all (not even an empty bordered band)
4
- // when a site hasn't configured either - both fields default to empty, so
5
- // `hasFooterContent` is never undefined either way. Callers don't need to
6
- // check this themselves; this component decides on its own whether it has
7
- // anything to show.
8
- //
9
- // Split out of BaseLayout.astro, which had grown to ~2200 lines covering
10
- // several unrelated concerns in one file - see that component's own
11
- // comment for the fuller rationale.
12
- import { isExternalHref, type DocsConfig } from '../../lib/config';
13
- import AppIcon from '../../components/AppIcon.astro';
14
- import { logoWidth } from '../../lib/image-size.js';
15
- import '../styles/footer.css';
16
- import { siteHref } from '../../lib/site-base';
17
-
18
- interface Props {
19
- config: DocsConfig;
20
- logoLight?: string;
21
- logoDark?: string;
22
- }
23
- const { config, logoLight, logoDark } = Astro.props as Props;
24
- const hasLogoImage = Boolean(logoLight || logoDark);
25
- const socialEntries = Object.entries(config.socials);
26
- // A `socials` key doubles as its own icon reference (resolveIcon() in
27
- // lib/config.ts, via <AppIcon>) - fine as-is for a bare name like
28
- // "github", but a key using the explicit "collection:icon-name" form
29
- // (e.g. "simple-icons:discord", for a platform Lucide doesn't have a
30
- // matching icon for) would otherwise end up as this link's own aria-label
31
- // verbatim, colon and all - not what a screen reader user wants read
32
- // aloud. Strips down to just the part after the last colon for the label
33
- // specifically; the full key still goes to AppIcon unchanged.
34
- const socialLabel = (platform: string) => platform.split(':').pop() ?? platform;
35
- const hasFooterContent = config.footer.columns.length > 0 || socialEntries.length > 0;
36
- ---
37
- {hasFooterContent && (
38
- <footer class="wd-footer">
39
- <div class="wd-footer-inner">
40
- {hasLogoImage && (
41
- <a class="wd-footer-brand" href={siteHref("/")}>
42
- {logoLight && <img src={siteHref(logoLight)} alt={config.name} height="24" width={logoWidth(logoLight)} class="wd-logo-light" />}
43
- {logoDark && <img src={siteHref(logoDark)} alt={config.name} height="24" width={logoWidth(logoDark)} class="wd-logo-dark" />}
44
- </a>
45
- )}
46
- {config.footer.columns.length > 0 && (
47
- <div class="wd-footer-columns">
48
- {config.footer.columns.map((column) => (
49
- <div class="wd-footer-column">
50
- {column.title && <div class="wd-footer-column-title">{column.title}</div>}
51
- <ul class="wd-footer-column-links">
52
- {column.links.map((link) => (
53
- <li>
54
- <a
55
- href={siteHref(link.href)}
56
- target={isExternalHref(link.href) ? '_blank' : undefined}
57
- rel={isExternalHref(link.href) ? 'noopener noreferrer' : undefined}
58
- aria-label={!link.label ? link.icon : undefined}
59
- >
60
- <AppIcon icon={link.icon} class="wd-tab-icon" />
61
- {link.label}
62
- </a>
63
- </li>
64
- ))}
65
- </ul>
66
- </div>
67
- ))}
68
- </div>
69
- )}
70
- {socialEntries.length > 0 && (
71
- <div class="wd-footer-socials">
72
- {socialEntries.map(([platform, url]) => (
73
- <a
74
- href={siteHref(url)}
75
- class="wd-footer-social-link"
76
- aria-label={socialLabel(platform)}
77
- target={isExternalHref(url) ? '_blank' : undefined}
78
- rel={isExternalHref(url) ? 'noopener noreferrer' : undefined}
79
- >
80
- <AppIcon icon={platform} class="wd-footer-social-icon" />
81
- </a>
82
- ))}
83
- </div>
84
- )}
85
- </div>
86
- </footer>
87
- )}
1
+ ---
2
+ // writedocs.json's `footer.columns`/`socials` - see footerSchema/`socials` in
3
+ // lib/config.ts. Renders nothing at all (not even an empty bordered band)
4
+ // when a site hasn't configured either - both fields default to empty, so
5
+ // `hasFooterContent` is never undefined either way. Callers don't need to
6
+ // check this themselves; this component decides on its own whether it has
7
+ // anything to show.
8
+ //
9
+ // Split out of BaseLayout.astro, which had grown to ~2200 lines covering
10
+ // several unrelated concerns in one file - see that component's own
11
+ // comment for the fuller rationale.
12
+ import { isExternalHref, type DocsConfig } from '../../lib/config';
13
+ import AppIcon from '../../components/AppIcon.astro';
14
+ import { logoWidth } from '../../lib/image-size.js';
15
+ import '../styles/footer.css';
16
+ import { siteHref } from '../../lib/site-base';
17
+
18
+ interface Props {
19
+ config: DocsConfig;
20
+ logoLight?: string;
21
+ logoDark?: string;
22
+ }
23
+ const { config, logoLight, logoDark } = Astro.props as Props;
24
+ const hasLogoImage = Boolean(logoLight || logoDark);
25
+ const socialEntries = Object.entries(config.socials);
26
+ // A `socials` key doubles as its own icon reference (resolveIcon() in
27
+ // lib/config.ts, via <AppIcon>) - fine as-is for a bare name like
28
+ // "github", but a key using the explicit "collection:icon-name" form
29
+ // (e.g. "simple-icons:discord", for a platform Lucide doesn't have a
30
+ // matching icon for) would otherwise end up as this link's own aria-label
31
+ // verbatim, colon and all - not what a screen reader user wants read
32
+ // aloud. Strips down to just the part after the last colon for the label
33
+ // specifically; the full key still goes to AppIcon unchanged.
34
+ const socialLabel = (platform: string) => platform.split(':').pop() ?? platform;
35
+ const hasFooterContent = config.footer.columns.length > 0 || socialEntries.length > 0;
36
+ ---
37
+ {hasFooterContent && (
38
+ <footer class="wd-footer">
39
+ <div class="wd-footer-inner">
40
+ {hasLogoImage && (
41
+ <a class="wd-footer-brand" href={siteHref("/")}>
42
+ {logoLight && <img src={siteHref(logoLight)} alt={config.name} height="24" width={logoWidth(logoLight)} class="wd-logo-light" />}
43
+ {logoDark && <img src={siteHref(logoDark)} alt={config.name} height="24" width={logoWidth(logoDark)} class="wd-logo-dark" />}
44
+ </a>
45
+ )}
46
+ {config.footer.columns.length > 0 && (
47
+ <div class="wd-footer-columns">
48
+ {config.footer.columns.map((column) => (
49
+ <div class="wd-footer-column">
50
+ {column.title && <div class="wd-footer-column-title">{column.title}</div>}
51
+ <ul class="wd-footer-column-links">
52
+ {column.links.map((link) => (
53
+ <li>
54
+ <a
55
+ href={siteHref(link.href)}
56
+ target={isExternalHref(link.href) ? '_blank' : undefined}
57
+ rel={isExternalHref(link.href) ? 'noopener noreferrer' : undefined}
58
+ aria-label={!link.label ? link.icon : undefined}
59
+ >
60
+ <AppIcon icon={link.icon} class="wd-tab-icon" />
61
+ {link.label}
62
+ </a>
63
+ </li>
64
+ ))}
65
+ </ul>
66
+ </div>
67
+ ))}
68
+ </div>
69
+ )}
70
+ {socialEntries.length > 0 && (
71
+ <div class="wd-footer-socials">
72
+ {socialEntries.map(([platform, url]) => (
73
+ <a
74
+ href={siteHref(url)}
75
+ class="wd-footer-social-link"
76
+ aria-label={socialLabel(platform)}
77
+ target={isExternalHref(url) ? '_blank' : undefined}
78
+ rel={isExternalHref(url) ? 'noopener noreferrer' : undefined}
79
+ >
80
+ <AppIcon icon={platform} class="wd-footer-social-icon" />
81
+ </a>
82
+ ))}
83
+ </div>
84
+ )}
85
+ </div>
86
+ </footer>
87
+ )}