@docusaurus/plugin-content-docs 0.0.0-4466 → 0.0.0-4484
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/lib/docs.js +4 -4
- package/lib/slug.d.ts +2 -2
- package/lib/slug.js +7 -7
- package/lib/translations.js +1 -1
- package/package.json +9 -9
- package/src/docFrontMatter.ts +1 -1
- package/src/docs.ts +4 -4
- package/src/slug.ts +8 -8
- package/src/translations.ts +1 -1
package/lib/docs.js
CHANGED
|
@@ -66,7 +66,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
|
|
|
66
66
|
const frontMatter = (0, docFrontMatter_1.validateDocFrontMatter)(unsafeFrontMatter);
|
|
67
67
|
const { custom_edit_url: customEditURL,
|
|
68
68
|
// Strip number prefixes by default (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc) by default,
|
|
69
|
-
// but allow to disable this behavior with
|
|
69
|
+
// but allow to disable this behavior with front matter
|
|
70
70
|
parse_number_prefixes: parseNumberPrefixes = true, } = frontMatter;
|
|
71
71
|
// ex: api/plugins/myDoc -> myDoc
|
|
72
72
|
// ex: myDoc -> myDoc
|
|
@@ -81,7 +81,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
|
|
|
81
81
|
if (baseID.includes('/')) {
|
|
82
82
|
throw new Error(`Document id "${baseID}" cannot include slash.`);
|
|
83
83
|
}
|
|
84
|
-
// For autogenerated sidebars, sidebar position can come from filename number prefix or
|
|
84
|
+
// For autogenerated sidebars, sidebar position can come from filename number prefix or front matter
|
|
85
85
|
const sidebarPosition = (_b = frontMatter.sidebar_position) !== null && _b !== void 0 ? _b : numberPrefix;
|
|
86
86
|
// TODO legacy retrocompatibility
|
|
87
87
|
// The same doc in 2 distinct version could keep the same id,
|
|
@@ -90,7 +90,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
|
|
|
90
90
|
? undefined
|
|
91
91
|
: `version-${versionMetadata.versionName}`;
|
|
92
92
|
// TODO legacy retrocompatibility
|
|
93
|
-
// I think it's bad to affect the
|
|
93
|
+
// I think it's bad to affect the front matter id with the dirname?
|
|
94
94
|
function computeDirNameIdPrefix() {
|
|
95
95
|
if (sourceDirName === '.') {
|
|
96
96
|
return undefined;
|
|
@@ -110,7 +110,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
|
|
|
110
110
|
baseID,
|
|
111
111
|
source,
|
|
112
112
|
sourceDirName,
|
|
113
|
-
|
|
113
|
+
frontMatterSlug: frontMatter.slug,
|
|
114
114
|
stripDirNumberPrefixes: parseNumberPrefixes,
|
|
115
115
|
numberPrefixParser: options.numberPrefixParser,
|
|
116
116
|
});
|
package/lib/slug.d.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { DocMetadataBase } from './types';
|
|
8
8
|
import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
|
|
9
|
-
export default function getSlug({ baseID,
|
|
9
|
+
export default function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes, numberPrefixParser, }: {
|
|
10
10
|
baseID: string;
|
|
11
|
-
|
|
11
|
+
frontMatterSlug?: string;
|
|
12
12
|
source: DocMetadataBase['slug'];
|
|
13
13
|
sourceDirName: DocMetadataBase['sourceDirName'];
|
|
14
14
|
stripDirNumberPrefixes?: boolean;
|
package/lib/slug.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const utils_1 = require("@docusaurus/utils");
|
|
10
10
|
const numberPrefix_1 = require("./numberPrefix");
|
|
11
11
|
const docs_1 = require("./docs");
|
|
12
|
-
function getSlug({ baseID,
|
|
12
|
+
function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes = true, numberPrefixParser = numberPrefix_1.DefaultNumberPrefixParser, }) {
|
|
13
13
|
function getDirNameSlug() {
|
|
14
14
|
const dirNameStripped = stripDirNumberPrefixes
|
|
15
15
|
? (0, numberPrefix_1.stripPathNumberPrefixes)(sourceDirName, numberPrefixParser)
|
|
@@ -20,15 +20,15 @@ function getSlug({ baseID, frontmatterSlug, source, sourceDirName, stripDirNumbe
|
|
|
20
20
|
return resolveDirname;
|
|
21
21
|
}
|
|
22
22
|
function computeSlug() {
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
23
|
+
if (frontMatterSlug === null || frontMatterSlug === void 0 ? void 0 : frontMatterSlug.startsWith('/')) {
|
|
24
|
+
return frontMatterSlug;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
const dirNameSlug = getDirNameSlug();
|
|
28
|
-
if (!
|
|
28
|
+
if (!frontMatterSlug && (0, docs_1.isConventionalDocIndex)({ source, sourceDirName })) {
|
|
29
29
|
return dirNameSlug;
|
|
30
30
|
}
|
|
31
|
-
const baseSlug =
|
|
31
|
+
const baseSlug = frontMatterSlug || baseID;
|
|
32
32
|
return (0, utils_1.resolvePathname)(baseSlug, getDirNameSlug());
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -36,8 +36,8 @@ function getSlug({ baseID, frontmatterSlug, source, sourceDirName, stripDirNumbe
|
|
|
36
36
|
if (!(0, utils_1.isValidPathname)(slug)) {
|
|
37
37
|
throw new Error(`We couldn't compute a valid slug for document with id "${baseID}" in "${sourceDirName}" directory.
|
|
38
38
|
The slug we computed looks invalid: ${slug}.
|
|
39
|
-
Maybe your slug
|
|
40
|
-
By using the slug
|
|
39
|
+
Maybe your slug front matter is incorrect or you use weird chars in the file path?
|
|
40
|
+
By using the slug front matter, you should be able to fix this error, by using the slug of your choice:
|
|
41
41
|
|
|
42
42
|
Example =>
|
|
43
43
|
---
|
package/lib/translations.js
CHANGED
|
@@ -33,7 +33,7 @@ function getNormalizedSidebarName({ versionName, sidebarName, }) {
|
|
|
33
33
|
}
|
|
34
34
|
/*
|
|
35
35
|
// Do we need to translate doc metadata?
|
|
36
|
-
// It seems translating
|
|
36
|
+
// It seems translating front matter labels is good enough
|
|
37
37
|
function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
38
38
|
return {
|
|
39
39
|
[`${doc.unversionedId}.title`]: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4484",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@docusaurus/core": "0.0.0-
|
|
26
|
-
"@docusaurus/logger": "0.0.0-
|
|
27
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
28
|
-
"@docusaurus/utils": "0.0.0-
|
|
29
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
25
|
+
"@docusaurus/core": "0.0.0-4484",
|
|
26
|
+
"@docusaurus/logger": "0.0.0-4484",
|
|
27
|
+
"@docusaurus/mdx-loader": "0.0.0-4484",
|
|
28
|
+
"@docusaurus/utils": "0.0.0-4484",
|
|
29
|
+
"@docusaurus/utils-validation": "0.0.0-4484",
|
|
30
30
|
"combine-promises": "^1.1.0",
|
|
31
31
|
"fs-extra": "^10.0.0",
|
|
32
32
|
"import-fresh": "^3.2.2",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"webpack": "^5.61.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
43
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/module-type-aliases": "0.0.0-4484",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4484",
|
|
44
44
|
"@types/js-yaml": "^4.0.0",
|
|
45
45
|
"@types/picomatch": "^2.2.1",
|
|
46
46
|
"commander": "^5.1.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=14"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ae60bd68f83e8063d4467fc31fa2c42432a5deeb"
|
|
59
59
|
}
|
package/src/docFrontMatter.ts
CHANGED
package/src/docs.ts
CHANGED
|
@@ -138,7 +138,7 @@ function doProcessDocMetadata({
|
|
|
138
138
|
custom_edit_url: customEditURL,
|
|
139
139
|
|
|
140
140
|
// Strip number prefixes by default (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc) by default,
|
|
141
|
-
// but allow to disable this behavior with
|
|
141
|
+
// but allow to disable this behavior with front matter
|
|
142
142
|
parse_number_prefixes: parseNumberPrefixes = true,
|
|
143
143
|
} = frontMatter;
|
|
144
144
|
|
|
@@ -162,7 +162,7 @@ function doProcessDocMetadata({
|
|
|
162
162
|
throw new Error(`Document id "${baseID}" cannot include slash.`);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
// For autogenerated sidebars, sidebar position can come from filename number prefix or
|
|
165
|
+
// For autogenerated sidebars, sidebar position can come from filename number prefix or front matter
|
|
166
166
|
const sidebarPosition: number | undefined =
|
|
167
167
|
frontMatter.sidebar_position ?? numberPrefix;
|
|
168
168
|
|
|
@@ -175,7 +175,7 @@ function doProcessDocMetadata({
|
|
|
175
175
|
: `version-${versionMetadata.versionName}`;
|
|
176
176
|
|
|
177
177
|
// TODO legacy retrocompatibility
|
|
178
|
-
// I think it's bad to affect the
|
|
178
|
+
// I think it's bad to affect the front matter id with the dirname?
|
|
179
179
|
function computeDirNameIdPrefix() {
|
|
180
180
|
if (sourceDirName === '.') {
|
|
181
181
|
return undefined;
|
|
@@ -198,7 +198,7 @@ function doProcessDocMetadata({
|
|
|
198
198
|
baseID,
|
|
199
199
|
source,
|
|
200
200
|
sourceDirName,
|
|
201
|
-
|
|
201
|
+
frontMatterSlug: frontMatter.slug,
|
|
202
202
|
stripDirNumberPrefixes: parseNumberPrefixes,
|
|
203
203
|
numberPrefixParser: options.numberPrefixParser,
|
|
204
204
|
});
|
package/src/slug.ts
CHANGED
|
@@ -21,14 +21,14 @@ import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
|
|
|
21
21
|
|
|
22
22
|
export default function getSlug({
|
|
23
23
|
baseID,
|
|
24
|
-
|
|
24
|
+
frontMatterSlug,
|
|
25
25
|
source,
|
|
26
26
|
sourceDirName,
|
|
27
27
|
stripDirNumberPrefixes = true,
|
|
28
28
|
numberPrefixParser = DefaultNumberPrefixParser,
|
|
29
29
|
}: {
|
|
30
30
|
baseID: string;
|
|
31
|
-
|
|
31
|
+
frontMatterSlug?: string;
|
|
32
32
|
source: DocMetadataBase['slug'];
|
|
33
33
|
sourceDirName: DocMetadataBase['sourceDirName'];
|
|
34
34
|
stripDirNumberPrefixes?: boolean;
|
|
@@ -46,14 +46,14 @@ export default function getSlug({
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function computeSlug(): string {
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
49
|
+
if (frontMatterSlug?.startsWith('/')) {
|
|
50
|
+
return frontMatterSlug;
|
|
51
51
|
} else {
|
|
52
52
|
const dirNameSlug = getDirNameSlug();
|
|
53
|
-
if (!
|
|
53
|
+
if (!frontMatterSlug && isConventionalDocIndex({source, sourceDirName})) {
|
|
54
54
|
return dirNameSlug;
|
|
55
55
|
}
|
|
56
|
-
const baseSlug =
|
|
56
|
+
const baseSlug = frontMatterSlug || baseID;
|
|
57
57
|
return resolvePathname(baseSlug, getDirNameSlug());
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -63,8 +63,8 @@ export default function getSlug({
|
|
|
63
63
|
throw new Error(
|
|
64
64
|
`We couldn't compute a valid slug for document with id "${baseID}" in "${sourceDirName}" directory.
|
|
65
65
|
The slug we computed looks invalid: ${slug}.
|
|
66
|
-
Maybe your slug
|
|
67
|
-
By using the slug
|
|
66
|
+
Maybe your slug front matter is incorrect or you use weird chars in the file path?
|
|
67
|
+
By using the slug front matter, you should be able to fix this error, by using the slug of your choice:
|
|
68
68
|
|
|
69
69
|
Example =>
|
|
70
70
|
---
|
package/src/translations.ts
CHANGED
|
@@ -57,7 +57,7 @@ function getNormalizedSidebarName({
|
|
|
57
57
|
|
|
58
58
|
/*
|
|
59
59
|
// Do we need to translate doc metadata?
|
|
60
|
-
// It seems translating
|
|
60
|
+
// It seems translating front matter labels is good enough
|
|
61
61
|
function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
62
62
|
return {
|
|
63
63
|
[`${doc.unversionedId}.title`]: {
|