@writedocs/generator 0.10.20 → 0.11.0
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 +1 -1
- package/src/cli/base-path-layout.js +44 -0
- package/src/cli/build.js +177 -168
- package/src/cli/check-built-styles.js +41 -33
- package/src/cli/dev.js +261 -244
- 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 +241 -237
- package/writedocs.schema.json +6 -0
package/src/lib/wdignore.js
CHANGED
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
// Which of a project's files are left out: never published, never read as
|
|
2
|
-
// content. Three layers, in this order:
|
|
3
|
-
//
|
|
4
|
-
// LOCKED_PATTERNS - secrets. Always left out; no `.wdignore` line brings
|
|
5
|
-
// one back.
|
|
6
|
-
// DEFAULT_PATTERNS - tooling and data that a docs repository holds but a
|
|
7
|
-
// site rarely means to publish. Left out unless the
|
|
8
|
-
// project's `.wdignore` re-includes them with `!`.
|
|
9
|
-
// the project's `.wdignore` - its own patterns, in .gitignore syntax.
|
|
10
|
-
//
|
|
11
|
-
// Files under the top-level `public/` folder are the exception to the
|
|
12
|
-
// second layer: putting a file there is already saying "publish this", so
|
|
13
|
-
// only LOCKED_PATTERNS and the project's own `.wdignore` apply to them
|
|
14
|
-
// (`public/.well-known/security.txt` is published; `public/.env` is not).
|
|
15
|
-
//
|
|
16
|
-
// THIS FILE IS A CONTRACT. The WriteDocs platform imports it
|
|
17
|
-
// (`@writedocs/generator/wdignore`) and applies the same rules when it
|
|
18
|
-
// syncs a project, so a `.env` never reaches its storage. It runs in a
|
|
19
|
-
// Cloudflare Worker there: nothing from Node (`fs`, `path`, `process`,
|
|
20
|
-
// `Buffer`) may be imported or used here - only `ignore`, which is plain
|
|
21
|
-
// JavaScript. It takes paths and the text of `.wdignore`; whoever calls it
|
|
22
|
-
// does the reading. scripts/wdignore.test.js bundles it for a browser to
|
|
23
|
-
// prove it, and runs every case in wdignore-cases.json, which the platform
|
|
24
|
-
// runs too.
|
|
25
|
-
//
|
|
26
|
-
// The two lists below are the only place the default exclusions are
|
|
27
|
-
// written. The docs (site/ and docs/dev/) describe them; nothing else
|
|
28
|
-
// repeats them.
|
|
29
|
-
import ignore from 'ignore';
|
|
30
|
-
|
|
31
|
-
/** The project's own ignore file, at its root. */
|
|
32
|
-
export const WDIGNORE_FILE = '.wdignore';
|
|
33
|
-
|
|
34
|
-
/** Never published and never synced, whatever `.wdignore` says. */
|
|
35
|
-
export const LOCKED_PATTERNS = [
|
|
36
|
-
// Environment files: API keys and passwords.
|
|
37
|
-
'.env',
|
|
38
|
-
'.env.*',
|
|
39
|
-
// The repository's own history.
|
|
40
|
-
'.git/',
|
|
41
|
-
// npm's configuration, which can hold a registry token.
|
|
42
|
-
'.npmrc',
|
|
43
|
-
// Private keys and the containers that hold them.
|
|
44
|
-
'*.pem',
|
|
45
|
-
'*.key',
|
|
46
|
-
'*.p12',
|
|
47
|
-
'*.pfx',
|
|
48
|
-
'id_rsa*',
|
|
49
|
-
'id_dsa*',
|
|
50
|
-
'id_ecdsa*',
|
|
51
|
-
'id_ed25519*',
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
/** Left out by default; a `.wdignore` line starting with `!` brings one back. */
|
|
55
|
-
export const DEFAULT_PATTERNS = [
|
|
56
|
-
// Every file and folder whose name starts with a dot: .gitignore,
|
|
57
|
-
// .gitmodules, .gitattributes, .github/, .vscode/, .DS_Store, .wdignore,
|
|
58
|
-
// .writedocs/ ...
|
|
59
|
-
'.*',
|
|
60
|
-
// Package manifests and lockfiles.
|
|
61
|
-
'package.json',
|
|
62
|
-
'package-lock.json',
|
|
63
|
-
'yarn.lock',
|
|
64
|
-
'pnpm-lock.yaml',
|
|
65
|
-
'bun.lockb',
|
|
66
|
-
'bun.lock',
|
|
67
|
-
'composer.json',
|
|
68
|
-
'composer.lock',
|
|
69
|
-
// Dependencies and build output, at any depth.
|
|
70
|
-
'node_modules/',
|
|
71
|
-
'dist/',
|
|
72
|
-
// Tooling and hosting configuration.
|
|
73
|
-
'tsconfig.json',
|
|
74
|
-
'jsconfig.json',
|
|
75
|
-
'vercel.json',
|
|
76
|
-
'netlify.json',
|
|
77
|
-
'netlify.toml',
|
|
78
|
-
'wrangler.json',
|
|
79
|
-
'wrangler.jsonc',
|
|
80
|
-
'wrangler.toml',
|
|
81
|
-
'Dockerfile',
|
|
82
|
-
'docker-compose*.yml',
|
|
83
|
-
'docker-compose*.yaml',
|
|
84
|
-
// Certificates and key stores.
|
|
85
|
-
'*.crt',
|
|
86
|
-
'*.jks',
|
|
87
|
-
'*.keystore',
|
|
88
|
-
// Databases and dumps.
|
|
89
|
-
'*.sqlite',
|
|
90
|
-
'*.sqlite3',
|
|
91
|
-
'*.db',
|
|
92
|
-
'*.sql',
|
|
93
|
-
// Logs.
|
|
94
|
-
'*.log',
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
/** Paths that are left out of the site (the patterns above match them) but
|
|
98
|
-
* that the build reads. A sync that drops ignored files must still deliver
|
|
99
|
-
* these, or the build runs with different rules than the sync did. */
|
|
100
|
-
export const BUILD_INPUT_PATHS = ['.wdignore', '.mintignore', '.writedocs/asset-dimensions.json'];
|
|
101
|
-
|
|
102
|
-
/** The top-level folder whose files skip DEFAULT_PATTERNS. */
|
|
103
|
-
const PUBLIC_DIR = 'public';
|
|
104
|
-
|
|
105
|
-
function clean(text) {
|
|
106
|
-
return typeof text === 'string' ? text.replace(
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** A project-relative POSIX path ("docs/a.pdf", no leading slash) with any
|
|
110
|
-
* trailing slash removed, or null when it isn't one: empty, absolute,
|
|
111
|
-
* with a backslash, or with a `.`/`..` segment. */
|
|
112
|
-
function normalize(relPath) {
|
|
113
|
-
if (typeof relPath !== 'string') return null;
|
|
114
|
-
const trimmed = relPath.replace(/\/+$/, '');
|
|
115
|
-
if (!trimmed || trimmed.startsWith('/') || trimmed.includes('\\')) return null;
|
|
116
|
-
if (trimmed.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')) return null;
|
|
117
|
-
return trimmed;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** The rules for one project. `text` is the content of its `.wdignore`
|
|
121
|
-
* ('' or undefined when it has none).
|
|
122
|
-
*
|
|
123
|
-
* `ignores(relPath, isDirectory)` says whether a path is left out.
|
|
124
|
-
* `relPath` is a POSIX path from the project root, with no leading slash;
|
|
125
|
-
* pass `isDirectory` as true for a folder (a pattern ending in `/` only
|
|
126
|
-
* matches folders). A path inside an ignored folder is ignored. A path
|
|
127
|
-
* that isn't a valid project-relative path is ignored too - the safe
|
|
128
|
-
* answer. Matching ignores letter case, as it does on the file systems
|
|
129
|
-
* most projects are written on.
|
|
130
|
-
*
|
|
131
|
-
* `isLocked(relPath, isDirectory)` says whether LOCKED_PATTERNS is the
|
|
132
|
-
* reason - a path `.wdignore` can't bring back. */
|
|
133
|
-
export function createWdignore(text = '') {
|
|
134
|
-
const own = clean(text);
|
|
135
|
-
const locked = ignore().add(LOCKED_PATTERNS);
|
|
136
|
-
const everywhere = ignore().add(DEFAULT_PATTERNS).add(own);
|
|
137
|
-
const inPublic = ignore().add(own);
|
|
138
|
-
|
|
139
|
-
const target = (relPath, isDirectory) => {
|
|
140
|
-
const normal = normalize(relPath);
|
|
141
|
-
return normal === null ? null : isDirectory ? `${normal}/` : normal;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
ignores(relPath, isDirectory = false) {
|
|
146
|
-
const p = target(relPath, isDirectory);
|
|
147
|
-
if (p === null) return true;
|
|
148
|
-
if (locked.ignores(p)) return true;
|
|
149
|
-
const underPublic = p.toLowerCase().startsWith(`${PUBLIC_DIR}/`);
|
|
150
|
-
return (underPublic ? inPublic : everywhere).ignores(p);
|
|
151
|
-
},
|
|
152
|
-
isLocked(relPath, isDirectory = false) {
|
|
153
|
-
const p = target(relPath, isDirectory);
|
|
154
|
-
return p !== null && locked.ignores(p);
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** Splits a list of file paths by the rules: `kept` are the files a sync
|
|
160
|
-
* delivers and a build may publish; `ignored` are left out. `buildInputs`
|
|
161
|
-
* are the ignored ones the build still has to receive (BUILD_INPUT_PATHS).
|
|
162
|
-
* Every list keeps the order of `paths`. */
|
|
163
|
-
export function partitionPaths(paths, text = '') {
|
|
164
|
-
const rules = createWdignore(text);
|
|
165
|
-
const inputs = new Set(BUILD_INPUT_PATHS);
|
|
166
|
-
const kept = [];
|
|
167
|
-
const ignored = [];
|
|
168
|
-
const buildInputs = [];
|
|
169
|
-
for (const p of paths) {
|
|
170
|
-
if (!rules.ignores(p)) kept.push(p);
|
|
171
|
-
else {
|
|
172
|
-
ignored.push(p);
|
|
173
|
-
if (inputs.has(p)) buildInputs.push(p);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return { kept, ignored, buildInputs };
|
|
177
|
-
}
|
|
1
|
+
// Which of a project's files are left out: never published, never read as
|
|
2
|
+
// content. Three layers, in this order:
|
|
3
|
+
//
|
|
4
|
+
// LOCKED_PATTERNS - secrets. Always left out; no `.wdignore` line brings
|
|
5
|
+
// one back.
|
|
6
|
+
// DEFAULT_PATTERNS - tooling and data that a docs repository holds but a
|
|
7
|
+
// site rarely means to publish. Left out unless the
|
|
8
|
+
// project's `.wdignore` re-includes them with `!`.
|
|
9
|
+
// the project's `.wdignore` - its own patterns, in .gitignore syntax.
|
|
10
|
+
//
|
|
11
|
+
// Files under the top-level `public/` folder are the exception to the
|
|
12
|
+
// second layer: putting a file there is already saying "publish this", so
|
|
13
|
+
// only LOCKED_PATTERNS and the project's own `.wdignore` apply to them
|
|
14
|
+
// (`public/.well-known/security.txt` is published; `public/.env` is not).
|
|
15
|
+
//
|
|
16
|
+
// THIS FILE IS A CONTRACT. The WriteDocs platform imports it
|
|
17
|
+
// (`@writedocs/generator/wdignore`) and applies the same rules when it
|
|
18
|
+
// syncs a project, so a `.env` never reaches its storage. It runs in a
|
|
19
|
+
// Cloudflare Worker there: nothing from Node (`fs`, `path`, `process`,
|
|
20
|
+
// `Buffer`) may be imported or used here - only `ignore`, which is plain
|
|
21
|
+
// JavaScript. It takes paths and the text of `.wdignore`; whoever calls it
|
|
22
|
+
// does the reading. scripts/wdignore.test.js bundles it for a browser to
|
|
23
|
+
// prove it, and runs every case in wdignore-cases.json, which the platform
|
|
24
|
+
// runs too.
|
|
25
|
+
//
|
|
26
|
+
// The two lists below are the only place the default exclusions are
|
|
27
|
+
// written. The docs (site/ and docs/dev/) describe them; nothing else
|
|
28
|
+
// repeats them.
|
|
29
|
+
import ignore from 'ignore';
|
|
30
|
+
|
|
31
|
+
/** The project's own ignore file, at its root. */
|
|
32
|
+
export const WDIGNORE_FILE = '.wdignore';
|
|
33
|
+
|
|
34
|
+
/** Never published and never synced, whatever `.wdignore` says. */
|
|
35
|
+
export const LOCKED_PATTERNS = [
|
|
36
|
+
// Environment files: API keys and passwords.
|
|
37
|
+
'.env',
|
|
38
|
+
'.env.*',
|
|
39
|
+
// The repository's own history.
|
|
40
|
+
'.git/',
|
|
41
|
+
// npm's configuration, which can hold a registry token.
|
|
42
|
+
'.npmrc',
|
|
43
|
+
// Private keys and the containers that hold them.
|
|
44
|
+
'*.pem',
|
|
45
|
+
'*.key',
|
|
46
|
+
'*.p12',
|
|
47
|
+
'*.pfx',
|
|
48
|
+
'id_rsa*',
|
|
49
|
+
'id_dsa*',
|
|
50
|
+
'id_ecdsa*',
|
|
51
|
+
'id_ed25519*',
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
/** Left out by default; a `.wdignore` line starting with `!` brings one back. */
|
|
55
|
+
export const DEFAULT_PATTERNS = [
|
|
56
|
+
// Every file and folder whose name starts with a dot: .gitignore,
|
|
57
|
+
// .gitmodules, .gitattributes, .github/, .vscode/, .DS_Store, .wdignore,
|
|
58
|
+
// .writedocs/ ...
|
|
59
|
+
'.*',
|
|
60
|
+
// Package manifests and lockfiles.
|
|
61
|
+
'package.json',
|
|
62
|
+
'package-lock.json',
|
|
63
|
+
'yarn.lock',
|
|
64
|
+
'pnpm-lock.yaml',
|
|
65
|
+
'bun.lockb',
|
|
66
|
+
'bun.lock',
|
|
67
|
+
'composer.json',
|
|
68
|
+
'composer.lock',
|
|
69
|
+
// Dependencies and build output, at any depth.
|
|
70
|
+
'node_modules/',
|
|
71
|
+
'dist/',
|
|
72
|
+
// Tooling and hosting configuration.
|
|
73
|
+
'tsconfig.json',
|
|
74
|
+
'jsconfig.json',
|
|
75
|
+
'vercel.json',
|
|
76
|
+
'netlify.json',
|
|
77
|
+
'netlify.toml',
|
|
78
|
+
'wrangler.json',
|
|
79
|
+
'wrangler.jsonc',
|
|
80
|
+
'wrangler.toml',
|
|
81
|
+
'Dockerfile',
|
|
82
|
+
'docker-compose*.yml',
|
|
83
|
+
'docker-compose*.yaml',
|
|
84
|
+
// Certificates and key stores.
|
|
85
|
+
'*.crt',
|
|
86
|
+
'*.jks',
|
|
87
|
+
'*.keystore',
|
|
88
|
+
// Databases and dumps.
|
|
89
|
+
'*.sqlite',
|
|
90
|
+
'*.sqlite3',
|
|
91
|
+
'*.db',
|
|
92
|
+
'*.sql',
|
|
93
|
+
// Logs.
|
|
94
|
+
'*.log',
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
/** Paths that are left out of the site (the patterns above match them) but
|
|
98
|
+
* that the build reads. A sync that drops ignored files must still deliver
|
|
99
|
+
* these, or the build runs with different rules than the sync did. */
|
|
100
|
+
export const BUILD_INPUT_PATHS = ['.wdignore', '.mintignore', '.writedocs/asset-dimensions.json'];
|
|
101
|
+
|
|
102
|
+
/** The top-level folder whose files skip DEFAULT_PATTERNS. */
|
|
103
|
+
const PUBLIC_DIR = 'public';
|
|
104
|
+
|
|
105
|
+
function clean(text) {
|
|
106
|
+
return typeof text === 'string' ? text.replace(/^\uFEFF/, '') : '';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A project-relative POSIX path ("docs/a.pdf", no leading slash) with any
|
|
110
|
+
* trailing slash removed, or null when it isn't one: empty, absolute,
|
|
111
|
+
* with a backslash, or with a `.`/`..` segment. */
|
|
112
|
+
function normalize(relPath) {
|
|
113
|
+
if (typeof relPath !== 'string') return null;
|
|
114
|
+
const trimmed = relPath.replace(/\/+$/, '');
|
|
115
|
+
if (!trimmed || trimmed.startsWith('/') || trimmed.includes('\\')) return null;
|
|
116
|
+
if (trimmed.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')) return null;
|
|
117
|
+
return trimmed;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The rules for one project. `text` is the content of its `.wdignore`
|
|
121
|
+
* ('' or undefined when it has none).
|
|
122
|
+
*
|
|
123
|
+
* `ignores(relPath, isDirectory)` says whether a path is left out.
|
|
124
|
+
* `relPath` is a POSIX path from the project root, with no leading slash;
|
|
125
|
+
* pass `isDirectory` as true for a folder (a pattern ending in `/` only
|
|
126
|
+
* matches folders). A path inside an ignored folder is ignored. A path
|
|
127
|
+
* that isn't a valid project-relative path is ignored too - the safe
|
|
128
|
+
* answer. Matching ignores letter case, as it does on the file systems
|
|
129
|
+
* most projects are written on.
|
|
130
|
+
*
|
|
131
|
+
* `isLocked(relPath, isDirectory)` says whether LOCKED_PATTERNS is the
|
|
132
|
+
* reason - a path `.wdignore` can't bring back. */
|
|
133
|
+
export function createWdignore(text = '') {
|
|
134
|
+
const own = clean(text);
|
|
135
|
+
const locked = ignore().add(LOCKED_PATTERNS);
|
|
136
|
+
const everywhere = ignore().add(DEFAULT_PATTERNS).add(own);
|
|
137
|
+
const inPublic = ignore().add(own);
|
|
138
|
+
|
|
139
|
+
const target = (relPath, isDirectory) => {
|
|
140
|
+
const normal = normalize(relPath);
|
|
141
|
+
return normal === null ? null : isDirectory ? `${normal}/` : normal;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
ignores(relPath, isDirectory = false) {
|
|
146
|
+
const p = target(relPath, isDirectory);
|
|
147
|
+
if (p === null) return true;
|
|
148
|
+
if (locked.ignores(p)) return true;
|
|
149
|
+
const underPublic = p.toLowerCase().startsWith(`${PUBLIC_DIR}/`);
|
|
150
|
+
return (underPublic ? inPublic : everywhere).ignores(p);
|
|
151
|
+
},
|
|
152
|
+
isLocked(relPath, isDirectory = false) {
|
|
153
|
+
const p = target(relPath, isDirectory);
|
|
154
|
+
return p !== null && locked.ignores(p);
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Splits a list of file paths by the rules: `kept` are the files a sync
|
|
160
|
+
* delivers and a build may publish; `ignored` are left out. `buildInputs`
|
|
161
|
+
* are the ignored ones the build still has to receive (BUILD_INPUT_PATHS).
|
|
162
|
+
* Every list keeps the order of `paths`. */
|
|
163
|
+
export function partitionPaths(paths, text = '') {
|
|
164
|
+
const rules = createWdignore(text);
|
|
165
|
+
const inputs = new Set(BUILD_INPUT_PATHS);
|
|
166
|
+
const kept = [];
|
|
167
|
+
const ignored = [];
|
|
168
|
+
const buildInputs = [];
|
|
169
|
+
for (const p of paths) {
|
|
170
|
+
if (!rules.ignores(p)) kept.push(p);
|
|
171
|
+
else {
|
|
172
|
+
ignored.push(p);
|
|
173
|
+
if (inputs.has(p)) buildInputs.push(p);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return { kept, ignored, buildInputs };
|
|
177
|
+
}
|
package/src/pages/404.astro
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
---
|
|
2
|
-
// Astro's own file-based convention: a static build (`output: 'static'`,
|
|
3
|
-
// this package's only supported mode - see astro.config.mjs) emits this
|
|
4
|
-
// file's output as a literal `404.html` at the site root, and most static
|
|
5
|
-
// hosts (Netlify, Vercel, GitHub Pages, Cloudflare Pages, ...) serve it
|
|
6
|
-
// automatically for any unmatched path. No params, no getStaticPaths -
|
|
7
|
-
// this is a single fixed route, same category as llms.txt.ts/
|
|
8
|
-
// llms-full.txt.ts (see their own comments on Astro auto-prerendering a
|
|
9
|
-
// non-dynamic page at its literal path).
|
|
10
|
-
import { loadDocsConfig } from '../lib/config';
|
|
11
|
-
import BaseLayout from '../layout/BaseLayout.astro';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
</
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
font-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
---
|
|
2
|
+
// Astro's own file-based convention: a static build (`output: 'static'`,
|
|
3
|
+
// this package's only supported mode - see astro.config.mjs) emits this
|
|
4
|
+
// file's output as a literal `404.html` at the site root, and most static
|
|
5
|
+
// hosts (Netlify, Vercel, GitHub Pages, Cloudflare Pages, ...) serve it
|
|
6
|
+
// automatically for any unmatched path. No params, no getStaticPaths -
|
|
7
|
+
// this is a single fixed route, same category as llms.txt.ts/
|
|
8
|
+
// llms-full.txt.ts (see their own comments on Astro auto-prerendering a
|
|
9
|
+
// non-dynamic page at its literal path).
|
|
10
|
+
import { loadDocsConfig } from '../lib/config';
|
|
11
|
+
import BaseLayout from '../layout/BaseLayout.astro';
|
|
12
|
+
import { siteHref } from '../lib/site-base';
|
|
13
|
+
|
|
14
|
+
const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
|
|
15
|
+
const config = loadDocsConfig(contentDir);
|
|
16
|
+
|
|
17
|
+
// writedocs.json's `notFound.{title,description}` (notFoundSchema in
|
|
18
|
+
// lib/config.ts) - both optional, with the hardcoded fallbacks below, so
|
|
19
|
+
// a site gets a reasonably branded 404 page without having to configure
|
|
20
|
+
// anything.
|
|
21
|
+
const title = config.notFound.title ?? 'Page not found';
|
|
22
|
+
const description = config.notFound.description ?? "The page you're looking for doesn't exist or has moved.";
|
|
23
|
+
---
|
|
24
|
+
<BaseLayout config={config} title={title} description={description} path="/404/" seo={{ noindex: true }} mode="frame">
|
|
25
|
+
<div class="wd-404">
|
|
26
|
+
<p class="wd-404-eyebrow">404</p>
|
|
27
|
+
<h1>{title}</h1>
|
|
28
|
+
<p class="wd-404-description">{description}</p>
|
|
29
|
+
<a class="wd-404-home" href={siteHref("/")}>← Back to home</a>
|
|
30
|
+
</div>
|
|
31
|
+
</BaseLayout>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.wd-404 {
|
|
35
|
+
max-width: 560px;
|
|
36
|
+
margin: 0 auto;
|
|
37
|
+
padding: 5rem 1.5rem 6rem;
|
|
38
|
+
text-align: center;
|
|
39
|
+
}
|
|
40
|
+
.wd-404-eyebrow {
|
|
41
|
+
margin: 0 0 0.5rem;
|
|
42
|
+
font-size: 0.85rem;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
letter-spacing: 0.08em;
|
|
45
|
+
color: var(--wd-primary);
|
|
46
|
+
}
|
|
47
|
+
.wd-404 h1 {
|
|
48
|
+
margin: 0 0 0.75rem;
|
|
49
|
+
font-size: 1.75rem;
|
|
50
|
+
}
|
|
51
|
+
.wd-404-description {
|
|
52
|
+
margin: 0 0 2rem;
|
|
53
|
+
color: var(--wd-text-muted);
|
|
54
|
+
}
|
|
55
|
+
.wd-404-home {
|
|
56
|
+
color: var(--wd-primary);
|
|
57
|
+
text-decoration: none;
|
|
58
|
+
font-weight: 500;
|
|
59
|
+
}
|
|
60
|
+
.wd-404-home:hover {
|
|
61
|
+
text-decoration: underline;
|
|
62
|
+
}
|
|
63
|
+
</style>
|