@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,49 +1,49 @@
1
- ---
2
- // writedocs.json's `integrations` - the six analytics providers. The tags
3
- // themselves are built by analyticsTags() in lib/consent.js (each one the
4
- // provider's own install snippet - see docs/dev/docs/integrations.mdx for
5
- // links and dates); this component decides how they reach the page:
6
- //
7
- // - no `integrations.consent`: one <script> tag each, loaded with the page.
8
- // - with it: no tag at all, only consentLoaderScript() - which adds them
9
- // once the reader has accepted, now or on an earlier visit. `scripts`
10
- // entries marked `consent: true` (gatedScripts) wait the same way.
11
- //
12
- // Rendered by BaseLayout.astro in <head>, right after the meta tags and
13
- // before even the theme-detection script - the usual placement every one
14
- // of these providers' own install instructions ask for, so pageview timing
15
- // is captured as close to actual page load as it can be. Every provider
16
- // field is optional and independent - a site can turn on any subset
17
- // (including all of them at once, for a migration period) or none.
18
- //
19
- // AskAiWidget.astro is the seventh integration (DocsBot) - its own
20
- // component, since it renders at the *end* of <body>, not in <head> (it's a
21
- // UI widget, not a pageview beacon - see that component's own comment), and
22
- // it doesn't wait for consent.
23
- import type { DocsConfig } from '../../lib/config';
24
- import { analyticsTags, scriptTags, consentLoaderScript } from '../../lib/consent.js';
25
- import { siteHref } from '../../lib/site-base';
26
-
27
- interface Props {
28
- config: DocsConfig;
29
- // consentOptions() of `integrations.consent` - null when the banner is off.
30
- consent?: object | null;
31
- // `scripts` entries with `consent: true`. Empty when the banner is off:
32
- // BaseLayout renders them as ordinary scripts then.
33
- gatedScripts?: { src?: string; content?: string }[];
34
- }
35
- const { config, consent = null, gatedScripts = [] } = Astro.props as Props;
36
-
37
- // A script's `src` can be a file in the site ("/js/stats.js"): it gets the
38
- // basePath (lib/site-base.ts).
39
- const withSrcBase = <T extends { src?: string }>(tag: T): T => (tag.src ? { ...tag, src: siteHref(tag.src) } : tag);
40
- const tags = analyticsTags(config.integrations).map(withSrcBase);
41
- const loader = consent ? consentLoaderScript([...tags, ...scriptTags(gatedScripts).map(withSrcBase)]) : null;
42
- ---
43
- {loader ? (
44
- <script is:inline set:html={loader} />
45
- ) : (
46
- tags.map((tag) =>
47
- tag.src ? <script is:inline src={tag.src} {...tag.attrs}></script> : <script is:inline set:html={tag.content} />,
48
- )
49
- )}
1
+ ---
2
+ // writedocs.json's `integrations` - the six analytics providers. The tags
3
+ // themselves are built by analyticsTags() in lib/consent.js (each one the
4
+ // provider's own install snippet - see docs/dev/docs/integrations.mdx for
5
+ // links and dates); this component decides how they reach the page:
6
+ //
7
+ // - no `integrations.consent`: one <script> tag each, loaded with the page.
8
+ // - with it: no tag at all, only consentLoaderScript() - which adds them
9
+ // once the reader has accepted, now or on an earlier visit. `scripts`
10
+ // entries marked `consent: true` (gatedScripts) wait the same way.
11
+ //
12
+ // Rendered by BaseLayout.astro in <head>, right after the meta tags and
13
+ // before even the theme-detection script - the usual placement every one
14
+ // of these providers' own install instructions ask for, so pageview timing
15
+ // is captured as close to actual page load as it can be. Every provider
16
+ // field is optional and independent - a site can turn on any subset
17
+ // (including all of them at once, for a migration period) or none.
18
+ //
19
+ // AskAiWidget.astro is the seventh integration (DocsBot) - its own
20
+ // component, since it renders at the *end* of <body>, not in <head> (it's a
21
+ // UI widget, not a pageview beacon - see that component's own comment), and
22
+ // it doesn't wait for consent.
23
+ import type { DocsConfig } from '../../lib/config';
24
+ import { analyticsTags, scriptTags, consentLoaderScript } from '../../lib/consent.js';
25
+ import { siteHref } from '../../lib/site-base';
26
+
27
+ interface Props {
28
+ config: DocsConfig;
29
+ // consentOptions() of `integrations.consent` - null when the banner is off.
30
+ consent?: object | null;
31
+ // `scripts` entries with `consent: true`. Empty when the banner is off:
32
+ // BaseLayout renders them as ordinary scripts then.
33
+ gatedScripts?: { src?: string; content?: string }[];
34
+ }
35
+ const { config, consent = null, gatedScripts = [] } = Astro.props as Props;
36
+
37
+ // A script's `src` can be a file in the site ("/js/stats.js"): it gets the
38
+ // basePath (lib/site-base.ts).
39
+ const withSrcBase = <T extends { src?: string }>(tag: T): T => (tag.src ? { ...tag, src: siteHref(tag.src) } : tag);
40
+ const tags = analyticsTags(config.integrations).map(withSrcBase);
41
+ const loader = consent ? consentLoaderScript([...tags, ...scriptTags(gatedScripts).map(withSrcBase)]) : null;
42
+ ---
43
+ {loader ? (
44
+ <script is:inline set:html={loader} />
45
+ ) : (
46
+ tags.map((tag) =>
47
+ tag.src ? <script is:inline src={tag.src} {...tag.attrs}></script> : <script is:inline set:html={tag.content} />,
48
+ )
49
+ )}
@@ -1,98 +1,98 @@
1
- ---
2
- // The ancestor-group trail above the auto-rendered <h1> ("Learn the
3
- // Basics > Authentication Flows") - `items` is ancestorGroupsForSlug()'s
4
- // output (lib/config.ts): the chain of group labels (root first) the
5
- // current page is nested under within its active Section's sidebar tree,
6
- // each linking to that group's own attached page when it has one
7
- // (`href`), or rendered as plain unlinked text when it doesn't.
8
- // Deliberately does NOT include the current page itself as a trailing
9
- // crumb - that's already the <h1> right below this, and repeating it
10
- // here would just be noise. [...slug].astro only renders this component
11
- // at all when `items` is non-empty (a page with no enclosing group has
12
- // no ancestor trail to show, and a home-icon-only bar isn't worth
13
- // rendering on its own).
14
- //
15
- // The home icon is always the first crumb, on every page this component
16
- // renders on, regardless of `items` - a fixed entry point back to `/`,
17
- // not itself part of the ancestor chain. Rendered via astro-icon (same
18
- // system every other writedocs.json `icon` field/AppIcon.astro uses - a real
19
- // build-time <svg>, no client JS/React needed) - fa6-solid:house is the
20
- // Iconify id for the exact same Font Awesome 6 glyph as react-icons'
21
- // `FaHouse`, without pulling React into an otherwise-static nav element.
22
- import { Icon } from 'astro-icon/components';
23
- import { siteHref } from '../../lib/site-base';
24
-
25
- export interface BreadcrumbItem {
26
- label: string;
27
- href: string | null;
28
- }
29
-
30
- interface Props {
31
- items: BreadcrumbItem[];
32
- }
33
-
34
- const { items } = Astro.props as Props;
35
- ---
36
- <nav class="wd-breadcrumbs" aria-label="Breadcrumb" data-pagefind-ignore data-markdown-ignore>
37
- <ol class="wd-breadcrumb-list">
38
- <li class="wd-breadcrumb-item">
39
- <a href={siteHref("/")} class="wd-breadcrumb-home" aria-label="Home">
40
- <Icon name="fa6-solid:house" class="wd-breadcrumb-home-icon" />
41
- </a>
42
- <svg class="wd-breadcrumb-sep" width="10" height="10" viewBox="0 0 18 18" fill="none" aria-hidden="true">
43
- <path d="M6.5 2.75L12.75 9L6.5 15.25" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
44
- </svg>
45
- </li>
46
- {items.map((item, i) => (
47
- <li class="wd-breadcrumb-item">
48
- {item.href ? <a href={siteHref(item.href)}>{item.label}</a> : <span>{item.label}</span>}
49
- {i < items.length - 1 && (
50
- <svg class="wd-breadcrumb-sep" width="10" height="10" viewBox="0 0 18 18" fill="none" aria-hidden="true">
51
- <path d="M6.5 2.75L12.75 9L6.5 15.25" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
52
- </svg>
53
- )}
54
- </li>
55
- ))}
56
- </ol>
57
- </nav>
58
-
59
- <style>
60
- .wd-breadcrumbs {
61
- margin-bottom: 0.6rem;
62
- }
63
- .wd-breadcrumb-list {
64
- display: flex;
65
- flex-wrap: wrap;
66
- align-items: center;
67
- gap: 0.35rem;
68
- list-style: none;
69
- margin: 0;
70
- padding: 0;
71
- font-size: 0.85rem;
72
- color: var(--wd-text-muted);
73
- }
74
- .wd-breadcrumb-item {
75
- display: flex;
76
- align-items: center;
77
- gap: 0.35rem;
78
- }
79
- .wd-breadcrumb-item a {
80
- display: flex;
81
- align-items: center;
82
- color: inherit;
83
- text-decoration: none;
84
- }
85
- .wd-breadcrumb-item a:hover {
86
- color: var(--wd-text);
87
- }
88
- .wd-breadcrumb-home-icon {
89
- width: 0.85em;
90
- height: 0.85em;
91
- flex-shrink: 0;
92
- }
93
- .wd-breadcrumb-sep {
94
- flex-shrink: 0;
95
- color: var(--wd-text-muted);
96
- opacity: 0.6;
97
- }
98
- </style>
1
+ ---
2
+ // The ancestor-group trail above the auto-rendered <h1> ("Learn the
3
+ // Basics > Authentication Flows") - `items` is ancestorGroupsForSlug()'s
4
+ // output (lib/config.ts): the chain of group labels (root first) the
5
+ // current page is nested under within its active Section's sidebar tree,
6
+ // each linking to that group's own attached page when it has one
7
+ // (`href`), or rendered as plain unlinked text when it doesn't.
8
+ // Deliberately does NOT include the current page itself as a trailing
9
+ // crumb - that's already the <h1> right below this, and repeating it
10
+ // here would just be noise. [...slug].astro only renders this component
11
+ // at all when `items` is non-empty (a page with no enclosing group has
12
+ // no ancestor trail to show, and a home-icon-only bar isn't worth
13
+ // rendering on its own).
14
+ //
15
+ // The home icon is always the first crumb, on every page this component
16
+ // renders on, regardless of `items` - a fixed entry point back to `/`,
17
+ // not itself part of the ancestor chain. Rendered via astro-icon (same
18
+ // system every other writedocs.json `icon` field/AppIcon.astro uses - a real
19
+ // build-time <svg>, no client JS/React needed) - fa6-solid:house is the
20
+ // Iconify id for the exact same Font Awesome 6 glyph as react-icons'
21
+ // `FaHouse`, without pulling React into an otherwise-static nav element.
22
+ import { Icon } from 'astro-icon/components';
23
+ import { siteHref } from '../../lib/site-base';
24
+
25
+ export interface BreadcrumbItem {
26
+ label: string;
27
+ href: string | null;
28
+ }
29
+
30
+ interface Props {
31
+ items: BreadcrumbItem[];
32
+ }
33
+
34
+ const { items } = Astro.props as Props;
35
+ ---
36
+ <nav class="wd-breadcrumbs" aria-label="Breadcrumb" data-pagefind-ignore data-markdown-ignore>
37
+ <ol class="wd-breadcrumb-list">
38
+ <li class="wd-breadcrumb-item">
39
+ <a href={siteHref("/")} class="wd-breadcrumb-home" aria-label="Home">
40
+ <Icon name="fa6-solid:house" class="wd-breadcrumb-home-icon" />
41
+ </a>
42
+ <svg class="wd-breadcrumb-sep" width="10" height="10" viewBox="0 0 18 18" fill="none" aria-hidden="true">
43
+ <path d="M6.5 2.75L12.75 9L6.5 15.25" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
44
+ </svg>
45
+ </li>
46
+ {items.map((item, i) => (
47
+ <li class="wd-breadcrumb-item">
48
+ {item.href ? <a href={siteHref(item.href)}>{item.label}</a> : <span>{item.label}</span>}
49
+ {i < items.length - 1 && (
50
+ <svg class="wd-breadcrumb-sep" width="10" height="10" viewBox="0 0 18 18" fill="none" aria-hidden="true">
51
+ <path d="M6.5 2.75L12.75 9L6.5 15.25" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
52
+ </svg>
53
+ )}
54
+ </li>
55
+ ))}
56
+ </ol>
57
+ </nav>
58
+
59
+ <style>
60
+ .wd-breadcrumbs {
61
+ margin-bottom: 0.6rem;
62
+ }
63
+ .wd-breadcrumb-list {
64
+ display: flex;
65
+ flex-wrap: wrap;
66
+ align-items: center;
67
+ gap: 0.35rem;
68
+ list-style: none;
69
+ margin: 0;
70
+ padding: 0;
71
+ font-size: 0.85rem;
72
+ color: var(--wd-text-muted);
73
+ }
74
+ .wd-breadcrumb-item {
75
+ display: flex;
76
+ align-items: center;
77
+ gap: 0.35rem;
78
+ }
79
+ .wd-breadcrumb-item a {
80
+ display: flex;
81
+ align-items: center;
82
+ color: inherit;
83
+ text-decoration: none;
84
+ }
85
+ .wd-breadcrumb-item a:hover {
86
+ color: var(--wd-text);
87
+ }
88
+ .wd-breadcrumb-home-icon {
89
+ width: 0.85em;
90
+ height: 0.85em;
91
+ flex-shrink: 0;
92
+ }
93
+ .wd-breadcrumb-sep {
94
+ flex-shrink: 0;
95
+ color: var(--wd-text-muted);
96
+ opacity: 0.6;
97
+ }
98
+ </style>
@@ -1,119 +1,119 @@
1
- ---
2
- import { siteHref } from '../../lib/site-base';
3
- // writedocs.json's `integrations.consent` - the banner that asks before the
4
- // analytics integrations load. It's in the page hidden; src/scripts/
5
- // consent.ts shows it when the reader hasn't answered yet (window.wdConsent,
6
- // defined in <head> by consentLoaderScript() in lib/consent.js), and again
7
- // when they follow a link to #cookie-settings.
8
- //
9
- // A strip along the bottom of the window rather than a dialog: the page
10
- // stays readable and usable while it's there, so focus isn't trapped and
11
- // nothing is covered that can't be scrolled into view (consent.ts pads the
12
- // page's end by the banner's height).
13
- interface Props {
14
- consent: {
15
- message: string;
16
- acceptLabel: string;
17
- declineLabel: string;
18
- policyUrl: string | null;
19
- policyLabel: string;
20
- };
21
- }
22
- const { consent } = Astro.props as Props;
23
- ---
24
- <section class="wd-consent" id="wd-consent" aria-label="Cookie consent" data-pagefind-ignore hidden>
25
- <div class="wd-consent-inner">
26
- <p class="wd-consent-text">
27
- {consent.message}{" "}
28
- {consent.policyUrl && <a href={siteHref(consent.policyUrl)}>{consent.policyLabel}</a>}
29
- </p>
30
- <div class="wd-consent-actions">
31
- <button type="button" class="wd-consent-button" data-consent="denied">{consent.declineLabel}</button>
32
- <button type="button" class="wd-consent-button wd-consent-accept" data-consent="granted">{consent.acceptLabel}</button>
33
- </div>
34
- </div>
35
- </section>
36
-
37
- <script>
38
- import { initConsent } from "../../scripts/consent";
39
-
40
- initConsent(document);
41
- document.addEventListener("astro:page-load", () => initConsent(document));
42
- </script>
43
-
44
- <style is:global>
45
- .wd-consent {
46
- position: fixed;
47
- left: 0;
48
- right: 0;
49
- bottom: 0;
50
- /* Above the topbar (10) and the page; below the search and image
51
- overlays (100), which the reader opened on purpose. */
52
- z-index: 50;
53
- background: var(--wd-surface);
54
- border-top: 1px solid var(--wd-border);
55
- color: var(--wd-text);
56
- box-shadow: 0 -4px 16px rgb(0 0 0 / 0.08);
57
- }
58
- .wd-consent[hidden] {
59
- display: none;
60
- }
61
- .wd-consent-inner {
62
- max-width: 1440px;
63
- margin: 0 auto;
64
- padding: 0.85rem 1.5rem;
65
- display: flex;
66
- align-items: center;
67
- justify-content: space-between;
68
- gap: 1rem 1.5rem;
69
- }
70
- .wd-consent-text {
71
- margin: 0;
72
- font-size: 0.88rem;
73
- line-height: 1.5;
74
- }
75
- .wd-consent-text a {
76
- color: var(--wd-primary);
77
- text-decoration: underline;
78
- }
79
- .wd-consent-actions {
80
- display: flex;
81
- gap: 0.5rem;
82
- flex-shrink: 0;
83
- }
84
- /* Both buttons the same size and weight but for the fill - declining is as
85
- easy as accepting. */
86
- .wd-consent-button {
87
- font: inherit;
88
- font-size: 0.85rem;
89
- font-weight: 600;
90
- padding: 0.45rem 1rem;
91
- border-radius: 0.5rem;
92
- border: 1px solid var(--wd-border);
93
- background: var(--wd-background);
94
- color: var(--wd-heading);
95
- cursor: pointer;
96
- }
97
- .wd-consent-button:hover {
98
- border-color: var(--wd-primary);
99
- }
100
- .wd-consent-accept {
101
- background: var(--wd-primary);
102
- border-color: var(--wd-primary);
103
- color: var(--wd-on-primary);
104
- }
105
- .wd-consent-button:focus-visible {
106
- outline: 2px solid var(--wd-primary);
107
- outline-offset: 2px;
108
- }
109
- @media (max-width: 640px) {
110
- .wd-consent-inner {
111
- flex-direction: column;
112
- align-items: stretch;
113
- padding: 0.85rem 1rem;
114
- }
115
- .wd-consent-actions > .wd-consent-button {
116
- flex: 1;
117
- }
118
- }
119
- </style>
1
+ ---
2
+ import { siteHref } from '../../lib/site-base';
3
+ // writedocs.json's `integrations.consent` - the banner that asks before the
4
+ // analytics integrations load. It's in the page hidden; src/scripts/
5
+ // consent.ts shows it when the reader hasn't answered yet (window.wdConsent,
6
+ // defined in <head> by consentLoaderScript() in lib/consent.js), and again
7
+ // when they follow a link to #cookie-settings.
8
+ //
9
+ // A strip along the bottom of the window rather than a dialog: the page
10
+ // stays readable and usable while it's there, so focus isn't trapped and
11
+ // nothing is covered that can't be scrolled into view (consent.ts pads the
12
+ // page's end by the banner's height).
13
+ interface Props {
14
+ consent: {
15
+ message: string;
16
+ acceptLabel: string;
17
+ declineLabel: string;
18
+ policyUrl: string | null;
19
+ policyLabel: string;
20
+ };
21
+ }
22
+ const { consent } = Astro.props as Props;
23
+ ---
24
+ <section class="wd-consent" id="wd-consent" aria-label="Cookie consent" data-pagefind-ignore hidden>
25
+ <div class="wd-consent-inner">
26
+ <p class="wd-consent-text">
27
+ {consent.message}{" "}
28
+ {consent.policyUrl && <a href={siteHref(consent.policyUrl)}>{consent.policyLabel}</a>}
29
+ </p>
30
+ <div class="wd-consent-actions">
31
+ <button type="button" class="wd-consent-button" data-consent="denied">{consent.declineLabel}</button>
32
+ <button type="button" class="wd-consent-button wd-consent-accept" data-consent="granted">{consent.acceptLabel}</button>
33
+ </div>
34
+ </div>
35
+ </section>
36
+
37
+ <script>
38
+ import { initConsent } from "../../scripts/consent";
39
+
40
+ initConsent(document);
41
+ document.addEventListener("astro:page-load", () => initConsent(document));
42
+ </script>
43
+
44
+ <style is:global>
45
+ .wd-consent {
46
+ position: fixed;
47
+ left: 0;
48
+ right: 0;
49
+ bottom: 0;
50
+ /* Above the topbar (10) and the page; below the search and image
51
+ overlays (100), which the reader opened on purpose. */
52
+ z-index: 50;
53
+ background: var(--wd-surface);
54
+ border-top: 1px solid var(--wd-border);
55
+ color: var(--wd-text);
56
+ box-shadow: 0 -4px 16px rgb(0 0 0 / 0.08);
57
+ }
58
+ .wd-consent[hidden] {
59
+ display: none;
60
+ }
61
+ .wd-consent-inner {
62
+ max-width: 1440px;
63
+ margin: 0 auto;
64
+ padding: 0.85rem 1.5rem;
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: space-between;
68
+ gap: 1rem 1.5rem;
69
+ }
70
+ .wd-consent-text {
71
+ margin: 0;
72
+ font-size: 0.88rem;
73
+ line-height: 1.5;
74
+ }
75
+ .wd-consent-text a {
76
+ color: var(--wd-primary);
77
+ text-decoration: underline;
78
+ }
79
+ .wd-consent-actions {
80
+ display: flex;
81
+ gap: 0.5rem;
82
+ flex-shrink: 0;
83
+ }
84
+ /* Both buttons the same size and weight but for the fill - declining is as
85
+ easy as accepting. */
86
+ .wd-consent-button {
87
+ font: inherit;
88
+ font-size: 0.85rem;
89
+ font-weight: 600;
90
+ padding: 0.45rem 1rem;
91
+ border-radius: 0.5rem;
92
+ border: 1px solid var(--wd-border);
93
+ background: var(--wd-background);
94
+ color: var(--wd-heading);
95
+ cursor: pointer;
96
+ }
97
+ .wd-consent-button:hover {
98
+ border-color: var(--wd-primary);
99
+ }
100
+ .wd-consent-accept {
101
+ background: var(--wd-primary);
102
+ border-color: var(--wd-primary);
103
+ color: var(--wd-on-primary);
104
+ }
105
+ .wd-consent-button:focus-visible {
106
+ outline: 2px solid var(--wd-primary);
107
+ outline-offset: 2px;
108
+ }
109
+ @media (max-width: 640px) {
110
+ .wd-consent-inner {
111
+ flex-direction: column;
112
+ align-items: stretch;
113
+ padding: 0.85rem 1rem;
114
+ }
115
+ .wd-consent-actions > .wd-consent-button {
116
+ flex: 1;
117
+ }
118
+ }
119
+ </style>