Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/multi-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ build/
└── llms-full.txt
```

Each version's label is its `versions.<name>.label` from the docs plugin config, or its name otherwise, so the current docs are labeled `current` unless you set `versions.current.label`. If `versions.json` is absent, the plugin generates only the current docs.
Each version's label follows Docusaurus: its `versions.<name>.label` from the docs plugin config when set, otherwise `Next` for the current docs and the version name for any other version. If `versions.json` is absent, the plugin generates only the current docs.

## Output layout and version identity

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"format:check": "oxfmt --check",
"cleanup": "node cleanup.js",
"prepublishOnly": "npm run build && npm run cleanup",
"test:unit": "node tests/test-plugin-options-validation.js && node tests/test-plugin-validation-integration.js && node tests/test-regex-escaping.js && node tests/test-baseurl-handling.js && node tests/test-baseurl-url-construction.js && node tests/test-baseurl-individual-markdown.js && node tests/test-compound-number-prefixes.js && node tests/test-relative-urls.js && node tests/test-content-cleaning-fences.js && node tests/test-jsx-attr-stripping.js && node tests/test-preserve-components.js && node tests/test-tabitem-attr-edge-cases.js && node tests/test-partial-dollar-replacement.js && node tests/test-partial-fence-masking.js && node tests/test-content-loss.js && node tests/test-output-assembly.js && node tests/test-crlf-handling.js && node tests/test-path-transforms.js && node tests/test-header-deduplication.js && node tests/test-import-removal.js && node tests/test-partials.js && node tests/test-site-alias-partials.js && node tests/test-partial-code-fence-imports.js && node tests/test-mdx-page-body-imports.js && node tests/test-missing-partials.js && node tests/test-circular-imports.js && node tests/test-root-content.js && node tests/test-rewrite-image-urls.js && node tests/test-filenames.js && node tests/test-url-encoding.js && node tests/test-nested-paths.js && node tests/test-filename-sanitization.js && node tests/test-yaml-encoding.js && node tests/test-url-error-handling.js && node tests/test-regex-lastindex.js && node tests/test-whitespace-paths.js && node tests/test-unique-identifier-iteration-limit.js && node tests/test-error-handling.js && node tests/test-file-io-error-handling.js && node tests/test-parallel-processing.js && node tests/test-path-length-validation.js && node tests/test-bom-handling.js && node tests/test-batch-processing.js && node tests/test-input-validation.js && node tests/test-add-md-extension.js && node tests/test-import-description-skip.js && node tests/test-description-non-prose.js && node tests/test-filename-sanitization-improved.js && node tests/test-content-edge-cases.js",
"test:integration": "node tests/test-path-transformation.js && node tests/test-multi-doc.js && node tests/test-draft-integration.js && node tests/test-md-extension-generation.js && node tests/test-regression-fixes.js && node tests/test-multi-version.js && node tests/test-versions-i18n.js && node tests/test-review-followups.js && node tests/test-frontmatter-slug-priority.js && node tests/test-numeric-frontmatter-slug.js && node tests/test-index-filename-case.js && node tests/test-log-level-and-batch-size.js && node tests/test-multi-section-route-scoping.js && node tests/test-path-safety.js && node tests/test-url-resolution.js && node tests/test-small-fixes.js",
"test:unit": "node tests/test-plugin-options-validation.js && node tests/test-plugin-validation-integration.js && node tests/test-regex-escaping.js && node tests/test-baseurl-handling.js && node tests/test-baseurl-url-construction.js && node tests/test-baseurl-individual-markdown.js && node tests/test-compound-number-prefixes.js && node tests/test-relative-urls.js && node tests/test-content-cleaning-fences.js && node tests/test-jsx-attr-stripping.js && node tests/test-preserve-components.js && node tests/test-tabitem-attr-edge-cases.js && node tests/test-partial-dollar-replacement.js && node tests/test-partial-fence-masking.js && node tests/test-content-loss.js && node tests/test-output-assembly.js && node tests/test-crlf-handling.js && node tests/test-path-transforms.js && node tests/test-header-deduplication.js && node tests/test-import-removal.js && node tests/test-partials.js && node tests/test-site-alias-partials.js && node tests/test-partial-code-fence-imports.js && node tests/test-mdx-page-body-imports.js && node tests/test-missing-partials.js && node tests/test-circular-imports.js && node tests/test-root-content.js && node tests/test-rewrite-image-urls.js && node tests/test-filenames.js && node tests/test-url-encoding.js && node tests/test-nested-paths.js && node tests/test-filename-sanitization.js && node tests/test-yaml-encoding.js && node tests/test-url-error-handling.js && node tests/test-regex-lastindex.js && node tests/test-whitespace-paths.js && node tests/test-unique-identifier-iteration-limit.js && node tests/test-error-handling.js && node tests/test-file-io-error-handling.js && node tests/test-parallel-processing.js && node tests/test-path-length-validation.js && node tests/test-bom-handling.js && node tests/test-batch-processing.js && node tests/test-input-validation.js && node tests/test-add-md-extension.js && node tests/test-import-description-skip.js && node tests/test-description-non-prose.js && node tests/test-filename-sanitization-improved.js && node tests/test-content-edge-cases.js && node tests/test-draft-filtering.js && node tests/test-individual-markdown-generation.js && node tests/test-component-name-escaping.js && node tests/test-description-extraction.js && node tests/test-double-slash-url.js && node tests/test-frontmatter-validation.js && node tests/test-ignored-files-warning.js && node tests/test-numbered-prefixes.js && node tests/test-path-bounds-checking.js && node tests/test-path-collision-limit.js && node tests/test-path-transformation-ignore.js && node tests/test-preserve-directory-structure.js && node tests/test-symlink-loops.js && node tests/test-type-guards.js && node tests/test-windows-path-normalization.js",
"test:integration": "node tests/test-path-transformation.js && node tests/test-multi-doc.js && node tests/test-draft-integration.js && node tests/test-md-extension-generation.js && node tests/test-regression-fixes.js && node tests/test-multi-version.js && node tests/test-versions-i18n.js && node tests/test-review-followups.js && node tests/test-frontmatter-slug-priority.js && node tests/test-numeric-frontmatter-slug.js && node tests/test-index-filename-case.js && node tests/test-log-level-and-batch-size.js && node tests/test-multi-section-route-scoping.js && node tests/test-path-safety.js && node tests/test-url-resolution.js && node tests/test-small-fixes.js && node tests/test-versions-edges.js && node tests/test-ignore-path-with-draft.js && node tests/test-pattern-matching.js && node tests/test-preserve-directory-structure-passthrough.js && node tests/test-route-resolution-helpers.js",
"test": "npm run build && npm run test:unit && npm run test:integration"
},
"dependencies": {
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ function readDocsPluginConfigs(siteConfig: unknown): DocsPluginConfig[] {
* - a version is served at `/<routeBasePath>/<versionPath>/`, where the
* version path is its configured `path`, else '' for the last version,
* 'next' for `current`, and the version name otherwise
* - a version's label is its configured `label`, else 'Next' for `current`
* and the version name otherwise (`getVersionLabel`)
* Each version writes its files under `<outDir>/<versionPath>/`, so the version
* served at the unprefixed route owns the root files.
*/
Expand Down Expand Up @@ -666,7 +668,10 @@ function detectVersions(
];
}

return { name, label: meta.label, docsDir, path: versionPath, routePrefix: '' };
// Docusaurus labels a version with its configured label, else 'Next' for
// the current docs and the version name otherwise.
const label = meta.label ?? (name === 'current' ? 'Next' : name);
return { name, label, docsDir, path: versionPath, routePrefix: '' };
});
}

Expand Down
26 changes: 16 additions & 10 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ export async function processMarkdownFile(
const content = await readFile(contentFilePath);
const { data, content: markdownContent } = matter(content);

// Skip draft files (accept both boolean true and the string "true", which
// some editors emit as quoted frontmatter).
if (data.draft === true || data.draft === 'true') {
// Skip draft files. Docusaurus validates `draft` as a Joi boolean with
// conversion, so the string "true" in any letter case is a draft too.
if (
data.draft === true ||
(typeof data.draft === 'string' && data.draft.toLowerCase() === 'true')
) {
return null;
}

Expand Down Expand Up @@ -526,14 +529,17 @@ async function resolveDocumentUrl(

// In multi-version mode, restrict matching to routes owned by this version so
// links resolve within the correct subtree (e.g. a 'stable' doc links to
// /stable/... and the root version's links avoid versioned subtrees).
// /stable/... and the root version's links avoid versioned subtrees). Blog
// posts aren't versioned, so they match the blog's routes in any version.
const basePath = getSiteBasePath(context.siteUrl);
let scopedRoutes = scopeRoutesToVersion(
context.routesPaths,
basePath,
context.routePrefix,
context.siblingPrefixes,
);
let scopedRoutes = isBlogFile
? context.routesPaths
: scopeRoutesToVersion(
context.routesPaths,
basePath,
context.routePrefix,
context.siblingPrefixes,
);

// The section's root route, relative to the baseUrl. Routes beneath it
// belong to this section; the blog isn't versioned.
Expand Down
282 changes: 0 additions & 282 deletions tests/test-array-bounds-checking.js

This file was deleted.

Loading
Loading