@writedocs/generator 0.10.20 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro.config.mjs +32 -8
- package/package.json +3 -1
- package/src/cli/astro-output.js +44 -11
- package/src/cli/base-path-layout.js +44 -0
- package/src/cli/build.js +18 -9
- package/src/cli/check-built-styles.js +41 -33
- package/src/cli/dev.js +21 -4
- package/src/cli/run-pagefind.js +154 -148
- package/src/cli/write-mcp-files.js +103 -96
- package/src/cli/write-redirects-file.js +25 -8
- package/src/components/AppIcon.astro +51 -50
- package/src/components/Card.astro +193 -192
- package/src/components/CopyPageMenu.astro +374 -370
- package/src/components/Hint.astro +188 -187
- package/src/components/Icon.astro +72 -71
- package/src/components/Image.astro +3 -2
- package/src/components/Tile.astro +67 -66
- package/src/components/Video.astro +137 -136
- package/src/layout/BaseLayout.astro +21 -12
- package/src/layout/components/AnalyticsScripts.astro +6 -2
- package/src/layout/components/Breadcrumbs.astro +98 -97
- package/src/layout/components/ConsentBanner.astro +119 -118
- package/src/layout/components/MobileMenu.astro +229 -228
- package/src/layout/components/NavTree.astro +393 -392
- package/src/layout/components/Sidebar.astro +232 -231
- package/src/layout/components/SiteFooter.astro +87 -86
- package/src/layout/components/TopBar.astro +386 -385
- package/src/lib/agent-markdown.js +164 -162
- package/src/lib/asset-dimensions.js +89 -89
- package/src/lib/base-path.js +90 -0
- package/src/lib/config-schema.js +10 -0
- package/src/lib/config-schema.ts +17 -0
- package/src/lib/config.ts +1314 -1289
- package/src/lib/consent.js +108 -102
- package/src/lib/json-schema-descriptions.js +1 -0
- package/src/lib/link-check.js +7 -2
- package/src/lib/llms-index.ts +90 -88
- package/src/lib/mcp-dev-integration.js +65 -60
- package/src/lib/mcp-index.ts +102 -101
- package/src/lib/project-files-integration.js +2 -2
- package/src/lib/rehype-base-path.js +62 -0
- package/src/lib/robots-txt.js +21 -16
- package/src/lib/seo-tags.js +155 -140
- package/src/lib/site-base.ts +27 -0
- package/src/lib/styles-asset-integration.js +23 -10
- package/src/lib/wdignore-cases.json +195 -195
- package/src/lib/wdignore.js +177 -177
- package/src/pages/404.astro +63 -62
- package/src/pages/[...slug].astro +1604 -1597
- package/src/pages/[...slug].md.ts +93 -93
- package/src/pages/llms-full.txt.ts +88 -86
- package/src/scripts/search.ts +245 -237
- package/writedocs.schema.json +6 -0
|
@@ -1,66 +1,67 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { extraClasses } from './class-names';
|
|
3
|
-
// Mintlify's <Tile> - a visual preview (the slot, usually an image or a
|
|
4
|
-
// light/dark image pair) on a patterned background, with a title and
|
|
5
|
-
// description under it. Usually laid out in a <Columns> grid. `title`
|
|
6
|
-
// takes inline Markdown (`code`, **bold**, *italic*), like Mintlify's.
|
|
7
|
-
import { inlineMarkdown } from '../lib/inline-markdown.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
</
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
border
|
|
38
|
-
|
|
39
|
-
background-
|
|
40
|
-
background-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.wd-tile-preview :global(
|
|
48
|
-
|
|
49
|
-
max-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
---
|
|
2
|
+
import { extraClasses } from './class-names';
|
|
3
|
+
// Mintlify's <Tile> - a visual preview (the slot, usually an image or a
|
|
4
|
+
// light/dark image pair) on a patterned background, with a title and
|
|
5
|
+
// description under it. Usually laid out in a <Columns> grid. `title`
|
|
6
|
+
// takes inline Markdown (`code`, **bold**, *italic*), like Mintlify's.
|
|
7
|
+
import { inlineMarkdown } from '../lib/inline-markdown.js';
|
|
8
|
+
import { siteHref } from '../lib/site-base';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
href?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
const { href, title, description } = Astro.props as Props;
|
|
16
|
+
const Tag = href ? 'a' : 'div';
|
|
17
|
+
---
|
|
18
|
+
<Tag class:list={["wd-tile", extraClasses(Astro.props)]} href={siteHref(href)}>
|
|
19
|
+
<div class="wd-tile-preview"><slot /></div>
|
|
20
|
+
{title && <div class="wd-tile-title" set:html={inlineMarkdown(title)} />}
|
|
21
|
+
{description && <div class="wd-tile-description">{description}</div>}
|
|
22
|
+
</Tag>
|
|
23
|
+
<style>
|
|
24
|
+
.wd-tile {
|
|
25
|
+
display: block;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
color: inherit;
|
|
28
|
+
}
|
|
29
|
+
/* Dotted pattern behind the preview, drawn from the theme's own border
|
|
30
|
+
color so it reads in both themes. */
|
|
31
|
+
.wd-tile-preview {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
height: 10rem;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
border: 1px solid var(--wd-border);
|
|
38
|
+
border-radius: 0.6rem;
|
|
39
|
+
background-color: var(--wd-surface);
|
|
40
|
+
background-image: radial-gradient(var(--wd-border) 1px, transparent 1px);
|
|
41
|
+
background-size: 14px 14px;
|
|
42
|
+
transition: border-color 0.15s ease;
|
|
43
|
+
}
|
|
44
|
+
a.wd-tile:hover .wd-tile-preview {
|
|
45
|
+
border-color: var(--wd-primary);
|
|
46
|
+
}
|
|
47
|
+
.wd-tile-preview :global(img),
|
|
48
|
+
.wd-tile-preview :global(svg) {
|
|
49
|
+
max-width: 100%;
|
|
50
|
+
max-height: 100%;
|
|
51
|
+
object-fit: contain;
|
|
52
|
+
margin: 0;
|
|
53
|
+
}
|
|
54
|
+
.wd-tile-preview :global(p) {
|
|
55
|
+
display: contents;
|
|
56
|
+
}
|
|
57
|
+
.wd-tile-title {
|
|
58
|
+
margin-top: 0.6rem;
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
color: var(--wd-heading);
|
|
61
|
+
}
|
|
62
|
+
.wd-tile-description {
|
|
63
|
+
margin-top: 0.15rem;
|
|
64
|
+
font-size: 0.875rem;
|
|
65
|
+
color: var(--wd-text);
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
@@ -1,136 +1,137 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { extraClasses } from './class-names';
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
// `src
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
// it
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
why
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
border
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
border
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
---
|
|
2
|
+
import { extraClasses } from './class-names';
|
|
3
|
+
import { siteHref } from '../lib/site-base';
|
|
4
|
+
// Renders either a native <video> or an <iframe> embed from the same
|
|
5
|
+
// `src` prop, auto-detected rather than requiring the author to pick -
|
|
6
|
+
// `src="media/clip.mp4"` (a direct video file, local or remote) gets a
|
|
7
|
+
// real <video controls>; `src="https://www.youtube.com/embed/..."` (or
|
|
8
|
+
// Vimeo, Loom, any other embed URL with no recognizable video file
|
|
9
|
+
// extension) gets an <iframe>. Same block-level, own-line, centered
|
|
10
|
+
// shape as Image/Frame, and shares their exact card language (border-
|
|
11
|
+
// radius, padding, box-shadow) - "same border radius as image and
|
|
12
|
+
// frame" was the explicit ask this was built against.
|
|
13
|
+
interface Props {
|
|
14
|
+
src: string;
|
|
15
|
+
// A raw CSS width ("500px", "80%", "40rem", ...) - named `width`
|
|
16
|
+
// here (not `size`, Image's own name for the same idea) to match
|
|
17
|
+
// this component's own requested API exactly. Same "applied to the
|
|
18
|
+
// wrapping figure, not the media element" approach Image.astro's own
|
|
19
|
+
// `size` prop uses (see its comment for the real bug that came from
|
|
20
|
+
// getting this wrong once already) - the whole component, card
|
|
21
|
+
// background included, sizes to `width`, not just the video/iframe
|
|
22
|
+
// inside it.
|
|
23
|
+
width?: string;
|
|
24
|
+
// Only meaningful for the <video> branch - ignored (not rendered as
|
|
25
|
+
// an attribute at all) for an <iframe> embed, since a YouTube/Vimeo
|
|
26
|
+
// player controls its own playback UI, autoplay policy, and looping
|
|
27
|
+
// through its own embed URL query params instead.
|
|
28
|
+
controls?: boolean;
|
|
29
|
+
autoplay?: boolean;
|
|
30
|
+
loop?: boolean;
|
|
31
|
+
muted?: boolean;
|
|
32
|
+
// Alt text has no real equivalent for video - `title` is the
|
|
33
|
+
// accessible-name attribute both <video> (via a wrapping description)
|
|
34
|
+
// and <iframe> (a required attribute for a11y tooling to identify
|
|
35
|
+
// embedded content) actually use.
|
|
36
|
+
title?: string;
|
|
37
|
+
caption?: string;
|
|
38
|
+
}
|
|
39
|
+
const {
|
|
40
|
+
src,
|
|
41
|
+
width,
|
|
42
|
+
controls = true,
|
|
43
|
+
autoplay = false,
|
|
44
|
+
loop = false,
|
|
45
|
+
muted = false,
|
|
46
|
+
title,
|
|
47
|
+
caption,
|
|
48
|
+
} = Astro.props as Props;
|
|
49
|
+
const isFile = /\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?(#.*)?$/i.test(src);
|
|
50
|
+
const sizeStyle = width ? `--wd-video-size:${width}` : undefined;
|
|
51
|
+
// Autoplaying video muted is a hard browser requirement, not a style
|
|
52
|
+
// choice - every major browser silently blocks (or, worse, plays with
|
|
53
|
+
// sound the visitor didn't ask for and then gets auto-paused
|
|
54
|
+
// inconsistently) an unmuted autoplay <video>, so an author setting
|
|
55
|
+
// autoplay without also remembering muted would get a broken-looking
|
|
56
|
+
// embed rather than the "plays immediately" behavior they actually
|
|
57
|
+
// asked for. Forcing it here means autoplay just works the one way
|
|
58
|
+
// it's actually able to.
|
|
59
|
+
const effectiveMuted = muted || autoplay;
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
<figure class:list={["wd-video-figure", caption && "wd-video-figure-framed", extraClasses(Astro.props)]} style={sizeStyle}>
|
|
63
|
+
{
|
|
64
|
+
isFile ? (
|
|
65
|
+
<video
|
|
66
|
+
class="wd-video"
|
|
67
|
+
src={siteHref(src)}
|
|
68
|
+
controls={controls}
|
|
69
|
+
autoplay={autoplay}
|
|
70
|
+
loop={loop}
|
|
71
|
+
muted={effectiveMuted}
|
|
72
|
+
playsinline
|
|
73
|
+
title={title}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<iframe
|
|
77
|
+
class="wd-video wd-video-embed"
|
|
78
|
+
src={siteHref(src)}
|
|
79
|
+
title={title ?? "Embedded video"}
|
|
80
|
+
loading="lazy"
|
|
81
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
82
|
+
allowfullscreen
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
{caption && <figcaption class="wd-video-caption">{caption}</figcaption>}
|
|
87
|
+
</figure>
|
|
88
|
+
<style>
|
|
89
|
+
/* Same three rules as Image.astro's own .wd-image-figure/
|
|
90
|
+
.wd-image-figure-framed/.wd-image-caption - see that file's own
|
|
91
|
+
comments for why width lives on the figure (not the media element),
|
|
92
|
+
why padding is what creates the inset-in-a-card look, and why
|
|
93
|
+
box-shadow exists alongside the border. Kept in sync on purpose -
|
|
94
|
+
both components are explicitly meant to look identical modulo
|
|
95
|
+
what's actually inside them. */
|
|
96
|
+
.wd-video-figure {
|
|
97
|
+
width: var(--wd-video-size, 100%);
|
|
98
|
+
max-width: 100%;
|
|
99
|
+
margin: 1.25rem auto;
|
|
100
|
+
}
|
|
101
|
+
.wd-video-figure-framed {
|
|
102
|
+
border: 1px solid var(--wd-border);
|
|
103
|
+
border-radius: 0.75rem;
|
|
104
|
+
background: var(--wd-surface);
|
|
105
|
+
padding: 0.5rem;
|
|
106
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
107
|
+
}
|
|
108
|
+
.wd-video {
|
|
109
|
+
display: block;
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: auto;
|
|
112
|
+
border: 0;
|
|
113
|
+
border-radius: 0.75rem;
|
|
114
|
+
}
|
|
115
|
+
/* Unlike <img>/<video> (both read their own intrinsic dimensions once
|
|
116
|
+
loaded, so width: 100%; height: auto keeps them proportional on
|
|
117
|
+
their own), a bare <iframe> has no intrinsic size at all - without
|
|
118
|
+
something constraining its height it either collapses to the UA
|
|
119
|
+
default (~150px) or needs an explicit pixel height the embedding
|
|
120
|
+
author would have to compute themselves. aspect-ratio: 16 / 9 is
|
|
121
|
+
the standard embed shape (YouTube, Vimeo, Loom, ...) and needs no
|
|
122
|
+
JS/ResizeObserver trick to stay proportional as width changes -
|
|
123
|
+
it's a real, if imperfect, default for embeds that aren't actually
|
|
124
|
+
16:9 (a vertical/Shorts-style video letterboxes instead of filling
|
|
125
|
+
the frame), which there's no way to detect automatically from a
|
|
126
|
+
bare embed URL.
|
|
127
|
+
*/
|
|
128
|
+
.wd-video-embed {
|
|
129
|
+
aspect-ratio: 16 / 9;
|
|
130
|
+
}
|
|
131
|
+
.wd-video-caption {
|
|
132
|
+
margin-top: 0.6rem;
|
|
133
|
+
text-align: center;
|
|
134
|
+
color: var(--wd-text);
|
|
135
|
+
font-size: 0.75rem;
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
@@ -29,6 +29,7 @@ import fs from "node:fs";
|
|
|
29
29
|
import nodePath from "node:path";
|
|
30
30
|
import {
|
|
31
31
|
resolveSiteUrl,
|
|
32
|
+
resolveSiteRoot,
|
|
32
33
|
findRootAssets,
|
|
33
34
|
resolveNavbarColor,
|
|
34
35
|
contrastTextColor,
|
|
@@ -83,6 +84,9 @@ import { contextMenuOptions } from "../lib/config";
|
|
|
83
84
|
import { jsonLd, serializeJsonLd } from "../lib/json-ld.js";
|
|
84
85
|
import { consentOptions } from "../lib/consent.js";
|
|
85
86
|
import { oncePerBuild } from "../lib/build-memo.js";
|
|
87
|
+
// writedocs.json's `basePath`: every site address written below goes
|
|
88
|
+
// through siteHref() - see lib/site-base.ts.
|
|
89
|
+
import { BASE, siteHref } from "../lib/site-base";
|
|
86
90
|
|
|
87
91
|
interface Props {
|
|
88
92
|
config: DocsConfig;
|
|
@@ -91,7 +95,8 @@ interface Props {
|
|
|
91
95
|
// see [...slug].astro, which passes entry.data.description straight
|
|
92
96
|
// through without resolving the fallback itself.
|
|
93
97
|
description?: string;
|
|
94
|
-
// The current page's own path (e.g. "/" or "/guides/foo/"
|
|
98
|
+
// The current page's own path (e.g. "/" or "/guides/foo/" - without the
|
|
99
|
+
// basePath, which siteUrl carries), used to
|
|
95
100
|
// build the canonical <link> and og:url/twitter:url - [...slug].astro
|
|
96
101
|
// already computes this via hrefForSlug(currentFileId) for its own
|
|
97
102
|
// prev/next links, so it's passed through rather than recomputed here.
|
|
@@ -170,6 +175,7 @@ const head = seoHead({
|
|
|
170
175
|
seo,
|
|
171
176
|
siteUrl,
|
|
172
177
|
path,
|
|
178
|
+
base: BASE,
|
|
173
179
|
});
|
|
174
180
|
// hreflang: only on a page search engines index, and only with full URLs.
|
|
175
181
|
const languageLinks = seo.noindex ? [] : hreflangLinks(siteUrl, alternates);
|
|
@@ -194,7 +200,7 @@ const structuredData = jsonLd({
|
|
|
194
200
|
});
|
|
195
201
|
// The note that tells an AI agent reading this page where llms.txt is -
|
|
196
202
|
// see lib/agent-directive.js.
|
|
197
|
-
const agentNote = htmlDirective({ siteUrl, markdownPages: contextMenuOptions(config.contextMenu).length > 0 });
|
|
203
|
+
const agentNote = htmlDirective({ siteUrl: resolveSiteRoot(config) || null, markdownPages: contextMenuOptions(config.contextMenu).length > 0 });
|
|
198
204
|
// Analytics wait for the reader's answer when the consent banner is on -
|
|
199
205
|
// see lib/consent.js.
|
|
200
206
|
const consent = consentOptions(config.integrations.consent);
|
|
@@ -330,10 +336,10 @@ const darkNavbarHover = darkNavbarConfigured ? `color-mix(in srgb, ${darkNavbarF
|
|
|
330
336
|
const lightPageBgColor = lightBackground;
|
|
331
337
|
const darkPageBgColor = darkBackground;
|
|
332
338
|
const lightPageBgImage = config.styles.background?.images?.light
|
|
333
|
-
? `url('${config.styles.background.images.light}')`
|
|
339
|
+
? `url('${siteHref(config.styles.background.images.light)}')`
|
|
334
340
|
: "none";
|
|
335
341
|
const darkPageBgImage = config.styles.background?.images?.dark
|
|
336
|
-
? `url('${config.styles.background.images.dark}')`
|
|
342
|
+
? `url('${siteHref(config.styles.background.images.dark)}')`
|
|
337
343
|
: "none";
|
|
338
344
|
// A logo is either one path used for both modes, or a {light, dark,
|
|
339
345
|
// label} object - normalized to a single light/dark pair here (the one
|
|
@@ -451,10 +457,13 @@ const wdFontFamilyBody = resolvedFonts.body ? fontStack(resolvedFonts.body.famil
|
|
|
451
457
|
// descriptor, or the Google Fonts URL's `:wght@` axis inside
|
|
452
458
|
// googleFontsHref() above), not the actual rendered boldness of any
|
|
453
459
|
// element - see wdFontWeightCss right below for that other half.
|
|
460
|
+
// A `source` in the project is a site address: it gets the basePath.
|
|
461
|
+
const withSourceBase = <T extends { source?: string } | null>(font: T): T =>
|
|
462
|
+
font?.source ? { ...font, source: siteHref(font.source) } : font;
|
|
454
463
|
const fontFaceCss = [
|
|
455
|
-
fontFaceRule(resolvedFonts.base),
|
|
456
|
-
fontFaceRule(resolvedFonts.heading),
|
|
457
|
-
fontFaceRule(resolvedFonts.body),
|
|
464
|
+
fontFaceRule(withSourceBase(resolvedFonts.base)),
|
|
465
|
+
fontFaceRule(withSourceBase(resolvedFonts.heading)),
|
|
466
|
+
fontFaceRule(withSourceBase(resolvedFonts.body)),
|
|
458
467
|
]
|
|
459
468
|
.filter(Boolean)
|
|
460
469
|
.join("\n");
|
|
@@ -506,7 +515,7 @@ const fontExtraCss = [fontFaceCss, fontFallbackCss, fontWeightCss].filter(Boolea
|
|
|
506
515
|
),
|
|
507
516
|
)
|
|
508
517
|
}
|
|
509
|
-
{config.styles.favicon && <link rel="icon" href={config.styles.favicon} />}
|
|
518
|
+
{config.styles.favicon && <link rel="icon" href={siteHref(config.styles.favicon)} />}
|
|
510
519
|
{
|
|
511
520
|
/* styles.fonts - see resolveFonts()/googleFontsHref() in lib/config.ts.
|
|
512
521
|
Present (non-null) whenever at least one configured font (or the
|
|
@@ -726,7 +735,7 @@ const fontExtraCss = [fontFaceCss, fontFallbackCss, fontWeightCss].filter(Boolea
|
|
|
726
735
|
{
|
|
727
736
|
config.scripts.head
|
|
728
737
|
.filter((s) => !gated(s))
|
|
729
|
-
.map((s) => (s.src ? <script is:inline src={s.src} /> : <script is:inline set:html={s.content} />))
|
|
738
|
+
.map((s) => (s.src ? <script is:inline src={siteHref(s.src)} /> : <script is:inline set:html={s.content} />))
|
|
730
739
|
}
|
|
731
740
|
{
|
|
732
741
|
/* Zero-config custom CSS - see findRootAssets() in lib/pages.js and
|
|
@@ -747,7 +756,7 @@ const fontExtraCss = [fontFaceCss, fontFallbackCss, fontWeightCss].filter(Boolea
|
|
|
747
756
|
pointing at their already-public URL instead of joining
|
|
748
757
|
rootCssContents above as inlined content. */
|
|
749
758
|
}
|
|
750
|
-
{publicCssHrefs.map((href) => <link rel="stylesheet" href={href} />)}
|
|
759
|
+
{publicCssHrefs.map((href) => <link rel="stylesheet" href={siteHref(href)} />)}
|
|
751
760
|
</head>
|
|
752
761
|
<body>
|
|
753
762
|
{
|
|
@@ -861,7 +870,7 @@ const fontExtraCss = [fontFaceCss, fontFallbackCss, fontWeightCss].filter(Boolea
|
|
|
861
870
|
{
|
|
862
871
|
config.scripts.body
|
|
863
872
|
.filter((s) => !gated(s))
|
|
864
|
-
.map((s) => (s.src ? <script is:inline src={s.src} /> : <script is:inline set:html={s.content} />))
|
|
873
|
+
.map((s) => (s.src ? <script is:inline src={siteHref(s.src)} /> : <script is:inline set:html={s.content} />))
|
|
865
874
|
}
|
|
866
875
|
{
|
|
867
876
|
/* Zero-config custom JS - see findRootAssets() in lib/pages.js and
|
|
@@ -889,7 +898,7 @@ const fontExtraCss = [fontFaceCss, fontFallbackCss, fontWeightCss].filter(Boolea
|
|
|
889
898
|
the more common spot for a plain local script and this hasn't come
|
|
890
899
|
up in practice). */
|
|
891
900
|
}
|
|
892
|
-
{publicJsHrefs.map((href) => <script is:inline src={href} />)}
|
|
901
|
+
{publicJsHrefs.map((href) => <script is:inline src={siteHref(href)} />)}
|
|
893
902
|
{
|
|
894
903
|
/* writedocs.json's `integrations.askAi` - see AskAiWidget.astro. Rendered
|
|
895
904
|
last of all - it's a floating chat widget, not something anything
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
// it doesn't wait for consent.
|
|
23
23
|
import type { DocsConfig } from '../../lib/config';
|
|
24
24
|
import { analyticsTags, scriptTags, consentLoaderScript } from '../../lib/consent.js';
|
|
25
|
+
import { siteHref } from '../../lib/site-base';
|
|
25
26
|
|
|
26
27
|
interface Props {
|
|
27
28
|
config: DocsConfig;
|
|
@@ -33,8 +34,11 @@ interface Props {
|
|
|
33
34
|
}
|
|
34
35
|
const { config, consent = null, gatedScripts = [] } = Astro.props as Props;
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
38
42
|
---
|
|
39
43
|
{loader ? (
|
|
40
44
|
<script is:inline set:html={loader} />
|