@docusaurus/plugin-content-docs 0.0.0-5899 → 0.0.0-5900
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/index.js +3 -0
- package/lib/routes.js +22 -29
- package/package.json +10 -10
- package/src/index.ts +3 -0
- package/src/routes.ts +21 -50
package/lib/index.js
CHANGED
|
@@ -30,6 +30,9 @@ async function pluginContentDocs(context, options) {
|
|
|
30
30
|
const pluginId = options.id;
|
|
31
31
|
const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
|
|
32
32
|
const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
|
|
33
|
+
// TODO Docusaurus v4 breaking change
|
|
34
|
+
// module aliasing should be automatic
|
|
35
|
+
// we should never find local absolute FS paths in the codegen registry
|
|
33
36
|
const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
|
|
34
37
|
// TODO env should be injected into all plugins
|
|
35
38
|
const env = process.env.NODE_ENV;
|
package/lib/routes.js
CHANGED
|
@@ -19,22 +19,20 @@ function createDocRouteMetadata(docMeta) {
|
|
|
19
19
|
lastUpdatedAt: docMeta.lastUpdatedAt,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
async function buildVersionCategoryGeneratedIndexRoutes({ version,
|
|
23
|
-
const slugs = (0, utils_1.createSlugger)();
|
|
22
|
+
async function buildVersionCategoryGeneratedIndexRoutes({ version, options, }) {
|
|
24
23
|
async function buildCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
|
|
25
|
-
const { sidebar, ...prop } = categoryGeneratedIndex;
|
|
26
|
-
const propFileName = slugs.slug(`${version.path}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`);
|
|
27
|
-
const propData = await actions.createData(`${(0, utils_1.docuHash)(`category/${propFileName}`)}.json`, JSON.stringify(prop, null, 2));
|
|
28
24
|
return {
|
|
29
25
|
path: categoryGeneratedIndex.permalink,
|
|
30
26
|
component: options.docCategoryGeneratedIndexComponent,
|
|
31
27
|
exact: true,
|
|
32
|
-
|
|
33
|
-
categoryGeneratedIndex
|
|
28
|
+
props: {
|
|
29
|
+
categoryGeneratedIndex,
|
|
34
30
|
},
|
|
35
31
|
// Same as doc, this sidebar route attribute permits to associate this
|
|
36
32
|
// subpage to the given sidebar
|
|
37
|
-
...(sidebar && {
|
|
33
|
+
...(categoryGeneratedIndex.sidebar && {
|
|
34
|
+
sidebar: categoryGeneratedIndex.sidebar,
|
|
35
|
+
}),
|
|
38
36
|
};
|
|
39
37
|
}
|
|
40
38
|
return Promise.all(version.categoryGeneratedIndices.map(buildCategoryGeneratedIndexRoute));
|
|
@@ -44,7 +42,7 @@ async function buildVersionDocRoutes({ version, actions, options, }) {
|
|
|
44
42
|
await actions.createData(
|
|
45
43
|
// Note that this created data path must be in sync with
|
|
46
44
|
// metadataPath provided to mdx-loader.
|
|
47
|
-
`${(0, utils_1.docuHash)(doc.source)}.json`,
|
|
45
|
+
`${(0, utils_1.docuHash)(doc.source)}.json`, doc);
|
|
48
46
|
const docRoute = {
|
|
49
47
|
path: doc.permalink,
|
|
50
48
|
component: options.docItemComponent,
|
|
@@ -77,37 +75,33 @@ async function buildVersionSidebarRoute(param) {
|
|
|
77
75
|
};
|
|
78
76
|
}
|
|
79
77
|
async function buildVersionTagsRoutes(param) {
|
|
80
|
-
const { version, options
|
|
78
|
+
const { version, options } = param;
|
|
81
79
|
const versionTags = (0, tags_1.getVersionTags)(version.docs);
|
|
82
80
|
async function buildTagsListRoute() {
|
|
83
81
|
// Don't create a tags list page if there's no tag
|
|
84
82
|
if (Object.keys(versionTags).length === 0) {
|
|
85
83
|
return null;
|
|
86
84
|
}
|
|
87
|
-
const tagsProp = (0, props_1.toTagsListTagsProp)(versionTags);
|
|
88
|
-
const tagsPropPath = await actions.createData(`${(0, utils_1.docuHash)(`tags-list-${version.versionName}-prop`)}.json`, JSON.stringify(tagsProp, null, 2));
|
|
89
85
|
return {
|
|
90
86
|
path: version.tagsPath,
|
|
91
87
|
exact: true,
|
|
92
88
|
component: options.docTagsListComponent,
|
|
93
|
-
|
|
94
|
-
tags:
|
|
89
|
+
props: {
|
|
90
|
+
tags: (0, props_1.toTagsListTagsProp)(versionTags),
|
|
95
91
|
},
|
|
96
92
|
};
|
|
97
93
|
}
|
|
98
94
|
async function buildTagDocListRoute(tag) {
|
|
99
|
-
const tagProps = (0, props_1.toTagDocListProp)({
|
|
100
|
-
allTagsPath: version.tagsPath,
|
|
101
|
-
tag,
|
|
102
|
-
docs: version.docs,
|
|
103
|
-
});
|
|
104
|
-
const tagPropPath = await actions.createData(`${(0, utils_1.docuHash)(`tag-${tag.permalink}`)}.json`, JSON.stringify(tagProps, null, 2));
|
|
105
95
|
return {
|
|
106
96
|
path: tag.permalink,
|
|
107
97
|
component: options.docTagDocListComponent,
|
|
108
98
|
exact: true,
|
|
109
|
-
|
|
110
|
-
tag:
|
|
99
|
+
props: {
|
|
100
|
+
tag: (0, props_1.toTagDocListProp)({
|
|
101
|
+
allTagsPath: version.tagsPath,
|
|
102
|
+
tag,
|
|
103
|
+
docs: version.docs,
|
|
104
|
+
}),
|
|
111
105
|
},
|
|
112
106
|
};
|
|
113
107
|
}
|
|
@@ -118,7 +112,7 @@ async function buildVersionTagsRoutes(param) {
|
|
|
118
112
|
return lodash_1.default.compact([tagsListRoute, ...allTagsDocListRoutes]);
|
|
119
113
|
}
|
|
120
114
|
async function buildVersionRoutes(param) {
|
|
121
|
-
const { version,
|
|
115
|
+
const { version, options } = param;
|
|
122
116
|
async function buildVersionSubRoutes() {
|
|
123
117
|
const [sidebarRoute, tagsRoutes] = await Promise.all([
|
|
124
118
|
buildVersionSidebarRoute(param),
|
|
@@ -127,16 +121,15 @@ async function buildVersionRoutes(param) {
|
|
|
127
121
|
return [sidebarRoute, ...tagsRoutes];
|
|
128
122
|
}
|
|
129
123
|
async function doBuildVersionRoutes() {
|
|
130
|
-
const versionProp = (0, props_1.toVersionMetadataProp)(options.id, version);
|
|
131
|
-
const versionPropPath = await actions.createData(`${(0, utils_1.docuHash)(`version-${version.versionName}-metadata-prop`)}.json`, JSON.stringify(versionProp, null, 2));
|
|
132
|
-
const subRoutes = await buildVersionSubRoutes();
|
|
133
124
|
return {
|
|
134
125
|
path: version.path,
|
|
135
126
|
exact: false,
|
|
136
127
|
component: options.docVersionRootComponent,
|
|
137
|
-
routes:
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
routes: await buildVersionSubRoutes(),
|
|
129
|
+
props: {
|
|
130
|
+
// TODO Docusaurus v4 breaking change?
|
|
131
|
+
// expose version metadata as route context instead of props
|
|
132
|
+
version: (0, props_1.toVersionMetadataProp)(options.id, version),
|
|
140
133
|
},
|
|
141
134
|
priority: version.routePriority,
|
|
142
135
|
};
|
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-5900",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "0.0.0-
|
|
39
|
-
"@docusaurus/logger": "0.0.0-
|
|
40
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
41
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
42
|
-
"@docusaurus/types": "0.0.0-
|
|
43
|
-
"@docusaurus/utils": "0.0.0-
|
|
44
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
45
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
38
|
+
"@docusaurus/core": "0.0.0-5900",
|
|
39
|
+
"@docusaurus/logger": "0.0.0-5900",
|
|
40
|
+
"@docusaurus/mdx-loader": "0.0.0-5900",
|
|
41
|
+
"@docusaurus/module-type-aliases": "0.0.0-5900",
|
|
42
|
+
"@docusaurus/types": "0.0.0-5900",
|
|
43
|
+
"@docusaurus/utils": "0.0.0-5900",
|
|
44
|
+
"@docusaurus/utils-common": "0.0.0-5900",
|
|
45
|
+
"@docusaurus/utils-validation": "0.0.0-5900",
|
|
46
46
|
"@types/react-router-config": "^5.0.7",
|
|
47
47
|
"combine-promises": "^1.1.0",
|
|
48
48
|
"fs-extra": "^11.1.1",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=18.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "8c799b8d6990ec2aea5708a732db09f4dd9e66cc"
|
|
70
70
|
}
|
package/src/index.ts
CHANGED
|
@@ -73,6 +73,9 @@ export default async function pluginContentDocs(
|
|
|
73
73
|
'docusaurus-plugin-content-docs',
|
|
74
74
|
);
|
|
75
75
|
const dataDir = path.join(pluginDataDirRoot, pluginId);
|
|
76
|
+
// TODO Docusaurus v4 breaking change
|
|
77
|
+
// module aliasing should be automatic
|
|
78
|
+
// we should never find local absolute FS paths in the codegen registry
|
|
76
79
|
const aliasedSource = (source: string) =>
|
|
77
80
|
`~docs/${posixPath(path.relative(pluginDataDirRoot, source))}`;
|
|
78
81
|
|
package/src/routes.ts
CHANGED
|
@@ -9,7 +9,6 @@ import _ from 'lodash';
|
|
|
9
9
|
import logger from '@docusaurus/logger';
|
|
10
10
|
import {
|
|
11
11
|
docuHash,
|
|
12
|
-
createSlugger,
|
|
13
12
|
normalizeUrl,
|
|
14
13
|
aliasedSitePathToRelativePath,
|
|
15
14
|
} from '@docusaurus/utils';
|
|
@@ -29,7 +28,6 @@ import type {
|
|
|
29
28
|
CategoryGeneratedIndexMetadata,
|
|
30
29
|
DocMetadata,
|
|
31
30
|
PluginOptions,
|
|
32
|
-
PropTagsListPage,
|
|
33
31
|
} from '@docusaurus/plugin-content-docs';
|
|
34
32
|
|
|
35
33
|
function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
|
|
@@ -41,36 +39,23 @@ function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
|
|
|
41
39
|
|
|
42
40
|
async function buildVersionCategoryGeneratedIndexRoutes({
|
|
43
41
|
version,
|
|
44
|
-
actions,
|
|
45
42
|
options,
|
|
46
|
-
aliasedSource,
|
|
47
43
|
}: BuildVersionRoutesParam): Promise<RouteConfig[]> {
|
|
48
|
-
const slugs = createSlugger();
|
|
49
|
-
|
|
50
44
|
async function buildCategoryGeneratedIndexRoute(
|
|
51
45
|
categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
|
|
52
46
|
): Promise<RouteConfig> {
|
|
53
|
-
const {sidebar, ...prop} = categoryGeneratedIndex;
|
|
54
|
-
|
|
55
|
-
const propFileName = slugs.slug(
|
|
56
|
-
`${version.path}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const propData = await actions.createData(
|
|
60
|
-
`${docuHash(`category/${propFileName}`)}.json`,
|
|
61
|
-
JSON.stringify(prop, null, 2),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
47
|
return {
|
|
65
48
|
path: categoryGeneratedIndex.permalink,
|
|
66
49
|
component: options.docCategoryGeneratedIndexComponent,
|
|
67
50
|
exact: true,
|
|
68
|
-
|
|
69
|
-
categoryGeneratedIndex
|
|
51
|
+
props: {
|
|
52
|
+
categoryGeneratedIndex,
|
|
70
53
|
},
|
|
71
54
|
// Same as doc, this sidebar route attribute permits to associate this
|
|
72
55
|
// subpage to the given sidebar
|
|
73
|
-
...(sidebar && {
|
|
56
|
+
...(categoryGeneratedIndex.sidebar && {
|
|
57
|
+
sidebar: categoryGeneratedIndex.sidebar,
|
|
58
|
+
}),
|
|
74
59
|
};
|
|
75
60
|
}
|
|
76
61
|
|
|
@@ -90,7 +75,7 @@ async function buildVersionDocRoutes({
|
|
|
90
75
|
// Note that this created data path must be in sync with
|
|
91
76
|
// metadataPath provided to mdx-loader.
|
|
92
77
|
`${docuHash(doc.source)}.json`,
|
|
93
|
-
|
|
78
|
+
doc,
|
|
94
79
|
);
|
|
95
80
|
|
|
96
81
|
const docRoute: RouteConfig = {
|
|
@@ -131,7 +116,7 @@ async function buildVersionSidebarRoute(param: BuildVersionRoutesParam) {
|
|
|
131
116
|
async function buildVersionTagsRoutes(
|
|
132
117
|
param: BuildVersionRoutesParam,
|
|
133
118
|
): Promise<RouteConfig[]> {
|
|
134
|
-
const {version, options
|
|
119
|
+
const {version, options} = param;
|
|
135
120
|
const versionTags = getVersionTags(version.docs);
|
|
136
121
|
|
|
137
122
|
async function buildTagsListRoute(): Promise<RouteConfig | null> {
|
|
@@ -139,37 +124,27 @@ async function buildVersionTagsRoutes(
|
|
|
139
124
|
if (Object.keys(versionTags).length === 0) {
|
|
140
125
|
return null;
|
|
141
126
|
}
|
|
142
|
-
const tagsProp: PropTagsListPage['tags'] = toTagsListTagsProp(versionTags);
|
|
143
|
-
const tagsPropPath = await actions.createData(
|
|
144
|
-
`${docuHash(`tags-list-${version.versionName}-prop`)}.json`,
|
|
145
|
-
JSON.stringify(tagsProp, null, 2),
|
|
146
|
-
);
|
|
147
127
|
return {
|
|
148
128
|
path: version.tagsPath,
|
|
149
129
|
exact: true,
|
|
150
130
|
component: options.docTagsListComponent,
|
|
151
|
-
|
|
152
|
-
tags:
|
|
131
|
+
props: {
|
|
132
|
+
tags: toTagsListTagsProp(versionTags),
|
|
153
133
|
},
|
|
154
134
|
};
|
|
155
135
|
}
|
|
156
136
|
|
|
157
137
|
async function buildTagDocListRoute(tag: VersionTag): Promise<RouteConfig> {
|
|
158
|
-
const tagProps = toTagDocListProp({
|
|
159
|
-
allTagsPath: version.tagsPath,
|
|
160
|
-
tag,
|
|
161
|
-
docs: version.docs,
|
|
162
|
-
});
|
|
163
|
-
const tagPropPath = await actions.createData(
|
|
164
|
-
`${docuHash(`tag-${tag.permalink}`)}.json`,
|
|
165
|
-
JSON.stringify(tagProps, null, 2),
|
|
166
|
-
);
|
|
167
138
|
return {
|
|
168
139
|
path: tag.permalink,
|
|
169
140
|
component: options.docTagDocListComponent,
|
|
170
141
|
exact: true,
|
|
171
|
-
|
|
172
|
-
tag:
|
|
142
|
+
props: {
|
|
143
|
+
tag: toTagDocListProp({
|
|
144
|
+
allTagsPath: version.tagsPath,
|
|
145
|
+
tag,
|
|
146
|
+
docs: version.docs,
|
|
147
|
+
}),
|
|
173
148
|
},
|
|
174
149
|
};
|
|
175
150
|
}
|
|
@@ -189,7 +164,7 @@ type BuildVersionRoutesParam = Omit<BuildAllRoutesParam, 'versions'> & {
|
|
|
189
164
|
async function buildVersionRoutes(
|
|
190
165
|
param: BuildVersionRoutesParam,
|
|
191
166
|
): Promise<RouteConfig> {
|
|
192
|
-
const {version,
|
|
167
|
+
const {version, options} = param;
|
|
193
168
|
|
|
194
169
|
async function buildVersionSubRoutes() {
|
|
195
170
|
const [sidebarRoute, tagsRoutes] = await Promise.all([
|
|
@@ -201,19 +176,15 @@ async function buildVersionRoutes(
|
|
|
201
176
|
}
|
|
202
177
|
|
|
203
178
|
async function doBuildVersionRoutes(): Promise<RouteConfig> {
|
|
204
|
-
const versionProp = toVersionMetadataProp(options.id, version);
|
|
205
|
-
const versionPropPath = await actions.createData(
|
|
206
|
-
`${docuHash(`version-${version.versionName}-metadata-prop`)}.json`,
|
|
207
|
-
JSON.stringify(versionProp, null, 2),
|
|
208
|
-
);
|
|
209
|
-
const subRoutes = await buildVersionSubRoutes();
|
|
210
179
|
return {
|
|
211
180
|
path: version.path,
|
|
212
181
|
exact: false,
|
|
213
182
|
component: options.docVersionRootComponent,
|
|
214
|
-
routes:
|
|
215
|
-
|
|
216
|
-
|
|
183
|
+
routes: await buildVersionSubRoutes(),
|
|
184
|
+
props: {
|
|
185
|
+
// TODO Docusaurus v4 breaking change?
|
|
186
|
+
// expose version metadata as route context instead of props
|
|
187
|
+
version: toVersionMetadataProp(options.id, version),
|
|
217
188
|
},
|
|
218
189
|
priority: version.routePriority,
|
|
219
190
|
};
|