@docusaurus/plugin-content-docs 0.0.0-4561 → 0.0.0-4566
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/docFrontMatter.js +1 -0
- package/lib/lastUpdate.js +13 -34
- package/lib/props.js +2 -1
- package/lib/types.d.ts +1 -0
- package/package.json +10 -10
- package/src/docFrontMatter.ts +1 -0
- package/src/lastUpdate.ts +13 -47
- package/src/plugin-content-docs.d.ts +0 -57
- package/src/props.ts +2 -1
- package/src/types.ts +1 -0
package/lib/docFrontMatter.js
CHANGED
|
@@ -24,6 +24,7 @@ const DocFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
|
|
|
24
24
|
sidebar_label: utils_validation_1.JoiFrontMatter.string(),
|
|
25
25
|
sidebar_position: utils_validation_1.JoiFrontMatter.number(),
|
|
26
26
|
sidebar_class_name: utils_validation_1.JoiFrontMatter.string(),
|
|
27
|
+
sidebar_custom_props: utils_validation_1.JoiFrontMatter.object().unknown(),
|
|
27
28
|
displayed_sidebar: utils_validation_1.JoiFrontMatter.string().allow(null),
|
|
28
29
|
tags: utils_validation_1.FrontMatterTagsSchema,
|
|
29
30
|
pagination_label: utils_validation_1.JoiFrontMatter.string(),
|
package/lib/lastUpdate.js
CHANGED
|
@@ -8,52 +8,31 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getFileLastUpdate = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
|
|
12
11
|
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
13
|
-
const
|
|
14
|
-
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(?<timestamp>\d+),(?<author>.+)$/;
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
13
|
let showedGitRequirementError = false;
|
|
16
14
|
async function getFileLastUpdate(filePath) {
|
|
17
15
|
if (!filePath) {
|
|
18
16
|
return null;
|
|
19
17
|
}
|
|
20
|
-
function getTimestampAndAuthor(str) {
|
|
21
|
-
var _a;
|
|
22
|
-
if (!str) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const temp = (_a = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX)) === null || _a === void 0 ? void 0 : _a.groups;
|
|
26
|
-
return temp
|
|
27
|
-
? { timestamp: Number(temp.timestamp), author: temp.author }
|
|
28
|
-
: null;
|
|
29
|
-
}
|
|
30
18
|
// Wrap in try/catch in case the shell commands fail
|
|
31
19
|
// (e.g. project doesn't use Git, etc).
|
|
32
20
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
logger_1.default.warn('Sorry, the docs plugin last update options require Git.');
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
if (!shelljs_1.default.test('-f', filePath)) {
|
|
41
|
-
throw new Error(`Retrieval of git history failed at "${filePath}" because the file does not exist.`);
|
|
42
|
-
}
|
|
43
|
-
const fileBasename = path_1.default.basename(filePath);
|
|
44
|
-
const fileDirname = path_1.default.dirname(filePath);
|
|
45
|
-
const result = shelljs_1.default.exec(`git log --max-count=1 --format=%ct,%an -- "${fileBasename}"`, {
|
|
46
|
-
cwd: fileDirname,
|
|
47
|
-
silent: true,
|
|
21
|
+
const result = (0, utils_1.getFileCommitDate)(filePath, {
|
|
22
|
+
age: 'newest',
|
|
23
|
+
includeAuthor: true,
|
|
48
24
|
});
|
|
49
|
-
|
|
50
|
-
throw new Error(`Retrieval of git history failed at "${filePath}" with exit code ${result.code}: ${result.stderr}`);
|
|
51
|
-
}
|
|
52
|
-
return getTimestampAndAuthor(result.stdout.trim());
|
|
25
|
+
return { timestamp: result.timestamp, author: result.author };
|
|
53
26
|
}
|
|
54
27
|
catch (e) {
|
|
55
|
-
|
|
28
|
+
if (e instanceof utils_1.GitNotFoundError && !showedGitRequirementError) {
|
|
29
|
+
logger_1.default.warn('Sorry, the docs plugin last update options require Git.');
|
|
30
|
+
showedGitRequirementError = true;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
logger_1.default.error(e);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
56
36
|
}
|
|
57
|
-
return null;
|
|
58
37
|
}
|
|
59
38
|
exports.getFileLastUpdate = getFileLastUpdate;
|
package/lib/props.js
CHANGED
|
@@ -21,6 +21,7 @@ Available document ids are:
|
|
|
21
21
|
return docMetadata;
|
|
22
22
|
}
|
|
23
23
|
const convertDocLink = (item) => {
|
|
24
|
+
var _a;
|
|
24
25
|
const docMetadata = getDocById(item.id);
|
|
25
26
|
const { title, permalink, frontMatter: { sidebar_label: sidebarLabel }, } = docMetadata;
|
|
26
27
|
return {
|
|
@@ -28,7 +29,7 @@ Available document ids are:
|
|
|
28
29
|
label: sidebarLabel || item.label || title,
|
|
29
30
|
href: permalink,
|
|
30
31
|
className: item.className,
|
|
31
|
-
customProps: item.customProps,
|
|
32
|
+
customProps: (_a = item.customProps) !== null && _a !== void 0 ? _a : docMetadata.frontMatter.sidebar_custom_props,
|
|
32
33
|
docId: docMetadata.unversionedId,
|
|
33
34
|
};
|
|
34
35
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare type DocFrontMatter = {
|
|
|
47
47
|
sidebar_label?: string;
|
|
48
48
|
sidebar_position?: number;
|
|
49
49
|
sidebar_class_name?: string;
|
|
50
|
+
sidebar_custom_props?: Record<string, unknown>;
|
|
50
51
|
displayed_sidebar?: string | null;
|
|
51
52
|
pagination_label?: string;
|
|
52
53
|
custom_edit_url?: string | null;
|
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-4566",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/logger": "0.0.0-
|
|
28
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
29
|
-
"@docusaurus/utils": "0.0.0-
|
|
30
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4566",
|
|
27
|
+
"@docusaurus/logger": "0.0.0-4566",
|
|
28
|
+
"@docusaurus/mdx-loader": "0.0.0-4566",
|
|
29
|
+
"@docusaurus/utils": "0.0.0-4566",
|
|
30
|
+
"@docusaurus/utils-validation": "0.0.0-4566",
|
|
31
31
|
"combine-promises": "^1.1.0",
|
|
32
32
|
"fs-extra": "^10.0.0",
|
|
33
33
|
"import-fresh": "^3.2.2",
|
|
34
34
|
"js-yaml": "^4.0.0",
|
|
35
35
|
"lodash": "^4.17.20",
|
|
36
36
|
"remark-admonitions": "^1.2.1",
|
|
37
|
-
"shelljs": "^0.8.4",
|
|
38
37
|
"tslib": "^2.3.1",
|
|
39
38
|
"utility-types": "^3.10.0",
|
|
40
39
|
"webpack": "^5.68.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
44
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/module-type-aliases": "0.0.0-4566",
|
|
43
|
+
"@docusaurus/types": "0.0.0-4566",
|
|
45
44
|
"@types/js-yaml": "^4.0.0",
|
|
46
45
|
"@types/picomatch": "^2.2.1",
|
|
47
46
|
"commander": "^5.1.0",
|
|
48
47
|
"escape-string-regexp": "^4.0.0",
|
|
49
48
|
"picomatch": "^2.1.1",
|
|
49
|
+
"shelljs": "^0.8.4",
|
|
50
50
|
"utility-types": "^3.10.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=14"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9f29e9998cf84adba25ceabd263fb637537d0033"
|
|
60
60
|
}
|
package/src/docFrontMatter.ts
CHANGED
|
@@ -30,6 +30,7 @@ const DocFrontMatterSchema = Joi.object<DocFrontMatter>({
|
|
|
30
30
|
sidebar_label: Joi.string(),
|
|
31
31
|
sidebar_position: Joi.number(),
|
|
32
32
|
sidebar_class_name: Joi.string(),
|
|
33
|
+
sidebar_custom_props: Joi.object().unknown(),
|
|
33
34
|
displayed_sidebar: Joi.string().allow(null),
|
|
34
35
|
tags: FrontMatterTagsSchema,
|
|
35
36
|
pagination_label: Joi.string(),
|
package/src/lastUpdate.ts
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import shell from 'shelljs';
|
|
9
8
|
import logger from '@docusaurus/logger';
|
|
10
|
-
import
|
|
9
|
+
import {getFileCommitDate, GitNotFoundError} from '@docusaurus/utils';
|
|
11
10
|
|
|
12
11
|
type FileLastUpdateData = {timestamp?: number; author?: string};
|
|
13
12
|
|
|
14
|
-
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(?<timestamp>\d+),(?<author>.+)$/;
|
|
15
|
-
|
|
16
13
|
let showedGitRequirementError = false;
|
|
17
14
|
|
|
18
15
|
export async function getFileLastUpdate(
|
|
@@ -21,53 +18,22 @@ export async function getFileLastUpdate(
|
|
|
21
18
|
if (!filePath) {
|
|
22
19
|
return null;
|
|
23
20
|
}
|
|
24
|
-
function getTimestampAndAuthor(str: string): FileLastUpdateData | null {
|
|
25
|
-
if (!str) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const temp = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX)?.groups;
|
|
30
|
-
return temp
|
|
31
|
-
? {timestamp: Number(temp.timestamp), author: temp.author}
|
|
32
|
-
: null;
|
|
33
|
-
}
|
|
34
21
|
|
|
35
22
|
// Wrap in try/catch in case the shell commands fail
|
|
36
23
|
// (e.g. project doesn't use Git, etc).
|
|
37
24
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!shell.test('-f', filePath)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Retrieval of git history failed at "${filePath}" because the file does not exist.`,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const fileBasename = path.basename(filePath);
|
|
54
|
-
const fileDirname = path.dirname(filePath);
|
|
55
|
-
const result = shell.exec(
|
|
56
|
-
`git log --max-count=1 --format=%ct,%an -- "${fileBasename}"`,
|
|
57
|
-
{
|
|
58
|
-
cwd: fileDirname, // this is needed: https://github.com/facebook/docusaurus/pull/5048
|
|
59
|
-
silent: true,
|
|
60
|
-
},
|
|
61
|
-
);
|
|
62
|
-
if (result.code !== 0) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Retrieval of git history failed at "${filePath}" with exit code ${result.code}: ${result.stderr}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return getTimestampAndAuthor(result.stdout.trim());
|
|
25
|
+
const result = getFileCommitDate(filePath, {
|
|
26
|
+
age: 'newest',
|
|
27
|
+
includeAuthor: true,
|
|
28
|
+
});
|
|
29
|
+
return {timestamp: result.timestamp, author: result.author};
|
|
68
30
|
} catch (e) {
|
|
69
|
-
|
|
31
|
+
if (e instanceof GitNotFoundError && !showedGitRequirementError) {
|
|
32
|
+
logger.warn('Sorry, the docs plugin last update options require Git.');
|
|
33
|
+
showedGitRequirementError = true;
|
|
34
|
+
} else {
|
|
35
|
+
logger.error(e);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
70
38
|
}
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
39
|
}
|
|
@@ -209,26 +209,6 @@ declare module '@theme/DocItem' {
|
|
|
209
209
|
export default DocItem;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
declare module '@theme/DocCard' {
|
|
213
|
-
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
214
|
-
|
|
215
|
-
export interface Props {
|
|
216
|
-
readonly item: PropSidebarItem;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export default function DocCard(props: Props): JSX.Element;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
declare module '@theme/DocCardList' {
|
|
223
|
-
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
224
|
-
|
|
225
|
-
export interface Props {
|
|
226
|
-
readonly items: PropSidebarItem[];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export default function DocCardList(props: Props): JSX.Element;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
212
|
declare module '@theme/DocCategoryGeneratedIndexPage' {
|
|
233
213
|
import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
|
|
234
214
|
|
|
@@ -241,12 +221,6 @@ declare module '@theme/DocCategoryGeneratedIndexPage' {
|
|
|
241
221
|
): JSX.Element;
|
|
242
222
|
}
|
|
243
223
|
|
|
244
|
-
declare module '@theme/DocItemFooter' {
|
|
245
|
-
import type {Props} from '@theme/DocItem';
|
|
246
|
-
|
|
247
|
-
export default function DocItemFooter(props: Props): JSX.Element;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
224
|
declare module '@theme/DocTagsListPage' {
|
|
251
225
|
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
|
|
252
226
|
|
|
@@ -263,22 +237,6 @@ declare module '@theme/DocTagDocListPage' {
|
|
|
263
237
|
export default function DocTagDocListPage(props: Props): JSX.Element;
|
|
264
238
|
}
|
|
265
239
|
|
|
266
|
-
declare module '@theme/DocVersionBanner' {
|
|
267
|
-
export interface Props {
|
|
268
|
-
readonly className?: string;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export default function DocVersionBanner(props: Props): JSX.Element;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
declare module '@theme/DocVersionBadge' {
|
|
275
|
-
export interface Props {
|
|
276
|
-
readonly className?: string;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export default function DocVersionBadge(props: Props): JSX.Element;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
240
|
declare module '@theme/DocPage' {
|
|
283
241
|
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
284
242
|
import type {DocumentRoute} from '@theme/DocItem';
|
|
@@ -297,21 +255,6 @@ declare module '@theme/DocPage' {
|
|
|
297
255
|
export default DocPage;
|
|
298
256
|
}
|
|
299
257
|
|
|
300
|
-
declare module '@theme/Seo' {
|
|
301
|
-
import type {ReactNode} from 'react';
|
|
302
|
-
|
|
303
|
-
export interface Props {
|
|
304
|
-
readonly title?: string;
|
|
305
|
-
readonly description?: string;
|
|
306
|
-
readonly keywords?: readonly string[] | string;
|
|
307
|
-
readonly image?: string;
|
|
308
|
-
readonly children?: ReactNode;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const Seo: (props: Props) => JSX.Element;
|
|
312
|
-
export default Seo;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
258
|
// TODO until TS supports exports field... hope it's in 4.6
|
|
316
259
|
declare module '@docusaurus/plugin-content-docs/client' {
|
|
317
260
|
export type ActivePlugin = {
|
package/src/props.ts
CHANGED
|
@@ -52,7 +52,8 @@ Available document ids are:
|
|
|
52
52
|
label: sidebarLabel || item.label || title,
|
|
53
53
|
href: permalink,
|
|
54
54
|
className: item.className,
|
|
55
|
-
customProps:
|
|
55
|
+
customProps:
|
|
56
|
+
item.customProps ?? docMetadata.frontMatter.sidebar_custom_props,
|
|
56
57
|
docId: docMetadata.unversionedId,
|
|
57
58
|
};
|
|
58
59
|
};
|
package/src/types.ts
CHANGED
|
@@ -58,6 +58,7 @@ export type DocFrontMatter = {
|
|
|
58
58
|
sidebar_label?: string;
|
|
59
59
|
sidebar_position?: number;
|
|
60
60
|
sidebar_class_name?: string;
|
|
61
|
+
sidebar_custom_props?: Record<string, unknown>;
|
|
61
62
|
displayed_sidebar?: string | null;
|
|
62
63
|
pagination_label?: string;
|
|
63
64
|
custom_edit_url?: string | null;
|