@writedocs/generator 0.10.14 → 0.10.16

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 (48) hide show
  1. package/astro.config.mjs +610 -572
  2. package/package.json +1 -1
  3. package/src/cli/generate-api-pages.js +418 -384
  4. package/src/cli/write-redirects-file.js +141 -116
  5. package/src/components/Accordion.astro +2 -1
  6. package/src/components/Callout.astro +1 -1
  7. package/src/components/CopyPageMenu.astro +1 -1
  8. package/src/components/Image.astro +19 -3
  9. package/src/components/Parameter.astro +11 -6
  10. package/src/components/Visibility.astro +11 -1
  11. package/src/layout/BaseLayout.astro +896 -831
  12. package/src/layout/components/AnalyticsScripts.astro +45 -77
  13. package/src/layout/components/Breadcrumbs.astro +1 -1
  14. package/src/layout/components/ConsentBanner.astro +118 -0
  15. package/src/layout/components/MobileMenu.astro +3 -2
  16. package/src/layout/components/Sidebar.astro +2 -2
  17. package/src/layout/components/SiteFooter.astro +3 -2
  18. package/src/layout/components/TopBar.astro +3 -2
  19. package/src/layout/styles/base.css +30 -0
  20. package/src/lib/agent-directive.js +47 -0
  21. package/src/lib/agent-markdown.js +22 -2
  22. package/src/lib/components-to-markdown.js +297 -0
  23. package/src/lib/config-schema.js +97 -10
  24. package/src/lib/config-schema.ts +1882 -1768
  25. package/src/lib/consent.js +102 -0
  26. package/src/lib/font-fallback.js +79 -0
  27. package/src/lib/image-size.js +140 -0
  28. package/src/lib/item-pages.js +63 -0
  29. package/src/lib/json-ld.js +127 -0
  30. package/src/lib/json-schema-descriptions.js +226 -212
  31. package/src/lib/last-modified.js +52 -0
  32. package/src/lib/link-check.js +506 -500
  33. package/src/lib/mcp-index.ts +1 -1
  34. package/src/lib/meta-description.js +41 -0
  35. package/src/lib/mintlify-convert.js +605 -603
  36. package/src/lib/moved-api-pages.js +54 -0
  37. package/src/lib/openapi-markdown.ts +16 -6
  38. package/src/lib/project-files-integration.js +61 -0
  39. package/src/lib/project-files.js +126 -0
  40. package/src/lib/rehype-image-loading.js +71 -0
  41. package/src/lib/robots-txt.js +16 -0
  42. package/src/lib/seo-tags.js +137 -0
  43. package/src/lib/styles-asset-integration.js +21 -3
  44. package/src/pages/[...slug].astro +22 -3
  45. package/src/pages/[...slug].md.ts +15 -5
  46. package/src/pages/llms-full.txt.ts +1 -1
  47. package/src/scripts/consent.ts +62 -0
  48. package/writedocs.schema.json +100 -0
@@ -1,212 +1,226 @@
1
- // The editor help text for writedocs.schema.json (see lib/json-schema.js):
2
- // one entry per field of writedocs.json, keyed by its path - `a.b.c`, with
3
- // `[]` for an array's items. Fields inside the navigation's recursive types
4
- // are keyed by the type's name instead (`Tab.icon`, `NavigationItem.group`).
5
- //
6
- // scripts/json-schema.test.js fails when a field has no entry here, or an
7
- // entry names a field that doesn't exist - so a new field in
8
- // config-schema.ts needs its description added here too.
9
-
10
- const CHILDREN = {
11
- pages: 'The pages and groups in this section of the sidebar.',
12
- tabs: 'Tabs inside this one.',
13
- versions: 'Versions inside this one - a version picker in the sidebar.',
14
- languages: 'Languages inside this one - a language picker.',
15
- dropdowns: 'Dropdowns inside this one. Inside a tab they are its menu, and inside one of those a flyout beside its entry - two levels at most; elsewhere, a switcher.',
16
- products: 'Products inside this one - a product picker.',
17
- href: 'Makes this a link to another address instead of a section with pages of its own.',
18
- };
19
-
20
- const CONTAINERS = {
21
- Tab: {
22
- tab: 'The tab\'s name, shown in the topbar.',
23
- icon: 'Icon next to the name: a Lucide name ("book-open"), "collection:name" ("mdi:server"), an emoji, or an image path.',
24
- },
25
- Version: {
26
- version: 'The version\'s name, like "v2".',
27
- label: 'Text shown in the version picker instead of `version`.',
28
- tag: 'A short badge next to the version, like "Latest" or "Deprecated".',
29
- default: 'Open this version first. Without it, the first version is the default.',
30
- },
31
- Language: {
32
- language: 'The language code, like "en" or "pt-BR".',
33
- label: 'Text shown in the language picker instead of `language`, like "Português".',
34
- },
35
- Dropdown: {
36
- dropdown: 'The dropdown\'s name.',
37
- icon: 'Icon next to the name: a Lucide name, "collection:name", an emoji, or an image path.',
38
- },
39
- Product: {
40
- product: 'The product\'s name, shown in the product picker.',
41
- icon: 'Icon next to the name: a Lucide name, "collection:name", an emoji, or an image path.',
42
- description: 'One line under the name in the product picker.',
43
- },
44
- };
45
-
46
- const HIDDEN = {
47
- hidden: 'Reachable only by its address: no tab, switcher or menu lists it, and inside it this level isn\'t shown. Its pages search only among themselves.',
48
- searchPublic: 'For a hidden item: its search also finds the site\'s public pages.',
49
- page: 'A page of its own - an overview - that choosing this item opens, in place of its first page. Shown inside the item; in a sidebar too, it opens there.',
50
- };
51
-
52
- const containerEntries = Object.entries(CONTAINERS).flatMap(([type, fields]) => [
53
- ...Object.entries(fields).map(([field, text]) => [`${type}.${field}`, text]),
54
- ...Object.entries(CHILDREN).map(([field, text]) => [`${type}.${field}`, text]),
55
- ...Object.entries(HIDDEN).map(([field, text]) => [`${type}.${field}`, text]),
56
- ]);
57
-
58
- const logo = (where) => ({
59
- [where]: 'The logo: one image path for both color modes, or `{ light, dark, label }` with an image per mode.',
60
- [`${where}.light`]: 'Logo image shown in light mode.',
61
- [`${where}.dark`]: 'Logo image shown in dark mode.',
62
- [`${where}.label`]: 'Text shown next to the logo. No text is shown by default - a logo is usually already a wordmark.',
63
- });
64
-
65
- const font = (where, what) => ({
66
- [`${where}.family`]: `Font family for ${what}. A Google Fonts name loads automatically; add \`source\` for a font file instead.`,
67
- [`${where}.weight`]: `Font weight for ${what}, like 400 or 700.`,
68
- [`${where}.source`]: 'Path or URL of a font file to load, instead of Google Fonts.',
69
- [`${where}.format`]: 'Format of the `source` font file.',
70
- });
71
-
72
- const link = (where) => ({
73
- [`${where}.label`]: 'Link text. A link needs a label, an icon, or both.',
74
- [`${where}.href`]: 'Where the link goes - a site path like "/docs/intro/" or a full URL.',
75
- [`${where}.icon`]: 'Icon shown with the link: a Lucide name, "collection:name", an emoji, or an image path.',
76
- });
77
-
78
- const script = (where) => ({
79
- [`${where}.src`]: 'URL of the script to load. Use either `src` or `content`, not both.',
80
- [`${where}.content`]: 'The script\'s code, inline. Use either `src` or `content`, not both.',
81
- });
82
-
83
- export const ROOT_DESCRIPTION = 'Configuration of a writedocs site: its name, look, navigation and integrations.';
84
-
85
- export const TYPE_DESCRIPTIONS = {
86
- NavigationItem: 'A page (its path from the project folder, without the extension), a group of pages, or a link.',
87
- Tab: 'A tab in the topbar, with its own sidebar.',
88
- Version: 'A version of the docs, chosen from a version picker.',
89
- Language: 'A language of the docs, chosen from a language picker.',
90
- Dropdown: 'A section chosen from a dropdown menu.',
91
- Product: 'A product, chosen from a product picker.',
92
- };
93
-
94
- export const DESCRIPTIONS = {
95
- $schema: 'The JSON Schema this file follows - for editor autocompletion and checks.',
96
- name: 'Required. The site\'s name - shown in the browser tab ("Page title · name") and as the topbar text when there\'s no logo.',
97
- description: 'Description used for pages that don\'t set their own `description` in frontmatter.',
98
-
99
- styles: 'Colors, logo, favicon, fonts, code block themes, navbar and background.',
100
- 'styles.colors': 'The site\'s colors.',
101
- 'styles.colors.primary': 'Main color: links, buttons, the active page in the sidebar. Default "#6366f1".',
102
- 'styles.colors.text': 'Body text color in light mode, and the sidebar pages. Default "#404045".',
103
- 'styles.colors.dark': 'Dark-mode colors. Anything left out uses the light-mode value.',
104
- 'styles.colors.dark.primary': 'Main color in dark mode. Pick a lighter one if `primary` is dark - links use it on a dark background.',
105
- 'styles.colors.dark.text': 'Body text color in dark mode, and the sidebar pages. Default "#a0a0a5".',
106
- ...logo('styles.logo'),
107
- 'styles.favicon': 'Favicon image path.',
108
- 'styles.fonts': 'Fonts. Default: Inter. `heading` and `body` override just that part; anything they leave out comes from the top-level fields.',
109
- ...font('styles.fonts', 'all text'),
110
- 'styles.fonts.heading': 'Font for headings only.',
111
- ...font('styles.fonts.heading', 'headings'),
112
- 'styles.fonts.body': 'Font for body text only.',
113
- ...font('styles.fonts.body', 'body text'),
114
- 'styles.codeblocks': 'Syntax-highlighting themes for code blocks and the API playground.',
115
- 'styles.codeblocks.light': 'Shiki theme name for light mode (https://shiki.style/themes). Default "github-light".',
116
- 'styles.codeblocks.dark': 'Shiki theme name for dark mode. Default "github-dark".',
117
- 'styles.codeblocks.langAlias': 'Extra language names for code blocks, mapped to a language Shiki knows - like { "curl": "bash" }.',
118
- 'styles.navbar': 'The topbar\'s own background. Without it, the topbar matches the page background. Its text turns black or white automatically.',
119
- 'styles.navbar.light': 'Topbar in light mode: a background color, or `{ background, accent }`.',
120
- 'styles.navbar.light.background': 'Topbar background color in light mode.',
121
- 'styles.navbar.light.accent': 'Color of the underline under the active tab in the topbar, in place of `styles.colors.primary`.',
122
- 'styles.navbar.dark': 'Topbar in dark mode: a background color, or `{ background, accent }`.',
123
- 'styles.navbar.dark.background': 'Topbar background color in dark mode.',
124
- 'styles.navbar.dark.accent': 'Color of the underline under the active tab in the topbar, in dark mode.',
125
- 'styles.background': 'Background color of the site, and an optional background image.',
126
- 'styles.background.colors': 'Background colors.',
127
- 'styles.background.colors.light': 'Background color in light mode. Default "#ffffff".',
128
- 'styles.background.colors.dark': 'Background color in dark mode. Default "#0b1120".',
129
- 'styles.background.images': 'Background images, shown behind the content and sidebar.',
130
- 'styles.background.images.light': 'Background image in light mode.',
131
- 'styles.background.images.dark': 'Background image in dark mode.',
132
-
133
- navigation:
134
- 'Required. The site\'s structure: a list of pages and groups, or an object with exactly one of `tabs`, `versions`, `languages`, `dropdowns` or `products`. Those can nest inside each other.',
135
- 'navigation.global': 'Dropdowns shown on every page, whatever section is open.',
136
- 'navigation.global.dropdowns': 'Dropdowns shown on every page.',
137
- 'navigation.tabs': 'Tabs in the topbar, each with its own sidebar.',
138
- 'navigation.versions': 'Versions of the docs, with a version picker.',
139
- 'navigation.languages': 'Languages of the docs, with a language picker.',
140
- 'navigation.dropdowns': 'Sections chosen from a dropdown menu.',
141
- 'navigation.products': 'Products, with a product picker.',
142
-
143
- 'NavigationItem.group': 'The group\'s name in the sidebar.',
144
- 'NavigationItem.page': 'A page the group\'s name links to.',
145
- 'NavigationItem.pages': 'The pages and groups inside this group.',
146
- 'NavigationItem.openapi': 'Generate this group\'s pages from an OpenAPI spec - a page per operation, grouped by tag.',
147
- 'NavigationItem.openapi.src': 'Path of the OpenAPI spec file, relative to writedocs.json.',
148
- 'NavigationItem.openapi.path': 'URL path the generated pages go under, like "/api". Each OpenAPI group needs its own.',
149
- 'NavigationItem.label': 'Link text in the sidebar.',
150
- 'NavigationItem.href': 'Where the link goes.',
151
- ...Object.fromEntries(containerEntries),
152
-
153
- socials: 'Icon links in the footer: platform -> URL, like { "github": "https://github.com/acme" }. The key is also the icon.',
154
- topbar: 'The topbar.',
155
- 'topbar.links': 'Links at the right of the topbar.',
156
- ...link('topbar.links[]'),
157
- footer: 'The footer: columns of links, and the `socials` icons.',
158
- 'footer.columns': 'Columns of links.',
159
- 'footer.columns[].title': 'The column\'s heading. Optional.',
160
- 'footer.columns[].links': 'The links in the column.',
161
- ...link('footer.columns[].links[]'),
162
- ...logo('footer.logo'),
163
-
164
- api: 'The API playground.',
165
- 'api.proxy': 'When the browser blocks a "Try it" request (the API doesn\'t allow calls from other sites - CORS), retry it through writedocs\' proxy. Requests always go to the API directly first. Default true.',
166
- domain: 'The site\'s address, like "docs.example.com". Turns on sitemap.xml and absolute URLs in link previews.',
167
-
168
- seo: 'Default metadata for every page. A page\'s own `seo` frontmatter overrides it field by field.',
169
- 'seo.ogImage': 'Image shown in link previews - a path or a full URL.',
170
- 'seo.ogType': 'The og:type of pages. Default "website".',
171
- 'seo.twitterCard': 'X/Twitter card style. Default "summary_large_image" with an `ogImage`, "summary" without.',
172
- 'seo.keywords': 'Keywords for the <meta name="keywords"> tag.',
173
- 'seo.noindex': 'Ask search engines not to index pages, and leave them out of sitemap.xml.',
174
- contextMenu: 'The "Copy page" menu on every page - copy as Markdown, view as Markdown, open in ChatGPT, Claude or Perplexity, copy the MCP server URL, connect to Cursor or VS Code - and a Markdown copy of each page at its address + ".md". On by default with every option (the MCP ones only while `mcp` is on). A list picks the options ("copy", "view", "chatgpt", "claude", "perplexity", "mcp", "cursor", "vscode"); false turns it all off.',
175
- 'contextMenu.openIn': 'The earlier form: which AI assistants the menu offers, besides copy and view. A list of options replaces it.',
176
- mcp: 'An MCP server at /mcp, so AI tools can search and read the docs. The build adds its index and a Cloudflare-ready _worker.js to dist/. Default true; false leaves them out.',
177
- redirects: 'Redirects from old addresses. Each matches one exact path.',
178
- 'redirects[].source': 'The old path, like "/old-page".',
179
- 'redirects[].destination': 'Where to send it, like "/docs/new-page/".',
180
- variables: 'Values pages can insert with [[name]], like { "productName": "Acme" }.',
181
- banner: 'A banner above the topbar on every page.',
182
- 'banner.content': 'The banner\'s text. Markdown links work.',
183
- 'banner.dismissible': 'Let readers close it. Default false.',
184
- 'banner.type': 'Its color: "info", "warning" or "critical". Default "info".',
185
- notFound: 'The 404 page.',
186
- 'notFound.title': 'The 404 page\'s title.',
187
- 'notFound.description': 'Text under the title on the 404 page.',
188
- scripts: 'Scripts added to every page - for tools `integrations` doesn\'t cover.',
189
- 'scripts.head': 'Scripts added at the end of <head>.',
190
- ...script('scripts.head[]'),
191
- 'scripts.body': 'Scripts added at the end of <body>.',
192
- ...script('scripts.body[]'),
193
-
194
- integrations: 'Analytics and chat tools.',
195
- 'integrations.ga4': 'Google Analytics 4.',
196
- 'integrations.ga4.measurementId': 'Measurement ID, like "G-XXXXXXXXXX".',
197
- 'integrations.googleTagManager': 'Google Tag Manager.',
198
- 'integrations.googleTagManager.containerId': 'Container ID, like "GTM-XXXXXXX".',
199
- 'integrations.plausible': 'Plausible Analytics.',
200
- 'integrations.plausible.domain': 'The site\'s domain, as registered in Plausible.',
201
- 'integrations.plausible.src': 'Script URL, for a self-hosted Plausible. Default "https://plausible.io/js/script.js".',
202
- 'integrations.fathom': 'Fathom Analytics.',
203
- 'integrations.fathom.siteId': 'Fathom\'s site ID, like "ABCDEFGH".',
204
- 'integrations.posthog': 'PostHog.',
205
- 'integrations.posthog.apiKey': 'Project API key, starting with "phc_".',
206
- 'integrations.posthog.apiHost': 'API host. Default "https://us.i.posthog.com" - use yours for EU cloud or self-hosting.',
207
- 'integrations.umami': 'Umami Analytics.',
208
- 'integrations.umami.websiteId': 'Umami\'s website ID.',
209
- 'integrations.umami.src': 'Script URL. Default "https://cloud.umami.is/script.js" - use yours when self-hosting.',
210
- 'integrations.askAi': 'AI chat over the docs, with DocsBot.',
211
- 'integrations.askAi.id': 'DocsBot\'s "teamId/botId". The WRITEDOCS_ASK_AI_ID environment variable overrides it.',
212
- };
1
+ // The editor help text for writedocs.schema.json (see lib/json-schema.js):
2
+ // one entry per field of writedocs.json, keyed by its path - `a.b.c`, with
3
+ // `[]` for an array's items. Fields inside the navigation's recursive types
4
+ // are keyed by the type's name instead (`Tab.icon`, `NavigationItem.group`).
5
+ //
6
+ // scripts/json-schema.test.js fails when a field has no entry here, or an
7
+ // entry names a field that doesn't exist - so a new field in
8
+ // config-schema.ts needs its description added here too.
9
+
10
+ const CHILDREN = {
11
+ pages: 'The pages and groups in this section of the sidebar.',
12
+ tabs: 'Tabs inside this one.',
13
+ versions: 'Versions inside this one - a version picker in the sidebar.',
14
+ languages: 'Languages inside this one - a language picker.',
15
+ dropdowns: 'Dropdowns inside this one. Inside a tab they are its menu, and inside one of those a flyout beside its entry - two levels at most; elsewhere, a switcher.',
16
+ products: 'Products inside this one - a product picker.',
17
+ href: 'Makes this a link to another address instead of a section with pages of its own.',
18
+ };
19
+
20
+ const CONTAINERS = {
21
+ Tab: {
22
+ tab: 'The tab\'s name, shown in the topbar.',
23
+ icon: 'Icon next to the name: a Lucide name ("book-open"), "collection:name" ("mdi:server"), an emoji, or an image path.',
24
+ },
25
+ Version: {
26
+ version: 'The version\'s name, like "v2".',
27
+ label: 'Text shown in the version picker instead of `version`.',
28
+ tag: 'A short badge next to the version, like "Latest" or "Deprecated".',
29
+ default: 'Open this version first. Without it, the first version is the default.',
30
+ },
31
+ Language: {
32
+ language: 'The language code, like "en" or "pt-BR".',
33
+ label: 'Text shown in the language picker instead of `language`, like "Português".',
34
+ },
35
+ Dropdown: {
36
+ dropdown: 'The dropdown\'s name.',
37
+ icon: 'Icon next to the name: a Lucide name, "collection:name", an emoji, or an image path.',
38
+ },
39
+ Product: {
40
+ product: 'The product\'s name, shown in the product picker.',
41
+ icon: 'Icon next to the name: a Lucide name, "collection:name", an emoji, or an image path.',
42
+ description: 'One line under the name in the product picker.',
43
+ },
44
+ };
45
+
46
+ const HIDDEN = {
47
+ hidden: 'Reachable only by its address: no tab, switcher or menu lists it, and inside it this level isn\'t shown. Its pages search only among themselves.',
48
+ searchPublic: 'For a hidden item: its search also finds the site\'s public pages.',
49
+ page: 'A page of its own - an overview - that choosing this item opens, in place of its first page. Shown inside the item; in a sidebar too, it opens there.',
50
+ };
51
+
52
+ const containerEntries = Object.entries(CONTAINERS).flatMap(([type, fields]) => [
53
+ ...Object.entries(fields).map(([field, text]) => [`${type}.${field}`, text]),
54
+ ...Object.entries(CHILDREN).map(([field, text]) => [`${type}.${field}`, text]),
55
+ ...Object.entries(HIDDEN).map(([field, text]) => [`${type}.${field}`, text]),
56
+ ]);
57
+
58
+ const logo = (where) => ({
59
+ [where]: 'The logo: one image path for both color modes, or `{ light, dark, label }` with an image per mode.',
60
+ [`${where}.light`]: 'Logo image shown in light mode.',
61
+ [`${where}.dark`]: 'Logo image shown in dark mode.',
62
+ [`${where}.label`]: 'Text shown next to the logo. No text is shown by default - a logo is usually already a wordmark.',
63
+ });
64
+
65
+ const font = (where, what) => ({
66
+ [`${where}.family`]: `Font family for ${what}. A Google Fonts name loads automatically; add \`source\` for a font file instead.`,
67
+ [`${where}.weight`]: `Font weight for ${what}, like 400 or 700.`,
68
+ [`${where}.source`]: 'Path or URL of a font file to load, instead of Google Fonts.',
69
+ [`${where}.format`]: 'Format of the `source` font file.',
70
+ });
71
+
72
+ const link = (where) => ({
73
+ [`${where}.label`]: 'Link text. A link needs a label, an icon, or both.',
74
+ [`${where}.href`]: 'Where the link goes - a site path like "/docs/intro/" or a full URL.',
75
+ [`${where}.icon`]: 'Icon shown with the link: a Lucide name, "collection:name", an emoji, or an image path.',
76
+ });
77
+
78
+ const script = (where) => ({
79
+ [`${where}.src`]: 'URL of the script to load. Use either `src` or `content`, not both.',
80
+ [`${where}.content`]: 'The script\'s code, inline. Use either `src` or `content`, not both.',
81
+ [`${where}.consent`]: 'With `integrations.consent` on, load this script only once the reader accepts.',
82
+ });
83
+
84
+ export const ROOT_DESCRIPTION = 'Configuration of a writedocs site: its name, look, navigation and integrations.';
85
+
86
+ export const TYPE_DESCRIPTIONS = {
87
+ NavigationItem: 'A page (its path from the project folder, without the extension), a group of pages, or a link.',
88
+ Tab: 'A tab in the topbar, with its own sidebar.',
89
+ Version: 'A version of the docs, chosen from a version picker.',
90
+ Language: 'A language of the docs, chosen from a language picker.',
91
+ Dropdown: 'A section chosen from a dropdown menu.',
92
+ Product: 'A product, chosen from a product picker.',
93
+ };
94
+
95
+ export const DESCRIPTIONS = {
96
+ $schema: 'The JSON Schema this file follows - for editor autocompletion and checks.',
97
+ name: 'Required. The site\'s name - shown in the browser tab ("Page title · name") and as the topbar text when there\'s no logo.',
98
+ description: 'Description used for pages that don\'t set their own `description` in frontmatter.',
99
+
100
+ styles: 'Colors, logo, favicon, fonts, code block themes, navbar and background.',
101
+ 'styles.colors': 'The site\'s colors.',
102
+ 'styles.colors.primary': 'Main color: links, buttons, the active page in the sidebar. Default "#6366f1".',
103
+ 'styles.colors.text': 'Body text color in light mode, and the sidebar pages. Default "#404045".',
104
+ 'styles.colors.dark': 'Dark-mode colors. Anything left out uses the light-mode value.',
105
+ 'styles.colors.dark.primary': 'Main color in dark mode. Pick a lighter one if `primary` is dark - links use it on a dark background.',
106
+ 'styles.colors.dark.text': 'Body text color in dark mode, and the sidebar pages. Default "#a0a0a5".',
107
+ ...logo('styles.logo'),
108
+ 'styles.favicon': 'Favicon image path.',
109
+ 'styles.fonts': 'Fonts. Default: Inter. `heading` and `body` override just that part; anything they leave out comes from the top-level fields.',
110
+ ...font('styles.fonts', 'all text'),
111
+ 'styles.fonts.heading': 'Font for headings only.',
112
+ ...font('styles.fonts.heading', 'headings'),
113
+ 'styles.fonts.body': 'Font for body text only.',
114
+ ...font('styles.fonts.body', 'body text'),
115
+ 'styles.codeblocks': 'Syntax-highlighting themes for code blocks and the API playground.',
116
+ 'styles.codeblocks.light': 'Shiki theme name for light mode (https://shiki.style/themes). Default "github-light".',
117
+ 'styles.codeblocks.dark': 'Shiki theme name for dark mode. Default "github-dark".',
118
+ 'styles.codeblocks.langAlias': 'Extra language names for code blocks, mapped to a language Shiki knows - like { "curl": "bash" }.',
119
+ 'styles.navbar': 'The topbar\'s own background. Without it, the topbar matches the page background. Its text turns black or white automatically.',
120
+ 'styles.navbar.light': 'Topbar in light mode: a background color, or `{ background, accent }`.',
121
+ 'styles.navbar.light.background': 'Topbar background color in light mode.',
122
+ 'styles.navbar.light.accent': 'Color of the underline under the active tab in the topbar, in place of `styles.colors.primary`.',
123
+ 'styles.navbar.dark': 'Topbar in dark mode: a background color, or `{ background, accent }`.',
124
+ 'styles.navbar.dark.background': 'Topbar background color in dark mode.',
125
+ 'styles.navbar.dark.accent': 'Color of the underline under the active tab in the topbar, in dark mode.',
126
+ 'styles.background': 'Background color of the site, and an optional background image.',
127
+ 'styles.background.colors': 'Background colors.',
128
+ 'styles.background.colors.light': 'Background color in light mode. Default "#ffffff".',
129
+ 'styles.background.colors.dark': 'Background color in dark mode. Default "#0b1120".',
130
+ 'styles.background.images': 'Background images, shown behind the content and sidebar.',
131
+ 'styles.background.images.light': 'Background image in light mode.',
132
+ 'styles.background.images.dark': 'Background image in dark mode.',
133
+
134
+ navigation:
135
+ 'Required. The site\'s structure: a list of pages and groups, or an object with exactly one of `tabs`, `versions`, `languages`, `dropdowns` or `products`. Those can nest inside each other.',
136
+ 'navigation.global': 'Dropdowns shown on every page, whatever section is open.',
137
+ 'navigation.global.dropdowns': 'Dropdowns shown on every page.',
138
+ 'navigation.tabs': 'Tabs in the topbar, each with its own sidebar.',
139
+ 'navigation.versions': 'Versions of the docs, with a version picker.',
140
+ 'navigation.languages': 'Languages of the docs, with a language picker.',
141
+ 'navigation.dropdowns': 'Sections chosen from a dropdown menu.',
142
+ 'navigation.products': 'Products, with a product picker.',
143
+
144
+ 'NavigationItem.group': 'The group\'s name in the sidebar.',
145
+ 'NavigationItem.page': 'A page the group\'s name links to.',
146
+ 'NavigationItem.pages': 'The pages and groups inside this group.',
147
+ 'NavigationItem.openapi': 'Generate this group\'s pages from an OpenAPI spec - a page per operation, grouped by tag.',
148
+ 'NavigationItem.openapi.src': 'Path of the OpenAPI spec file, relative to writedocs.json.',
149
+ 'NavigationItem.openapi.path': 'URL path the generated pages go under, like "/api". Each OpenAPI group needs its own.',
150
+ 'NavigationItem.label': 'Link text in the sidebar.',
151
+ 'NavigationItem.href': 'Where the link goes.',
152
+ ...Object.fromEntries(containerEntries),
153
+
154
+ socials: 'Icon links in the footer: platform -> URL, like { "github": "https://github.com/acme" }. The key is also the icon.',
155
+ topbar: 'The topbar.',
156
+ 'topbar.links': 'Links at the right of the topbar.',
157
+ ...link('topbar.links[]'),
158
+ footer: 'The footer: columns of links, and the `socials` icons.',
159
+ 'footer.columns': 'Columns of links.',
160
+ 'footer.columns[].title': 'The column\'s heading. Optional.',
161
+ 'footer.columns[].links': 'The links in the column.',
162
+ ...link('footer.columns[].links[]'),
163
+ ...logo('footer.logo'),
164
+
165
+ api: 'The API playground.',
166
+ 'api.proxy': 'When the browser blocks a "Try it" request (the API doesn\'t allow calls from other sites - CORS), retry it through writedocs\' proxy. Requests always go to the API directly first. Default true.',
167
+ domain: 'The site\'s address, like "docs.example.com". Turns on sitemap.xml and absolute URLs in link previews.',
168
+
169
+ seo: 'Default metadata for every page. A page\'s own `seo` frontmatter overrides it field by field.',
170
+ 'seo.ogImage': 'Image shown in link previews - a path or a full URL.',
171
+ 'seo.ogType': 'The og:type of pages. Default "website".',
172
+ 'seo.twitterCard': 'X/Twitter card style. Default "summary_large_image" with an `ogImage`, "summary" without.',
173
+ 'seo.keywords': 'Keywords for the <meta name="keywords"> tag.',
174
+ 'seo.noindex': 'Ask search engines not to index pages, and leave them out of sitemap.xml.',
175
+ 'seo.robots': 'The whole <meta name="robots"> value, like "noindex, follow". Replaces `noindex`; a value with "noindex" leaves pages out of sitemap.xml too.',
176
+ 'seo.organization': 'Who publishes the site, for search engines: an Organization in the home page\'s structured data, and the publisher of every page.',
177
+ 'seo.organization.name': 'The organization\'s name, like "Acme".',
178
+ 'seo.organization.url': 'The organization\'s own site. Default: this site\'s address.',
179
+ 'seo.organization.logo': 'Its logo - a path or a full URL. Default: the site\'s logo.',
180
+ 'seo.organization.sameAs': 'Its profiles on other sites. Default: the URLs in `socials`.',
181
+ 'seo.metatags':'Other <meta> tags, name to content - like { "google-site-verification": "..." }. One with the name of a tag writedocs writes ("og:image", "twitter:image") replaces it.',
182
+ contextMenu: 'The "Copy page" menu on every page - copy as Markdown, view as Markdown, open in ChatGPT, Claude or Perplexity, copy the MCP server URL, connect to Cursor or VS Code - and a Markdown copy of each page at its address + ".md". On by default with every option (the MCP ones only while `mcp` is on). A list picks the options ("copy", "view", "chatgpt", "claude", "perplexity", "mcp", "cursor", "vscode"); false turns it all off.',
183
+ 'contextMenu.openIn': 'The earlier form: which AI assistants the menu offers, besides copy and view. A list of options replaces it.',
184
+ mcp: 'An MCP server at /mcp, so AI tools can search and read the docs. The build adds its index and a Cloudflare-ready _worker.js to dist/. Default true; false leaves them out.',
185
+ redirects: 'Redirects from old addresses. Each matches one exact path.',
186
+ 'redirects[].source': 'The old path, like "/old-page".',
187
+ 'redirects[].destination': 'Where to send it, like "/docs/new-page/".',
188
+ variables: 'Values pages can insert with [[name]], like { "productName": "Acme" }.',
189
+ banner: 'A banner above the topbar on every page.',
190
+ 'banner.content': 'The banner\'s text. Markdown links work.',
191
+ 'banner.dismissible': 'Let readers close it. Default false.',
192
+ 'banner.type': 'Its color: "info", "warning" or "critical". Default "info".',
193
+ notFound: 'The 404 page.',
194
+ 'notFound.title': 'The 404 page\'s title.',
195
+ 'notFound.description': 'Text under the title on the 404 page.',
196
+ scripts: 'Scripts added to every page - for tools `integrations` doesn\'t cover.',
197
+ 'scripts.head': 'Scripts added at the end of <head>.',
198
+ ...script('scripts.head[]'),
199
+ 'scripts.body': 'Scripts added at the end of <body>.',
200
+ ...script('scripts.body[]'),
201
+
202
+ integrations: 'Analytics and chat tools.',
203
+ 'integrations.ga4': 'Google Analytics 4.',
204
+ 'integrations.ga4.measurementId': 'Measurement ID, like "G-XXXXXXXXXX".',
205
+ 'integrations.googleTagManager': 'Google Tag Manager.',
206
+ 'integrations.googleTagManager.containerId': 'Container ID, like "GTM-XXXXXXX".',
207
+ 'integrations.plausible': 'Plausible Analytics.',
208
+ 'integrations.plausible.domain': 'The site\'s domain, as registered in Plausible.',
209
+ 'integrations.plausible.src': 'Script URL, for a self-hosted Plausible. Default "https://plausible.io/js/script.js".',
210
+ 'integrations.fathom': 'Fathom Analytics.',
211
+ 'integrations.fathom.siteId': 'Fathom\'s site ID, like "ABCDEFGH".',
212
+ 'integrations.posthog': 'PostHog.',
213
+ 'integrations.posthog.apiKey': 'Project API key, starting with "phc_".',
214
+ 'integrations.posthog.apiHost': 'API host. Default "https://us.i.posthog.com" - use yours for EU cloud or self-hosting.',
215
+ 'integrations.umami': 'Umami Analytics.',
216
+ 'integrations.umami.websiteId': 'Umami\'s website ID.',
217
+ 'integrations.umami.src': 'Script URL. Default "https://cloud.umami.is/script.js" - use yours when self-hosting.',
218
+ 'integrations.askAi': 'AI chat over the docs, with DocsBot.',
219
+ 'integrations.askAi.id': 'DocsBot\'s "teamId/botId". The WRITEDOCS_ASK_AI_ID environment variable overrides it.',
220
+ 'integrations.consent': 'A consent banner: the analytics integrations load only once the reader accepts. true uses the default texts; an object changes them.',
221
+ 'integrations.consent.message': 'The banner\'s text.',
222
+ 'integrations.consent.acceptLabel': 'The accept button\'s text. Default "Accept".',
223
+ 'integrations.consent.declineLabel': 'The decline button\'s text. Default "Decline".',
224
+ 'integrations.consent.policyUrl': 'A link after the text, to your privacy or cookie policy.',
225
+ 'integrations.consent.policyLabel': 'That link\'s text. Default "Privacy policy".',
226
+ };
@@ -0,0 +1,52 @@
1
+ // When each file of a project last changed, from git - for <lastmod> in
2
+ // sitemap.xml (astro.config.mjs). One `git log` for the whole project, not
3
+ // one per page.
4
+ //
5
+ // There's only an answer when git has the history to give one:
6
+ // - not a git repository, or no git: null;
7
+ // - a shallow clone (many CI systems fetch only the latest commit): null -
8
+ // every file would get that one commit's date, and a sitemap saying
9
+ // every page changed on every deploy is worse than one saying nothing.
10
+ // A file with uncommitted changes keeps its last commit's date; one never
11
+ // committed has none.
12
+ //
13
+ // Plain JavaScript, for scripts/last-modified.test.js.
14
+ import { execFileSync } from 'node:child_process';
15
+
16
+ function git(contentDir, args) {
17
+ return execFileSync('git', args, { cwd: contentDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 256 * 1024 * 1024, timeout: 60_000 });
18
+ }
19
+
20
+ /** `git log --format=%x00%cI --name-only` output as path -> ISO date. The
21
+ * log is newest first, so the first date seen for a path is its latest. */
22
+ export function parseGitLog(output) {
23
+ const dates = new Map();
24
+ for (const commit of output.split('\0')) {
25
+ const [date, ...files] = commit.split('\n').map((line) => line.trim()).filter(Boolean);
26
+ if (!date) continue;
27
+ for (const file of files) if (!dates.has(file)) dates.set(file, date);
28
+ }
29
+ return dates;
30
+ }
31
+
32
+ /** A Map of file path (POSIX, from `contentDir`) to the ISO date of the
33
+ * last commit that touched it - or null when git can't say (see above). */
34
+ export function gitLastModified(contentDir) {
35
+ try {
36
+ if (git(contentDir, ['rev-parse', '--is-inside-work-tree']).trim() !== 'true') return null;
37
+ if (git(contentDir, ['rev-parse', '--is-shallow-repository']).trim() === 'true') return null;
38
+ // --relative: paths from contentDir, and only files under it - a docs
39
+ // project is often a folder of a larger repository. quotepath off, so a
40
+ // file name with an accent comes back as it is.
41
+ return parseGitLog(git(contentDir, ['-c', 'core.quotepath=off', 'log', '--format=%x00%cI', '--name-only', '--relative', '--', '.']));
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ /** The newest of several dates (ISO strings), ignoring missing ones. */
48
+ export function newestDate(dates) {
49
+ let newest;
50
+ for (const date of dates) if (date && (!newest || Date.parse(date) > Date.parse(newest))) newest = date;
51
+ return newest;
52
+ }