@writedocs/generator 0.13.5 → 0.14.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/bin/writedocs.js +4 -1
- package/package.json +1 -1
- package/src/cli/build.js +23 -3
- package/src/cli/dev.js +2 -1
- package/src/cli/generate-api-pages.js +9 -7
- package/src/cli/page-list-watch.js +4 -2
- package/src/cli/run-astro.js +1 -1
- package/src/content.config.ts +16 -0
- package/src/layout/components/NavTree.astro +14 -0
- package/src/lib/config-schema.js +12 -1
- package/src/lib/config-schema.ts +14 -0
- package/src/lib/config.ts +18 -3
- package/src/lib/content-check.js +4 -1
- package/src/lib/drafts.js +186 -0
- package/src/lib/link-check.js +11 -2
- package/src/lib/pages.js +40 -6
- package/src/lib/seo-tags.js +3 -1
- package/src/pages/[...slug].astro +12 -1
package/bin/writedocs.js
CHANGED
|
@@ -90,6 +90,9 @@ program
|
|
|
90
90
|
.argument('[dir]', 'content directory (contains writedocs.json and docs/)', '.')
|
|
91
91
|
.option('-k, --key <key>', 'build authorization key (or set WRITEDOCS_API_KEY)')
|
|
92
92
|
.option('--verbose', "also print Astro's and Vite's own output")
|
|
93
|
+
// A preview of the drafts (src/lib/drafts.js): included, marked and
|
|
94
|
+
// noindex, out of the sitemap, llms.txt and the MCP index.
|
|
95
|
+
.option('--drafts', 'include draft pages (draft: true), marked and noindex')
|
|
93
96
|
.action(async (dir, opts) => {
|
|
94
97
|
const contentDir = canonicalPath(path.resolve(process.cwd(), dir));
|
|
95
98
|
// Project-scoped, not global: a .env sitting next to this project's own
|
|
@@ -99,7 +102,7 @@ program
|
|
|
99
102
|
// environment - an explicit `export`/CI secret still wins over the file.
|
|
100
103
|
dotenv.config({ path: path.join(contentDir, '.env'), quiet: true });
|
|
101
104
|
await requireBuildKey(opts.key || process.env.WRITEDOCS_API_KEY);
|
|
102
|
-
await runBuild({ contentDir, packageRoot, verbose: Boolean(opts.verbose) });
|
|
105
|
+
await runBuild({ contentDir, packageRoot, verbose: Boolean(opts.verbose), drafts: Boolean(opts.drafts) });
|
|
103
106
|
});
|
|
104
107
|
|
|
105
108
|
program
|
package/package.json
CHANGED
package/src/cli/build.js
CHANGED
|
@@ -17,8 +17,14 @@ import { siteDirFor, moveRootFiles } from './base-path-layout.js';
|
|
|
17
17
|
import { log, step, plural, duration, displayPath, formatProblems, color, CliExit } from './output.js';
|
|
18
18
|
import { describeError, builtRoute, authorWarning, verboseLine } from './astro-output.js';
|
|
19
19
|
import { reportApiPages } from './api-pages-output.js';
|
|
20
|
+
import { findDraftPages } from '../lib/pages.js';
|
|
21
|
+
import { draftWarnings } from '../lib/drafts.js';
|
|
22
|
+
import { createJsonLocator } from '../lib/config-schema.js';
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
/** `drafts` (`writedocs build --drafts`): draft pages are part of the site -
|
|
25
|
+
* marked, noindex, out of the sitemap, llms.txt and the MCP index, the way
|
|
26
|
+
* `writedocs dev` shows them (lib/drafts.js). Without it they're left out. */
|
|
27
|
+
export async function runBuild({ contentDir, packageRoot, verbose = false, drafts = false }) {
|
|
22
28
|
// One spelling of each folder throughout - see lib/canonical-path.js.
|
|
23
29
|
contentDir = canonicalPath(contentDir);
|
|
24
30
|
packageRoot = canonicalPath(packageRoot);
|
|
@@ -38,10 +44,22 @@ export async function runBuild({ contentDir, packageRoot, verbose = false }) {
|
|
|
38
44
|
warnings.push({ where, message });
|
|
39
45
|
};
|
|
40
46
|
|
|
41
|
-
const api = await generateApiPages({ contentDir });
|
|
47
|
+
const api = await generateApiPages({ contentDir, drafts });
|
|
42
48
|
sameDriveCheck(contentDir, packageRoot, { generatedPages: api.groups.length > 0 });
|
|
43
49
|
reportApiPages(api);
|
|
44
50
|
api.warnings.forEach((message) => addWarning(null, message));
|
|
51
|
+
// The draft pages the build leaves out (lib/drafts.js) - and what that
|
|
52
|
+
// took out of the navigation, or leaves a redirect or "/" pointing at.
|
|
53
|
+
// With --drafts, only how many it kept.
|
|
54
|
+
const draftPages = findDraftPages(contentDir);
|
|
55
|
+
if (drafts) {
|
|
56
|
+
if (draftPages.length) notes.push(`${plural(draftPages.length, 'draft page')} built (--drafts): marked, noindex, and out of the sitemap, llms.txt and the MCP index.`);
|
|
57
|
+
} else {
|
|
58
|
+
const configText = readConfigText(contentDir);
|
|
59
|
+
const drafted = draftWarnings({ configText, drafts: draftPages, locate: createJsonLocator(configText) });
|
|
60
|
+
drafted.warnings.forEach(({ where, message }) => addWarning(where, message));
|
|
61
|
+
notes.push(...drafted.notes);
|
|
62
|
+
}
|
|
45
63
|
|
|
46
64
|
const building = step('Building pages');
|
|
47
65
|
const buildStarted = Date.now();
|
|
@@ -57,7 +75,9 @@ export async function runBuild({ contentDir, packageRoot, verbose = false }) {
|
|
|
57
75
|
const { exited } = runAstro('build', {
|
|
58
76
|
packageRoot,
|
|
59
77
|
contentDir,
|
|
60
|
-
|
|
78
|
+
// WRITEDOCS_DRAFTS: draftsIncluded() in lib/pages.js - set either way, so
|
|
79
|
+
// one left in the shell's environment can't decide it.
|
|
80
|
+
env: { WRITEDOCS_OG_CARDS_FILE: ogCardsFile, WRITEDOCS_DRAFTS: drafts ? '1' : '' },
|
|
61
81
|
onEvent(event) {
|
|
62
82
|
if (verbose) {
|
|
63
83
|
const line = verboseLine(event);
|
package/src/cli/dev.js
CHANGED
|
@@ -52,7 +52,8 @@ export async function runDev({ contentDir, packageRoot, port, verbose = false, o
|
|
|
52
52
|
writeLock(packageRoot, { contentDir, url: null });
|
|
53
53
|
process.on('exit', () => removeLock(packageRoot));
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// Draft pages are pages in the preview (lib/drafts.js).
|
|
56
|
+
const api = await generateApiPages({ contentDir, drafts: true });
|
|
56
57
|
sameDriveCheck(contentDir, packageRoot, { generatedPages: api.groups.length > 0 });
|
|
57
58
|
reportApiPages(api);
|
|
58
59
|
api.warnings.forEach((message) => log.warn(message));
|
|
@@ -339,8 +339,8 @@ async function generateApiPagesForGroup({ contentDir, generatedDocsDir, group, o
|
|
|
339
339
|
* warnings: [message], sources: [every local spec file read, $refs
|
|
340
340
|
* included], written: [paths], removed: [paths] }.
|
|
341
341
|
*/
|
|
342
|
-
export async function generateApiPages({ contentDir, keepEmptyFolders = false }) {
|
|
343
|
-
const { summary, files, roots } = await planApiPages({ contentDir });
|
|
342
|
+
export async function generateApiPages({ contentDir, keepEmptyFolders = false, drafts }) {
|
|
343
|
+
const { summary, files, roots } = await planApiPages({ contentDir, drafts });
|
|
344
344
|
const { written, removed } = writeGeneratedFiles(roots, files, { keepEmptyFolders });
|
|
345
345
|
return { ...summary, written, removed };
|
|
346
346
|
}
|
|
@@ -348,8 +348,10 @@ export async function generateApiPages({ contentDir, keepEmptyFolders = false })
|
|
|
348
348
|
/** Everything generateApiPages() would write, without writing it:
|
|
349
349
|
* `{ summary, files, roots }` - `files` maps each absolute path to its
|
|
350
350
|
* content, `roots` are the two folders it owns (generated-docs/ first).
|
|
351
|
-
* `writedocs dev` writes it in two steps (lib/openapi-reload-integration.js).
|
|
352
|
-
|
|
351
|
+
* `writedocs dev` writes it in two steps (lib/openapi-reload-integration.js).
|
|
352
|
+
* `drafts`: whether draft pages are pages (findAllPages()) - the specs they
|
|
353
|
+
* name are parsed then; by default, as draftsIncluded() says. */
|
|
354
|
+
export async function planApiPages({ contentDir, drafts }) {
|
|
353
355
|
const summary = { groups: [], pageSpecs: [], warnings: [], sources: [] };
|
|
354
356
|
const generatedDocsDir = path.join(writedocsTempDir(contentDir), 'generated-docs');
|
|
355
357
|
const openapiOutDir = path.join(writedocsTempDir(contentDir), 'openapi');
|
|
@@ -394,7 +396,7 @@ export async function planApiPages({ contentDir }) {
|
|
|
394
396
|
if (moved.length) files.set(movedApiPagesFile(contentDir), JSON.stringify(moved, null, 2));
|
|
395
397
|
|
|
396
398
|
const groupSpecs = groups.map((g) => path.resolve(contentDir, g.openapi.src));
|
|
397
|
-
const pageSpecs = await parsePageSpecs({ contentDir, openapiOutDir, groupSpecs, summary, files, sources });
|
|
399
|
+
const pageSpecs = await parsePageSpecs({ contentDir, openapiOutDir, groupSpecs, summary, files, sources, drafts });
|
|
398
400
|
// Every spec the site reads, as paths from the project root: these are
|
|
399
401
|
// how the site is built, not files it publishes (lib/project-files.js).
|
|
400
402
|
if (groupSpecs.length || pageSpecs.length) {
|
|
@@ -471,9 +473,9 @@ export function writeGeneratedFiles(roots, files, { keepEmptyFolders = false } =
|
|
|
471
473
|
* pages are generated - the pages that name the spec are the pages. A
|
|
472
474
|
* spec that's missing or doesn't parse is a warning, not a build failure:
|
|
473
475
|
* its pages show the playground's own "no operation found" notice. */
|
|
474
|
-
async function parsePageSpecs({ contentDir, openapiOutDir, groupSpecs, summary, files, sources }) {
|
|
476
|
+
async function parsePageSpecs({ contentDir, openapiOutDir, groupSpecs, summary, files, sources, drafts }) {
|
|
475
477
|
const specs = new Set();
|
|
476
|
-
for (const rel of findAllPages(contentDir)) {
|
|
478
|
+
for (const rel of findAllPages(contentDir, { drafts })) {
|
|
477
479
|
let data;
|
|
478
480
|
try {
|
|
479
481
|
({ data } = matter(fs.readFileSync(path.join(contentDir, rel), 'utf-8')));
|
|
@@ -32,12 +32,14 @@ export function mayChangePages(relative) {
|
|
|
32
32
|
/** Starts watching; returns `{ close }`. `onChange({ added, removed })` gets
|
|
33
33
|
* the page files (relative paths) that came and went. */
|
|
34
34
|
export function watchPageList(contentDir, onChange, { settleMs = SETTLE_MS } = {}) {
|
|
35
|
-
|
|
35
|
+
// Drafts included, as in the preview (lib/drafts.js): `draft: true` coming
|
|
36
|
+
// or going doesn't change the list.
|
|
37
|
+
let current = new Set(findAllPages(contentDir, { drafts: true }));
|
|
36
38
|
let timer = null;
|
|
37
39
|
const check = () => {
|
|
38
40
|
let next;
|
|
39
41
|
try {
|
|
40
|
-
next = new Set(findAllPages(contentDir));
|
|
42
|
+
next = new Set(findAllPages(contentDir, { drafts: true }));
|
|
41
43
|
} catch {
|
|
42
44
|
return; // mid-save, or a folder being moved - the next event checks again
|
|
43
45
|
}
|
package/src/cli/run-astro.js
CHANGED
|
@@ -20,7 +20,7 @@ const workerPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'astr
|
|
|
20
20
|
* console.warn that doesn't go through cli-report.js still shows up.
|
|
21
21
|
*
|
|
22
22
|
* `env` adds variables for the child only (build.js's
|
|
23
|
-
* WRITEDOCS_OG_CARDS_FILE).
|
|
23
|
+
* WRITEDOCS_OG_CARDS_FILE, and WRITEDOCS_DRAFTS with --drafts).
|
|
24
24
|
*
|
|
25
25
|
* Returns { child, exited } - `exited` resolves with the exit code.
|
|
26
26
|
*/
|
package/src/content.config.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { glob } from 'astro/loaders';
|
|
|
3
3
|
import type { Loader } from 'astro/loaders';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
6
7
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
8
|
import { pageFrontmatterSchema, findAllPages } from './lib/config';
|
|
8
9
|
import { titleFromPath } from './lib/pages.js';
|
|
@@ -76,10 +77,25 @@ function skipIfMissing(inner: Loader): Loader {
|
|
|
76
77
|
// a migrated page that relied on it builds with the same title. See
|
|
77
78
|
// titleFromPath() in lib/pages.js; `writedocs validate` applies the same
|
|
78
79
|
// default (lib/content-check.js).
|
|
80
|
+
//
|
|
81
|
+
// And each page's digest - what Astro's content store, kept between runs in
|
|
82
|
+
// writedocsTempDir()'s cache/, compares to reuse a page's data instead of
|
|
83
|
+
// parsing it again - also covers the frontmatter schema (config-schema.ts).
|
|
84
|
+
// With the file's text alone, a page that hadn't changed kept the data an
|
|
85
|
+
// earlier writedocs parsed: after an upgrade that added `draft`, a draft
|
|
86
|
+
// page came back without it - no strip in `writedocs dev`, and not noindex
|
|
87
|
+
// in `build --drafts`. Astro clears the store only when content.config.ts's
|
|
88
|
+
// own text, the Astro config or Astro's version changes.
|
|
89
|
+
const schemaDigest = createHash('sha256')
|
|
90
|
+
.update(fs.readFileSync(path.join(process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd(), 'src', 'lib', 'config-schema.ts')))
|
|
91
|
+
.digest('hex')
|
|
92
|
+
.slice(0, 16);
|
|
93
|
+
|
|
79
94
|
type LoaderContext = Parameters<Loader['load']>[0];
|
|
80
95
|
function withTitleFallback(context: LoaderContext): LoaderContext {
|
|
81
96
|
return {
|
|
82
97
|
...context,
|
|
98
|
+
generateDigest: (data) => context.generateDigest(typeof data === 'string' ? `${schemaDigest}\n${data}` : data),
|
|
83
99
|
parseData: (props) =>
|
|
84
100
|
context.parseData({
|
|
85
101
|
...props,
|
|
@@ -38,6 +38,20 @@ const { nodes, hrefForSlug, currentSlug, depth = 0 } = Astro.props as Props;
|
|
|
38
38
|
)}
|
|
39
39
|
{node.icon && <AppIcon icon={node.icon} class="wd-nav-page-icon" />}
|
|
40
40
|
<span class="wd-nav-title">{node.title}</span>
|
|
41
|
+
{
|
|
42
|
+
// A draft page (`draft: true` - lib/drafts.js), in `writedocs
|
|
43
|
+
// dev` and `build --drafts`. Its colors inline, not in the
|
|
44
|
+
// <style> below: that stylesheet is on every site, and a
|
|
45
|
+
// site with no drafts builds byte for byte as before.
|
|
46
|
+
node.draft && (
|
|
47
|
+
<span
|
|
48
|
+
class="wd-nav-tag"
|
|
49
|
+
style="color: var(--wd-text); background: color-mix(in srgb, var(--wd-text-muted) 16%, transparent)"
|
|
50
|
+
>
|
|
51
|
+
Draft
|
|
52
|
+
</span>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
41
55
|
{node.deprecated && <span class="wd-nav-tag wd-nav-tag-deprecated">Deprecated</span>}
|
|
42
56
|
{node.tag && <span class="wd-nav-tag">{node.tag}</span>}
|
|
43
57
|
</a>
|
package/src/lib/config-schema.js
CHANGED
|
@@ -485,7 +485,13 @@ const pageFrontmatterSchema = z.object({
|
|
|
485
485
|
hidden: z.boolean().optional(),
|
|
486
486
|
url: z.string().optional(),
|
|
487
487
|
hideFooterPagination: z.boolean().optional(),
|
|
488
|
-
hideApiMarker: z.boolean().optional()
|
|
488
|
+
hideApiMarker: z.boolean().optional(),
|
|
489
|
+
// Docusaurus' key: a draft isn't part of the site `writedocs build`
|
|
490
|
+
// makes - no route, no navigation entry, not in search, the sitemap,
|
|
491
|
+
// llms.txt or the MCP index (lib/drafts.js). `writedocs dev` and
|
|
492
|
+
// `writedocs build --drafts` show it, marked, and always noindex (the
|
|
493
|
+
// transform below) - with `hidden` too, the draft wins.
|
|
494
|
+
draft: z.boolean().optional()
|
|
489
495
|
}).transform(
|
|
490
496
|
({ noindex, robots, canonical, keywords, "og:image": ogImage, "og:type": ogType, "twitter:card": twitterCard, ...data }) => {
|
|
491
497
|
const seo = { ...data.seo };
|
|
@@ -509,6 +515,11 @@ const pageFrontmatterSchema = z.object({
|
|
|
509
515
|
seo.noindex = /\bnoindex\b|\bnone\b/i.test(pageRobots);
|
|
510
516
|
changed = true;
|
|
511
517
|
}
|
|
518
|
+
if (data.draft === true) {
|
|
519
|
+
seo.noindex = true;
|
|
520
|
+
seo.robots = "noindex, nofollow";
|
|
521
|
+
changed = true;
|
|
522
|
+
}
|
|
512
523
|
return changed ? { ...data, seo } : data;
|
|
513
524
|
}
|
|
514
525
|
);
|
package/src/lib/config-schema.ts
CHANGED
|
@@ -856,6 +856,12 @@ export const pageFrontmatterSchema = z.object({
|
|
|
856
856
|
url: z.string().optional(),
|
|
857
857
|
hideFooterPagination: z.boolean().optional(),
|
|
858
858
|
hideApiMarker: z.boolean().optional(),
|
|
859
|
+
// Docusaurus' key: a draft isn't part of the site `writedocs build`
|
|
860
|
+
// makes - no route, no navigation entry, not in search, the sitemap,
|
|
861
|
+
// llms.txt or the MCP index (lib/drafts.js). `writedocs dev` and
|
|
862
|
+
// `writedocs build --drafts` show it, marked, and always noindex (the
|
|
863
|
+
// transform below) - with `hidden` too, the draft wins.
|
|
864
|
+
draft: z.boolean().optional(),
|
|
859
865
|
}).transform(
|
|
860
866
|
({ noindex, robots, canonical, keywords, 'og:image': ogImage, 'og:type': ogType, 'twitter:card': twitterCard, ...data }) => {
|
|
861
867
|
// Top-level Mintlify keys fill in `seo` only where the page's own `seo`
|
|
@@ -885,6 +891,14 @@ export const pageFrontmatterSchema = z.object({
|
|
|
885
891
|
seo.noindex = /\bnoindex\b|\bnone\b/i.test(pageRobots);
|
|
886
892
|
changed = true;
|
|
887
893
|
}
|
|
894
|
+
// A draft is never indexed, whatever the page says: only `writedocs
|
|
895
|
+
// dev` and `build --drafts` render one. `robots` too: the page's own
|
|
896
|
+
// `robots` would decide over `noindex` (mergeSeo()).
|
|
897
|
+
if (data.draft === true) {
|
|
898
|
+
seo.noindex = true;
|
|
899
|
+
seo.robots = 'noindex, nofollow';
|
|
900
|
+
changed = true;
|
|
901
|
+
}
|
|
888
902
|
return changed ? { ...data, seo } : data;
|
|
889
903
|
},
|
|
890
904
|
);
|
package/src/lib/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { EXCLUDED_TOP_LEVEL_DIRS, navPageId } from './pages.js';
|
|
3
|
+
import { EXCLUDED_TOP_LEVEL_DIRS, navPageId, draftsIncluded, findDraftPages, fileIdForPath } from './pages.js';
|
|
4
|
+
import { withoutDrafts } from './drafts.js';
|
|
4
5
|
import { isHidden } from './hidden-sections.js';
|
|
5
6
|
import { itemPage, childLevel, equivalentItem, resolveLandings as resolveLandingsJs } from './item-pages.js';
|
|
6
7
|
import matter from 'gray-matter';
|
|
@@ -457,6 +458,14 @@ function readDocsConfig(contentDir: string): DocsConfig {
|
|
|
457
458
|
// always run, rather than gated behind a global manifest check, since
|
|
458
459
|
// there's no longer a single global spec to check for.
|
|
459
460
|
result.data.navigation = withPageIds(expandOpenApiInNavigation(result.data.navigation, contentDir));
|
|
461
|
+
// `writedocs build` (without --drafts): no entry for a draft page, and no
|
|
462
|
+
// item left with no pages - everything that reads the navigation sees it
|
|
463
|
+
// this way (lib/drafts.js). The build prints what was left out
|
|
464
|
+
// (draftWarnings(), src/cli/build.js).
|
|
465
|
+
if (!draftsIncluded()) {
|
|
466
|
+
const draftIds = new Set(findDraftPages(contentDir).map((draft) => fileIdForPath(draft.file)));
|
|
467
|
+
result.data.navigation = withoutDrafts(result.data.navigation, draftIds).navigation;
|
|
468
|
+
}
|
|
460
469
|
return result.data;
|
|
461
470
|
}
|
|
462
471
|
|
|
@@ -1203,6 +1212,9 @@ export type NavTreeNode =
|
|
|
1203
1212
|
icon?: string;
|
|
1204
1213
|
tag?: string;
|
|
1205
1214
|
deprecated?: boolean;
|
|
1215
|
+
// A draft page (`draft: true`): only in `writedocs dev` and `build
|
|
1216
|
+
// --drafts` - the build takes it out of the navigation (lib/drafts.js).
|
|
1217
|
+
draft?: boolean;
|
|
1206
1218
|
}
|
|
1207
1219
|
| { kind: 'group'; label: string; pageSlug: string | null; children: NavTreeNode[] }
|
|
1208
1220
|
| { kind: 'link'; label: string; href: string };
|
|
@@ -1213,14 +1225,15 @@ export type NavTreeNode =
|
|
|
1213
1225
|
* sidebar (e.g. "GET") or null for an ordinary page - see
|
|
1214
1226
|
* NavTree.astro for how that badge renders. */
|
|
1215
1227
|
/** Per-page frontmatter that changes how a page shows up in navigation -
|
|
1216
|
-
* Mintlify's `hidden`, `url`, `icon`, `tag` and `deprecated`
|
|
1217
|
-
* content.config.ts's docsSchema). */
|
|
1228
|
+
* Mintlify's `hidden`, `url`, `icon`, `tag` and `deprecated`, and `draft`
|
|
1229
|
+
* (see content.config.ts's docsSchema). */
|
|
1218
1230
|
export interface NavPageMeta {
|
|
1219
1231
|
hidden?: boolean;
|
|
1220
1232
|
url?: string;
|
|
1221
1233
|
icon?: string;
|
|
1222
1234
|
tag?: string;
|
|
1223
1235
|
deprecated?: boolean;
|
|
1236
|
+
draft?: boolean;
|
|
1224
1237
|
}
|
|
1225
1238
|
|
|
1226
1239
|
export function buildNavTree(
|
|
@@ -1245,6 +1258,8 @@ export function buildNavTree(
|
|
|
1245
1258
|
icon: meta?.icon,
|
|
1246
1259
|
tag: meta?.tag,
|
|
1247
1260
|
deprecated: meta?.deprecated,
|
|
1261
|
+
// Only on a draft, so every other page's node is as it was.
|
|
1262
|
+
...(meta?.draft ? { draft: true } : {}),
|
|
1248
1263
|
},
|
|
1249
1264
|
];
|
|
1250
1265
|
}
|
package/src/lib/content-check.js
CHANGED
|
@@ -384,7 +384,10 @@ async function checkOpenApi(contentDir, config, locate, openapiRefs, errors, war
|
|
|
384
384
|
export async function checkContent(contentDir, configText) {
|
|
385
385
|
const errors = [];
|
|
386
386
|
const warnings = [];
|
|
387
|
-
|
|
387
|
+
// Drafts too (`draft: true`): the build leaves them out, but they're the
|
|
388
|
+
// project's pages - checked like any other, and the navigation can list
|
|
389
|
+
// them (the build takes those entries out, with a warning).
|
|
390
|
+
const pages = findAllPages(contentDir, { drafts: true });
|
|
388
391
|
const openapiRefs = [];
|
|
389
392
|
for (const rel of pages) await checkPage(contentDir, rel, errors, warnings, openapiRefs);
|
|
390
393
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Draft pages - `draft: true` in a page's frontmatter (Docusaurus' key).
|
|
2
|
+
//
|
|
3
|
+
// In `writedocs build` a draft doesn't exist: it's left out where the build
|
|
4
|
+
// decides which pages there are - findAllPages() in lib/pages.js, the list
|
|
5
|
+
// every route, the content collection, the sitemap and `writedocs
|
|
6
|
+
// broken-links` start from - and where it reads the navigation:
|
|
7
|
+
// loadDocsConfig() in lib/config.ts puts the navigation through
|
|
8
|
+
// withoutDrafts() below, so the sidebar, the switchers, prev/next, the "/"
|
|
9
|
+
// redirect, llms.txt and the MCP index never see an entry for one. Nothing
|
|
10
|
+
// downstream filters drafts on its own.
|
|
11
|
+
//
|
|
12
|
+
// `writedocs dev` and `writedocs build --drafts` - a preview of them, for
|
|
13
|
+
// deploy previews - keep them (draftsIncluded() in lib/pages.js), marked: a
|
|
14
|
+
// strip at the top of the page (DRAFT_BANNER_HTML below, [...slug].astro), a
|
|
15
|
+
// mark on its sidebar entry (NavTree.astro) and "Draft" on its search
|
|
16
|
+
// result's section line - and noindex: the page schema makes every draft
|
|
17
|
+
// noindex (lib/config-schema.ts), which keeps it out of the sitemap, llms.txt
|
|
18
|
+
// and the MCP index the way any noindex page is.
|
|
19
|
+
//
|
|
20
|
+
// Plain JavaScript, for scripts/drafts.test.js and for the CLI, which prints
|
|
21
|
+
// draftWarnings() with the build's other warnings. No import of
|
|
22
|
+
// lib/config-schema.js: lib/config.ts loads this file inside Astro, where the
|
|
23
|
+
// schema comes from config-schema.ts - draftWarnings() gets its line locator
|
|
24
|
+
// from the caller instead.
|
|
25
|
+
import { navPageId, fileIdForPath } from './pages.js';
|
|
26
|
+
|
|
27
|
+
/** The key that names each kind of navigation item, in the order they're
|
|
28
|
+
* looked for - what a warning calls the item. */
|
|
29
|
+
const ITEM_KINDS = ['group', 'tab', 'version', 'language', 'dropdown', 'product'];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* `navigation` without the entries that name a draft page: a page in a
|
|
33
|
+
* `pages` list, or an item's own `page`. An item that had pages and is left
|
|
34
|
+
* with none - every page in it was a draft - goes too, and so on up: a tab
|
|
35
|
+
* whose groups all went. An item that keeps its own `page`, or that never
|
|
36
|
+
* had pages (an `href`, an `openapi` group, which gets its pages later), is
|
|
37
|
+
* kept. The navigation's root is always kept.
|
|
38
|
+
*
|
|
39
|
+
* `draftIds` - the drafts' page ids (fileIdForPath()); a navigation entry
|
|
40
|
+
* matches by its page id (navPageId(): "guides/index" is "guides"). With no
|
|
41
|
+
* drafts, `navigation` itself comes back. Returns { navigation, leftOut }:
|
|
42
|
+
* `leftOut` lists what was taken out, in the order it was met - `{ path,
|
|
43
|
+
* page }` for an entry (`page` as the navigation writes it), `{ path, kind,
|
|
44
|
+
* name }` for an item - with `path` the JSON path from `navigation`.
|
|
45
|
+
*/
|
|
46
|
+
export function withoutDrafts(navigation, draftIds) {
|
|
47
|
+
const leftOut = [];
|
|
48
|
+
if (!draftIds || draftIds.size === 0) return { navigation, leftOut };
|
|
49
|
+
const isDraftEntry = (value) => typeof value === 'string' && draftIds.has(navPageId(value));
|
|
50
|
+
const REMOVED = Symbol('removed');
|
|
51
|
+
|
|
52
|
+
function prune(node, trail) {
|
|
53
|
+
if (Array.isArray(node)) {
|
|
54
|
+
const kept = [];
|
|
55
|
+
node.forEach((item, i) => {
|
|
56
|
+
if (isDraftEntry(item)) {
|
|
57
|
+
leftOut.push({ path: [...trail, i], page: item });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const value = prune(item, [...trail, i]);
|
|
61
|
+
if (value !== REMOVED) kept.push(value);
|
|
62
|
+
});
|
|
63
|
+
return kept;
|
|
64
|
+
}
|
|
65
|
+
if (!node || typeof node !== 'object') return node;
|
|
66
|
+
const out = {};
|
|
67
|
+
let hadPages = false;
|
|
68
|
+
let hasPages = false;
|
|
69
|
+
for (const [key, value] of Object.entries(node)) {
|
|
70
|
+
if (key === 'href' || key === 'openapi') {
|
|
71
|
+
out[key] = value;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (key === 'page' && typeof value === 'string') {
|
|
75
|
+
if (isDraftEntry(value)) leftOut.push({ path: [...trail, key], page: value });
|
|
76
|
+
else out[key] = value;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const pruned = prune(value, [...trail, key]);
|
|
80
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
81
|
+
hadPages = true;
|
|
82
|
+
if (pruned.length > 0) hasPages = true;
|
|
83
|
+
}
|
|
84
|
+
out[key] = pruned;
|
|
85
|
+
}
|
|
86
|
+
const emptied = hadPages && !hasPages && !('page' in out) && !('href' in out) && !('openapi' in out);
|
|
87
|
+
if (emptied && trail.length > 0) {
|
|
88
|
+
const kind = ITEM_KINDS.find((k) => typeof node[k] === 'string') ?? 'item';
|
|
89
|
+
leftOut.push({ path: trail, kind, name: node[kind] ?? '' });
|
|
90
|
+
return REMOVED;
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { navigation: prune(navigation, []), leftOut };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A page address the way writedocs.json's `redirects` and a page's `slug`
|
|
99
|
+
* write it, as one key: no slashes around it, no #anchor or ?query, lower
|
|
100
|
+
* case; the root is "index". */
|
|
101
|
+
function addressKey(value) {
|
|
102
|
+
const bare = String(value).split(/[?#]/)[0].replace(/^\/+|\/+$/g, '').toLowerCase();
|
|
103
|
+
return bare === '' ? 'index' : bare;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* What `writedocs build` tells the author about the drafts it leaves out,
|
|
108
|
+
* as { warnings, notes } - warnings `{ where, message }` like the build's
|
|
109
|
+
* others, `where` a "writedocs.json:line" or the draft's own file:
|
|
110
|
+
* - each navigation entry for a draft, and each item left with no pages
|
|
111
|
+
* (withoutDrafts());
|
|
112
|
+
* - each redirect that leads to a draft - it stays, and shows "not found"
|
|
113
|
+
* until the page is published;
|
|
114
|
+
* - a draft home page - "/" goes to the navigation's first page instead.
|
|
115
|
+
* `notes` says how many drafts were left out. `configText` is
|
|
116
|
+
* writedocs.json's text (valid JSON - the build checked it first), `drafts`
|
|
117
|
+
* what findDraftPages() (lib/pages.js) gives, `locate` createJsonLocator()
|
|
118
|
+
* of that text (lib/config-schema.js). Empty without drafts.
|
|
119
|
+
*/
|
|
120
|
+
export function draftWarnings({ configText, drafts, locate }) {
|
|
121
|
+
const warnings = [];
|
|
122
|
+
const notes = [];
|
|
123
|
+
if (!drafts.length) return { warnings, notes };
|
|
124
|
+
const config = JSON.parse(configText);
|
|
125
|
+
const where = (jsonPath) => {
|
|
126
|
+
const line = locate(jsonPath)?.line;
|
|
127
|
+
return line ? `writedocs.json:${line}` : 'writedocs.json';
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const { leftOut } = withoutDrafts(config.navigation, new Set(drafts.map((draft) => fileIdForPath(draft.file))));
|
|
131
|
+
for (const entry of leftOut) {
|
|
132
|
+
const jsonPath = ['navigation', ...entry.path];
|
|
133
|
+
warnings.push({
|
|
134
|
+
where: where(jsonPath),
|
|
135
|
+
message: entry.page
|
|
136
|
+
? `${entry.page} is a draft and was left out of the navigation.`
|
|
137
|
+
: `The ${entry.kind} "${entry.name}" was left out of the navigation: every page in it is a draft.`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const byAddress = new Map(drafts.map((draft) => [addressKey(draft.slug ?? fileIdForPath(draft.file)), draft]));
|
|
142
|
+
(Array.isArray(config.redirects) ? config.redirects : []).forEach((redirect, i) => {
|
|
143
|
+
if (typeof redirect?.destination !== 'string' || /^[a-z][a-z0-9+.-]*:|^\/\//i.test(redirect.destination)) return;
|
|
144
|
+
const draft = byAddress.get(addressKey(redirect.destination));
|
|
145
|
+
if (!draft) return;
|
|
146
|
+
warnings.push({
|
|
147
|
+
where: where(['redirects', i, 'destination']),
|
|
148
|
+
message: `The redirect from ${redirect.source} leads to ${redirect.destination}, a draft (${draft.file}) - it shows "not found" until the page is published.`,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const home = byAddress.get('index');
|
|
153
|
+
if (home) {
|
|
154
|
+
warnings.push({
|
|
155
|
+
where: home.file,
|
|
156
|
+
message: "The home page is a draft - the site's address (/) opens the navigation's first page instead.",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
notes.push(
|
|
161
|
+
drafts.length === 1
|
|
162
|
+
? '1 draft page (draft: true) was left out of the site - writedocs dev shows it.'
|
|
163
|
+
: `${drafts.length} draft pages (draft: true) were left out of the site - writedocs dev shows them.`
|
|
164
|
+
);
|
|
165
|
+
return { warnings, notes };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** The strip at the top of a draft page, in `writedocs dev` and `build
|
|
169
|
+
* --drafts` ([...slug].astro). Its stylesheet comes with it, inline: in the
|
|
170
|
+
* site's own CSS it would be on every site, and a site with no drafts builds
|
|
171
|
+
* byte for byte as it did before drafts existed. Left out of search's text
|
|
172
|
+
* and the page's Markdown copy. */
|
|
173
|
+
export const DRAFT_BANNER_HTML =
|
|
174
|
+
'<style>' +
|
|
175
|
+
'.wd-draft-banner{display:flex;flex-wrap:wrap;align-items:baseline;gap:.25rem .625rem;margin:0 0 1.5rem;padding:.625rem .875rem;' +
|
|
176
|
+
'border:1px dashed color-mix(in srgb,#d97706 60%,transparent);border-radius:.5rem;' +
|
|
177
|
+
'background:color-mix(in srgb,#d97706 9%,var(--wd-background));color:var(--wd-text);font-size:.875rem;line-height:1.5}' +
|
|
178
|
+
'.wd-draft-banner strong{color:#b45309;font-weight:700}' +
|
|
179
|
+
'[data-theme=dark] .wd-draft-banner strong{color:#fbbf24}' +
|
|
180
|
+
'.wd-draft-banner code{font-size:.8125rem}' +
|
|
181
|
+
'.wd-canvas>.wd-draft-banner{margin:1rem}' +
|
|
182
|
+
'</style>' +
|
|
183
|
+
'<div class="wd-draft-banner" role="note" data-pagefind-ignore data-markdown-ignore>' +
|
|
184
|
+
'<strong>Draft: not published</strong>' +
|
|
185
|
+
'<span>This page has <code>draft: true</code> - the published site leaves it out.</span>' +
|
|
186
|
+
'</div>';
|
package/src/lib/link-check.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// comment on why not TypeScript).
|
|
6
6
|
//
|
|
7
7
|
// A link is broken when, on the built site:
|
|
8
|
-
// - no page, redirect or file is at its address
|
|
8
|
+
// - no page, redirect or file is at its address - a draft page (`draft:
|
|
9
|
+
// true`) included: the build leaves drafts out;
|
|
9
10
|
// - its #anchor isn't on the target page (headings, titled components -
|
|
10
11
|
// Callout/Accordion/Update and friends - and elements with an `id`).
|
|
11
12
|
// #cookie-settings is on every page when writedocs.json turns on
|
|
@@ -35,7 +36,7 @@ import { createRequire } from 'node:module';
|
|
|
35
36
|
import { pathToFileURL } from 'node:url';
|
|
36
37
|
import matter from 'gray-matter';
|
|
37
38
|
import { visit } from 'unist-util-visit';
|
|
38
|
-
import { findAllPages } from './pages.js';
|
|
39
|
+
import { findAllPages, findDraftPages } from './pages.js';
|
|
39
40
|
import { createJsonLocator, contextMenuOptions } from './config-schema.js';
|
|
40
41
|
import { writedocsTempDir } from './writedocs-temp-dir.js';
|
|
41
42
|
import { folderAddresses } from './folder-redirects.js';
|
|
@@ -302,6 +303,10 @@ export async function checkLinks(contentDir, configText) {
|
|
|
302
303
|
pages.set(url, { rel, abs, scan });
|
|
303
304
|
urlOfFile.set(rel, url);
|
|
304
305
|
}
|
|
306
|
+
// Draft pages (`draft: true`) aren't on the built site - a link to one is
|
|
307
|
+
// broken, and says why (lib/drafts.js). Their own links aren't checked:
|
|
308
|
+
// they aren't published either.
|
|
309
|
+
const drafts = new Map(findDraftPages(contentDir).map((draft) => [urlOf(draft.file, draft.slug), draft.file]));
|
|
305
310
|
const generated = generatedPageUrls(contentDir);
|
|
306
311
|
const redirects = new Set(
|
|
307
312
|
(Array.isArray(config.redirects) ? config.redirects : [])
|
|
@@ -427,6 +432,10 @@ export async function checkLinks(contentDir, configText) {
|
|
|
427
432
|
// "/" always exists: the home page, or a redirect to the first page.
|
|
428
433
|
if (pageKey === '/' || generated.has(pageKey) || redirects.has(pageKey) || folders.has(pageKey) || special.has(pageKey.replace(/\/$/, '') || '/')) return;
|
|
429
434
|
if (special.has(pathname)) return;
|
|
435
|
+
if (drafts.has(pageKey)) {
|
|
436
|
+
report(`${value} - ${pageKey} is a draft (draft: true in ${drafts.get(pageKey)}), so it isn't published.`);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
430
439
|
|
|
431
440
|
// Mintlify-style relative link: resolved from the file's folder
|
|
432
441
|
// instead of the page's URL, would it land on a page?
|
package/src/lib/pages.js
CHANGED
|
@@ -121,10 +121,41 @@ function navigationPageIds(contentDir) {
|
|
|
121
121
|
* project is scanned once and every later call gets that list
|
|
122
122
|
* (lib/build-memo.js) - a page that scanned it again made the build N x N;
|
|
123
123
|
* everywhere else (`writedocs dev`, `validate`) every call scans afresh,
|
|
124
|
-
* so a page added or removed is seen.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
* so a page added or removed is seen.
|
|
125
|
+
*
|
|
126
|
+
* Draft pages (`draft: true`) are left out unless `drafts` is true - by
|
|
127
|
+
* default, draftsIncluded() below. This is where `writedocs build` leaves
|
|
128
|
+
* them out of the site: every route, the content collection and the
|
|
129
|
+
* sitemap start from this list (lib/drafts.js). */
|
|
130
|
+
export function findAllPages(contentDir, { drafts = draftsIncluded() } = {}) {
|
|
131
|
+
// A new list, so a caller that changes its list doesn't change everyone's.
|
|
132
|
+
return scannedPages(contentDir)
|
|
133
|
+
.filter((page) => drafts || !page.draft)
|
|
134
|
+
.map((page) => page.file);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Whether draft pages (`draft: true` - lib/drafts.js) are pages here: in
|
|
138
|
+
* `writedocs dev` and `writedocs build --drafts`, which tell the Astro
|
|
139
|
+
* process so (src/cli/run-astro.js's WRITEDOCS_COMMAND, src/cli/build.js's
|
|
140
|
+
* WRITEDOCS_DRAFTS). Everywhere else - `writedocs build`, and `writedocs
|
|
141
|
+
* broken-links`, which checks the site the build makes - a draft isn't a
|
|
142
|
+
* page. The CLI's own calls in dev, build and validate pass `drafts`
|
|
143
|
+
* instead. */
|
|
144
|
+
export function draftsIncluded(env = process.env) {
|
|
145
|
+
return env.WRITEDOCS_COMMAND === 'dev' || env.WRITEDOCS_DRAFTS === '1';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The draft pages findAllPages() finds (whether it leaves them out or not):
|
|
149
|
+
* `{ file, slug }` - the file's path as findAllPages() gives it, and its
|
|
150
|
+
* frontmatter `slug`, if any. */
|
|
151
|
+
export function findDraftPages(contentDir) {
|
|
152
|
+
return scannedPages(contentDir)
|
|
153
|
+
.filter((page) => page.draft)
|
|
154
|
+
.map(({ file, slug }) => ({ file, slug }));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function scannedPages(contentDir) {
|
|
158
|
+
return oncePerBuild(`pages:${contentDir}`, () => scanAllPages(contentDir));
|
|
128
159
|
}
|
|
129
160
|
|
|
130
161
|
function scanAllPages(contentDir) {
|
|
@@ -165,11 +196,14 @@ function scanAllPages(contentDir) {
|
|
|
165
196
|
// frontmatter block), so the error surfaces with this file's name -
|
|
166
197
|
// from `writedocs validate`, or Astro's own loader in the build -
|
|
167
198
|
// instead of as a bare YAML error thrown from here.
|
|
168
|
-
if (/^---\r?\n/.test(raw)) results.push(rel);
|
|
199
|
+
if (/^---\r?\n/.test(raw)) results.push({ file: rel, draft: false });
|
|
169
200
|
continue;
|
|
170
201
|
}
|
|
171
202
|
if (Object.keys(data).length === 0 && !listed.has(fileIdForPath(rel))) continue; // not a page
|
|
172
|
-
|
|
203
|
+
// Only `draft: true` - `draft: "yes"` stays a page, and the schema
|
|
204
|
+
// rejects it.
|
|
205
|
+
const draft = data.draft === true;
|
|
206
|
+
results.push({ file: rel, draft, slug: draft && typeof data.slug === 'string' ? data.slug : undefined });
|
|
173
207
|
}
|
|
174
208
|
}
|
|
175
209
|
walk(contentDir, '');
|
package/src/lib/seo-tags.js
CHANGED
|
@@ -27,8 +27,10 @@ export function isNoindex(seo) {
|
|
|
27
27
|
|
|
28
28
|
/** A page's frontmatter as gray-matter read it - before the schema folds
|
|
29
29
|
* Mintlify's top-level `noindex`/`robots` into `seo`, and marks a `hidden`
|
|
30
|
-
* page noindex. Used where pages aren't loaded yet (astro.config.mjs).
|
|
30
|
+
* page noindex. Used where pages aren't loaded yet (astro.config.mjs). A
|
|
31
|
+
* draft is noindex whatever else it says, as in the schema. */
|
|
31
32
|
export function frontmatterNoindex(data) {
|
|
33
|
+
if (data?.draft === true) return true;
|
|
32
34
|
const robots = data?.seo?.robots ?? data?.robots;
|
|
33
35
|
if (typeof robots === 'string') return isNoindex({ robots });
|
|
34
36
|
return (data?.seo?.noindex ?? data?.noindex ?? data?.hidden === true) === true;
|
|
@@ -79,6 +79,7 @@ import { selectorPlacements } from "../lib/selector-placement.js";
|
|
|
79
79
|
import { spaceOf } from "../lib/hidden-sections.js";
|
|
80
80
|
import { navigationPageOrder } from "../lib/pages.js";
|
|
81
81
|
import { folderRedirects } from "../lib/folder-redirects.js";
|
|
82
|
+
import { DRAFT_BANNER_HTML } from "../lib/drafts.js";
|
|
82
83
|
import { oncePerBuild } from "../lib/build-memo.js";
|
|
83
84
|
// writedocs.json's `basePath` - the addresses below stay site addresses
|
|
84
85
|
// ("/guides/a/"); the base goes in where one is written (lib/site-base.ts).
|
|
@@ -508,7 +509,11 @@ const selectors = landing
|
|
|
508
509
|
// be found by), and the version/language/product it belongs to - search
|
|
509
510
|
// shows the reader's own first. A hidden page belongs to no section.
|
|
510
511
|
const pageSearchScope = isHidden ? { key: ALL_SCOPES, label: "" } : searchScope(activeSection.path);
|
|
511
|
-
|
|
512
|
+
// A draft (only in `writedocs dev` and `build --drafts` - lib/drafts.js)
|
|
513
|
+
// says so on its search result's section line.
|
|
514
|
+
const pageSectionTrail = [entry.data.draft ? "Draft" : "", isHidden ? "" : sectionTrail(activeSection.path, breadcrumbs)]
|
|
515
|
+
.filter(Boolean)
|
|
516
|
+
.join(" · ");
|
|
512
517
|
// A page under a hidden navigation item searches its own index, not the
|
|
513
518
|
// site's (lib/hidden-sections.js, cli/run-pagefind.js).
|
|
514
519
|
const pageSearchSpace = isHidden ? null : spaceOf(activeSection.path);
|
|
@@ -678,6 +683,7 @@ const components = {
|
|
|
678
683
|
// a data-pagefind-body wrapper so a hand-built page's own text is
|
|
679
684
|
// still searchable.
|
|
680
685
|
<div class="wd-canvas" data-pagefind-body>
|
|
686
|
+
{entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />}
|
|
681
687
|
<Content components={components} />
|
|
682
688
|
{entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
|
|
683
689
|
{/* After the content: a result's excerpt shows the section only when
|
|
@@ -696,6 +702,11 @@ const components = {
|
|
|
696
702
|
</div>
|
|
697
703
|
) : (
|
|
698
704
|
<article class={`wd-article ${pageMode === "wide" ? "wd-article-wide" : ""}`} data-pagefind-body>
|
|
705
|
+
{
|
|
706
|
+
// A draft page - only in `writedocs dev` and `build --drafts`
|
|
707
|
+
// (lib/drafts.js): a strip at the top saying so.
|
|
708
|
+
entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />
|
|
709
|
+
}
|
|
699
710
|
{breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}
|
|
700
711
|
<div class="wd-article-header">
|
|
701
712
|
{
|