@docusaurus/utils 3.4.0 → 3.5.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/lib/cliUtils.js +1 -2
- package/lib/cliUtils.js.map +1 -1
- package/lib/contentVisibilityUtils.js +2 -3
- package/lib/contentVisibilityUtils.js.map +1 -1
- package/lib/dataFileUtils.d.ts +6 -7
- package/lib/dataFileUtils.d.ts.map +1 -1
- package/lib/dataFileUtils.js +14 -14
- package/lib/dataFileUtils.js.map +1 -1
- package/lib/emitUtils.d.ts +0 -1
- package/lib/emitUtils.d.ts.map +1 -1
- package/lib/emitUtils.js +2 -3
- package/lib/emitUtils.js.map +1 -1
- package/lib/gitUtils.js +2 -2
- package/lib/gitUtils.js.map +1 -1
- package/lib/globUtils.js +3 -3
- package/lib/globUtils.js.map +1 -1
- package/lib/hashUtils.js +3 -4
- package/lib/hashUtils.js.map +1 -1
- package/lib/i18nUtils.js +4 -5
- package/lib/i18nUtils.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/jsUtils.js +2 -3
- package/lib/jsUtils.js.map +1 -1
- package/lib/lastUpdateUtils.js +4 -4
- package/lib/lastUpdateUtils.js.map +1 -1
- package/lib/markdownLinks.js +1 -2
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownUtils.js +12 -12
- package/lib/markdownUtils.js.map +1 -1
- package/lib/moduleUtils.js +1 -2
- package/lib/moduleUtils.js.map +1 -1
- package/lib/pathUtils.js +8 -8
- package/lib/pathUtils.js.map +1 -1
- package/lib/regExpUtils.js +1 -2
- package/lib/regExpUtils.js.map +1 -1
- package/lib/routeUtils.js +1 -2
- package/lib/routeUtils.js.map +1 -1
- package/lib/shellUtils.js +1 -2
- package/lib/shellUtils.js.map +1 -1
- package/lib/slugger.js +1 -2
- package/lib/slugger.js.map +1 -1
- package/lib/tags.d.ts +1 -1
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +5 -6
- package/lib/tags.js.map +1 -1
- package/lib/urlUtils.js +14 -15
- package/lib/urlUtils.js.map +1 -1
- package/lib/webpackUtils.js +2 -3
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/dataFileUtils.ts +12 -14
- package/src/index.ts +1 -1
- package/src/markdownUtils.ts +2 -2
- package/src/tags.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.
|
|
22
|
-
"@docusaurus/utils-common": "3.
|
|
21
|
+
"@docusaurus/logger": "3.5.0",
|
|
22
|
+
"@docusaurus/utils-common": "3.5.0",
|
|
23
23
|
"@svgr/webpack": "^8.1.0",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"file-loader": "^6.2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"node": ">=18.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@docusaurus/types": "3.
|
|
46
|
+
"@docusaurus/types": "3.5.0",
|
|
47
47
|
"@types/dedent": "^0.7.0",
|
|
48
48
|
"@types/github-slugger": "^1.3.0",
|
|
49
49
|
"@types/micromatch": "^4.0.2",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"optional": true
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cb5829f3c34b26d798b869e38ee25073488140bd"
|
|
63
63
|
}
|
package/src/dataFileUtils.ts
CHANGED
|
@@ -43,30 +43,28 @@ export async function getDataFilePath({
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Looks up for a data file in the content paths
|
|
47
|
-
*
|
|
46
|
+
* Looks up for a data file in the content paths
|
|
47
|
+
* Favors the localized content path over the base content path
|
|
48
|
+
* Currently supports Yaml and JSON data files
|
|
49
|
+
* It is the caller responsibility to validate and normalize the resulting data
|
|
48
50
|
*
|
|
49
51
|
* @returns `undefined` when file not found
|
|
50
|
-
* @throws Throws when
|
|
52
|
+
* @throws Throws when data file can't be parsed
|
|
51
53
|
*/
|
|
52
|
-
export async function
|
|
53
|
-
params: DataFileParams & {
|
|
54
|
-
/** Used for the "The X file looks invalid" message. */
|
|
55
|
-
fileType: string;
|
|
56
|
-
},
|
|
57
|
-
validate: (content: unknown) => T,
|
|
58
|
-
): Promise<T | undefined> {
|
|
54
|
+
export async function readDataFile(params: DataFileParams): Promise<unknown> {
|
|
59
55
|
const filePath = await getDataFilePath(params);
|
|
60
56
|
if (!filePath) {
|
|
61
57
|
return undefined;
|
|
62
58
|
}
|
|
63
59
|
try {
|
|
64
60
|
const contentString = await fs.readFile(filePath, {encoding: 'utf8'});
|
|
65
|
-
|
|
66
|
-
return validate(unsafeContent);
|
|
61
|
+
return Yaml.load(contentString);
|
|
67
62
|
} catch (err) {
|
|
68
|
-
logger.
|
|
69
|
-
|
|
63
|
+
const msg = logger.interpolate`The file at path=${path.relative(
|
|
64
|
+
process.cwd(),
|
|
65
|
+
filePath,
|
|
66
|
+
)} looks invalid (not Yaml nor JSON).`;
|
|
67
|
+
throw new Error(msg, {cause: err as Error});
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
|
package/src/index.ts
CHANGED
package/src/markdownUtils.ts
CHANGED
|
@@ -70,9 +70,9 @@ export function escapeMarkdownHeadingIds(content: string): string {
|
|
|
70
70
|
export function unwrapMdxCodeBlocks(content: string): string {
|
|
71
71
|
// We only support 3/4 backticks on purpose, should be good enough
|
|
72
72
|
const regexp3 =
|
|
73
|
-
/(?<begin>^|\r?\n)```(?<spaces>\x20*)mdx-code-block\r?\n(?<children>.*?)\r?\n```(?<end>\r?\n|$)/gs;
|
|
73
|
+
/(?<begin>^|\r?\n)(?<indentStart>\x20*)```(?<spaces>\x20*)mdx-code-block\r?\n(?<children>.*?)\r?\n(?<indentEnd>\x20*)```(?<end>\r?\n|$)/gs;
|
|
74
74
|
const regexp4 =
|
|
75
|
-
/(?<begin>^|\r?\n)````(?<spaces>\x20*)mdx-code-block\r?\n(?<children>.*?)\r?\n````(?<end>\r?\n|$)/gs;
|
|
75
|
+
/(?<begin>^|\r?\n)(?<indentStart>\x20*)````(?<spaces>\x20*)mdx-code-block\r?\n(?<children>.*?)\r?\n(?<indentEnd>\x20*)````(?<end>\r?\n|$)/gs;
|
|
76
76
|
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
78
|
const replacer = (substring: string, ...args: any[]) => {
|
package/src/tags.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type TagsPluginOptions = {
|
|
|
28
28
|
// TODO allow option tags later? | TagsFile;
|
|
29
29
|
/** Path to the tags file. */
|
|
30
30
|
tags: string | false | null | undefined;
|
|
31
|
-
/** The behavior of Docusaurus when it
|
|
31
|
+
/** The behavior of Docusaurus when it finds inline tags. */
|
|
32
32
|
onInlineTags: 'ignore' | 'log' | 'warn' | 'throw';
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -45,6 +45,7 @@ export type TagsListItem = Tag & {
|
|
|
45
45
|
/** What the tag's own page should know about the tag. */
|
|
46
46
|
export type TagModule = TagsListItem & {
|
|
47
47
|
/** The tags list page's permalink. */
|
|
48
|
+
// TODO move this global value to a shared docs/blog bundle
|
|
48
49
|
allTagsPath: string;
|
|
49
50
|
/** Is this tag unlisted? (when it only contains unlisted items) */
|
|
50
51
|
unlisted: boolean;
|