@docusaurus/core 0.0.0-4683 → 0.0.0-4687
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/bin/docusaurus.mjs +20 -21
- package/lib/client/exports/BrowserOnly.js +1 -1
- package/lib/client/exports/Link.js +1 -1
- package/lib/client/serverEntry.js +4 -4
- package/lib/commands/commandUtils.js +1 -1
- package/lib/commands/start.js +4 -5
- package/lib/server/configValidation.d.ts +1 -1
- package/lib/server/configValidation.js +14 -5
- package/lib/server/html-tags/htmlTags.js +1 -1
- package/lib/server/html-tags/index.js +1 -1
- package/lib/server/index.js +17 -11
- package/lib/server/presets/index.js +1 -1
- package/lib/webpack/plugins/CleanWebpackPlugin.js +1 -1
- package/package.json +12 -12
package/bin/docusaurus.mjs
CHANGED
|
@@ -245,34 +245,33 @@ cli.arguments('<command>').action((cmd) => {
|
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
|
-
* @param {string} command
|
|
248
|
+
* @param {string | undefined} command
|
|
249
249
|
*/
|
|
250
250
|
function isInternalCommand(command) {
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
251
|
+
return (
|
|
252
|
+
command &&
|
|
253
|
+
[
|
|
254
|
+
'start',
|
|
255
|
+
'build',
|
|
256
|
+
'swizzle',
|
|
257
|
+
'deploy',
|
|
258
|
+
'serve',
|
|
259
|
+
'clear',
|
|
260
|
+
'write-translations',
|
|
261
|
+
'write-heading-ids',
|
|
262
|
+
].includes(command)
|
|
263
|
+
);
|
|
261
264
|
}
|
|
262
265
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
cli.parse(process.argv);
|
|
266
|
+
if (!isInternalCommand(process.argv.slice(2)[0])) {
|
|
267
|
+
await externalCommand(cli, await resolveDir('.'));
|
|
268
|
+
}
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
270
|
+
if (!process.argv.slice(2).length) {
|
|
271
|
+
cli.outputHelp();
|
|
273
272
|
}
|
|
274
273
|
|
|
275
|
-
|
|
274
|
+
cli.parse(process.argv);
|
|
276
275
|
|
|
277
276
|
process.on('unhandledRejection', (err) => {
|
|
278
277
|
logger.error(err);
|
|
@@ -110,7 +110,7 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
110
110
|
return isRegularHtmlLink ? (
|
|
111
111
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
112
112
|
<a ref={innerRef} href={targetLink} {...(targetLinkUnprefixed &&
|
|
113
|
-
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink
|
|
113
|
+
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink}
|
|
114
114
|
// avoid "React does not recognize the `activeClassName` prop on a DOM
|
|
115
115
|
// element"
|
|
116
116
|
{...(isNavLink && { isActive, activeClassName })}/>);
|
|
@@ -81,13 +81,13 @@ async function doRender(locals) {
|
|
|
81
81
|
// manifest information.
|
|
82
82
|
const modulesToBeLoaded = [...manifest.entrypoints, ...Array.from(modules)];
|
|
83
83
|
const bundles = getBundles(manifest, modulesToBeLoaded);
|
|
84
|
-
const stylesheets = (bundles.css
|
|
85
|
-
const scripts = (bundles.js
|
|
84
|
+
const stylesheets = (bundles.css ?? []).map((b) => b.file);
|
|
85
|
+
const scripts = (bundles.js ?? []).map((b) => b.file);
|
|
86
86
|
const renderedHtml = renderSSRTemplate(ssrTemplate, {
|
|
87
87
|
appHtml,
|
|
88
88
|
baseUrl,
|
|
89
|
-
htmlAttributes
|
|
90
|
-
bodyAttributes
|
|
89
|
+
htmlAttributes,
|
|
90
|
+
bodyAttributes,
|
|
91
91
|
headTags,
|
|
92
92
|
preBodyTags,
|
|
93
93
|
postBodyTags,
|
|
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const choosePort_1 = tslib_1.__importDefault(require("../choosePort"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
function getCLIOptionHost(hostOption) {
|
|
14
|
-
return hostOption
|
|
14
|
+
return hostOption ?? 'localhost';
|
|
15
15
|
}
|
|
16
16
|
exports.getCLIOptionHost = getCLIOptionHost;
|
|
17
17
|
async function getCLIOptionPort(portOption, host) {
|
package/lib/commands/start.js
CHANGED
|
@@ -60,17 +60,16 @@ async function start(siteDir, cliOptions) {
|
|
|
60
60
|
logger_1.default.error(err.stack);
|
|
61
61
|
});
|
|
62
62
|
}, 500);
|
|
63
|
-
const { siteConfig, plugins
|
|
63
|
+
const { siteConfig, plugins } = props;
|
|
64
64
|
const normalizeToSiteDir = (filepath) => {
|
|
65
65
|
if (filepath && path_1.default.isAbsolute(filepath)) {
|
|
66
66
|
return (0, utils_1.posixPath)(path_1.default.relative(siteDir, filepath));
|
|
67
67
|
}
|
|
68
68
|
return (0, utils_1.posixPath)(filepath);
|
|
69
69
|
};
|
|
70
|
-
const pluginPaths =
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
.filter(Boolean))
|
|
70
|
+
const pluginPaths = plugins
|
|
71
|
+
.flatMap((plugin) => plugin.getPathsToWatch?.() ?? [])
|
|
72
|
+
.filter(Boolean)
|
|
74
73
|
.map(normalizeToSiteDir);
|
|
75
74
|
const pathsToWatch = [
|
|
76
75
|
...pluginPaths,
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
import type { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
|
|
8
8
|
import { Joi } from '@docusaurus/utils-validation';
|
|
9
9
|
export declare const DEFAULT_I18N_CONFIG: I18nConfig;
|
|
10
|
-
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
|
|
10
|
+
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'stylesheets' | 'scripts' | 'clientModules' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
|
|
11
11
|
export declare const ConfigSchema: Joi.ObjectSchema<any>;
|
|
12
12
|
export declare function validateConfig(config: Partial<DocusaurusConfig>): DocusaurusConfig;
|
|
@@ -23,6 +23,9 @@ exports.DEFAULT_CONFIG = {
|
|
|
23
23
|
plugins: [],
|
|
24
24
|
themes: [],
|
|
25
25
|
presets: [],
|
|
26
|
+
stylesheets: [],
|
|
27
|
+
scripts: [],
|
|
28
|
+
clientModules: [],
|
|
26
29
|
customFields: {},
|
|
27
30
|
themeConfig: {},
|
|
28
31
|
titleDelimiter: '|',
|
|
@@ -131,19 +134,25 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
131
134
|
themes: utils_validation_1.Joi.array().items(ThemeSchema).default(exports.DEFAULT_CONFIG.themes),
|
|
132
135
|
presets: utils_validation_1.Joi.array().items(PresetSchema).default(exports.DEFAULT_CONFIG.presets),
|
|
133
136
|
themeConfig: utils_validation_1.Joi.object().unknown().default(exports.DEFAULT_CONFIG.themeConfig),
|
|
134
|
-
scripts: utils_validation_1.Joi.array()
|
|
137
|
+
scripts: utils_validation_1.Joi.array()
|
|
138
|
+
.items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
|
|
135
139
|
src: utils_validation_1.Joi.string().required(),
|
|
136
140
|
async: utils_validation_1.Joi.bool(),
|
|
137
141
|
defer: utils_validation_1.Joi.bool(),
|
|
138
142
|
})
|
|
139
143
|
// See https://github.com/facebook/docusaurus/issues/3378
|
|
140
|
-
.unknown())
|
|
144
|
+
.unknown())
|
|
145
|
+
.default(exports.DEFAULT_CONFIG.scripts),
|
|
141
146
|
ssrTemplate: utils_validation_1.Joi.string(),
|
|
142
|
-
stylesheets: utils_validation_1.Joi.array()
|
|
147
|
+
stylesheets: utils_validation_1.Joi.array()
|
|
148
|
+
.items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
|
|
143
149
|
href: utils_validation_1.Joi.string().required(),
|
|
144
150
|
type: utils_validation_1.Joi.string(),
|
|
145
|
-
}).unknown())
|
|
146
|
-
|
|
151
|
+
}).unknown())
|
|
152
|
+
.default(exports.DEFAULT_CONFIG.stylesheets),
|
|
153
|
+
clientModules: utils_validation_1.Joi.array()
|
|
154
|
+
.items(utils_validation_1.Joi.string())
|
|
155
|
+
.default(exports.DEFAULT_CONFIG.clientModules),
|
|
147
156
|
tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
|
|
148
157
|
titleDelimiter: utils_validation_1.Joi.string().default('|'),
|
|
149
158
|
noIndex: utils_validation_1.Joi.bool().default(false),
|
|
@@ -24,7 +24,7 @@ function htmlTagObjectToString(tagDefinition) {
|
|
|
24
24
|
throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
|
|
25
25
|
}
|
|
26
26
|
const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
|
|
27
|
-
const tagAttributes = tagDefinition.attributes
|
|
27
|
+
const tagAttributes = tagDefinition.attributes ?? {};
|
|
28
28
|
const attributes = Object.keys(tagAttributes)
|
|
29
29
|
.filter((attributeName) => tagAttributes[attributeName] !== false)
|
|
30
30
|
.map((attributeName) => {
|
|
@@ -21,7 +21,7 @@ function loadHtmlTags(plugins) {
|
|
|
21
21
|
if (!plugin.injectHtmlTags) {
|
|
22
22
|
return acc;
|
|
23
23
|
}
|
|
24
|
-
const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content })
|
|
24
|
+
const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) ?? {};
|
|
25
25
|
return {
|
|
26
26
|
headTags: headTags
|
|
27
27
|
? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
|
package/lib/server/index.js
CHANGED
|
@@ -100,8 +100,8 @@ async function loadPluginConfigs(context) {
|
|
|
100
100
|
}
|
|
101
101
|
presetPlugins = presetPlugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
|
|
102
102
|
presetThemes = presetThemes.map((theme) => normalizeShorthand(theme, 'theme'));
|
|
103
|
-
const standalonePlugins =
|
|
104
|
-
const standaloneThemes =
|
|
103
|
+
const standalonePlugins = siteConfig.plugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
|
|
104
|
+
const standaloneThemes = siteConfig.themes.map((theme) => normalizeShorthand(theme, 'theme'));
|
|
105
105
|
return [
|
|
106
106
|
...presetPlugins,
|
|
107
107
|
...presetThemes,
|
|
@@ -115,7 +115,7 @@ exports.loadPluginConfigs = loadPluginConfigs;
|
|
|
115
115
|
// - Resolve aliased theme components
|
|
116
116
|
// - Inject scripts/stylesheets
|
|
117
117
|
function createBootstrapPlugin({ siteConfig, }) {
|
|
118
|
-
const { stylesheets
|
|
118
|
+
const { stylesheets, scripts, clientModules: siteConfigClientModules, } = siteConfig;
|
|
119
119
|
return {
|
|
120
120
|
name: 'docusaurus-bootstrap-plugin',
|
|
121
121
|
content: null,
|
|
@@ -208,6 +208,7 @@ async function load(siteDir, options = {}) {
|
|
|
208
208
|
context.siteConfig.themeConfig = themeConfigTranslated;
|
|
209
209
|
(0, duplicateRoutes_1.handleDuplicateRoutes)(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
|
|
210
210
|
const genWarning = (0, utils_1.generate)(generatedFilesDir, 'DONT-EDIT-THIS-FOLDER', `This folder stores temp files that Docusaurus' client bundler accesses.
|
|
211
|
+
|
|
211
212
|
DO NOT hand-modify files in this folder because they will be overwritten in the
|
|
212
213
|
next build. You can clear all build artifacts (including this folder) with the
|
|
213
214
|
\`docusaurus clear\` command.
|
|
@@ -215,20 +216,24 @@ next build. You can clear all build artifacts (including this folder) with the
|
|
|
215
216
|
// Site config must be generated after plugins
|
|
216
217
|
// We want the generated config to have been normalized by the plugins!
|
|
217
218
|
const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME, `/*
|
|
218
|
-
AUTOGENERATED - DON'T EDIT
|
|
219
|
-
Your edits in this file will be overwritten in the next build!
|
|
220
|
-
Modify the docusaurus.config.js file at your site's root instead.
|
|
221
|
-
*/
|
|
222
|
-
export default ${JSON.stringify(siteConfig, null, 2)}
|
|
219
|
+
* AUTOGENERATED - DON'T EDIT
|
|
220
|
+
* Your edits in this file will be overwritten in the next build!
|
|
221
|
+
* Modify the docusaurus.config.js file at your site's root instead.
|
|
222
|
+
*/
|
|
223
|
+
export default ${JSON.stringify(siteConfig, null, 2)};
|
|
224
|
+
`);
|
|
223
225
|
plugins.push(createBootstrapPlugin({ siteConfig }));
|
|
224
226
|
plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
|
|
225
227
|
// Load client modules.
|
|
226
228
|
const clientModules = (0, client_modules_1.default)(plugins);
|
|
227
|
-
const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
|
|
229
|
+
const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
|
|
230
|
+
${clientModules
|
|
228
231
|
// import() is async so we use require() because client modules can have
|
|
229
232
|
// CSS and the order matters for loading CSS.
|
|
230
233
|
.map((module) => ` require('${(0, utils_1.escapePath)(module)}'),`)
|
|
231
|
-
.join('\n')}
|
|
234
|
+
.join('\n')}
|
|
235
|
+
];
|
|
236
|
+
`);
|
|
232
237
|
// Load extra head & body html tags.
|
|
233
238
|
const { headTags, preBodyTags, postBodyTags } = (0, html_tags_1.loadHtmlTags)(plugins);
|
|
234
239
|
// Routing.
|
|
@@ -237,7 +242,8 @@ export default ${JSON.stringify(siteConfig, null, 2)};`);
|
|
|
237
242
|
${Object.entries(registry)
|
|
238
243
|
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
239
244
|
.map(([key, chunk]) => ` '${key}': [${chunk.loader}, '${(0, utils_1.escapePath)(chunk.modulePath)}', require.resolveWeak('${(0, utils_1.escapePath)(chunk.modulePath)}')],`)
|
|
240
|
-
.join('\n')}}
|
|
245
|
+
.join('\n')}};
|
|
246
|
+
`);
|
|
241
247
|
const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
|
|
242
248
|
const genRoutes = (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
|
|
243
249
|
const genGlobalData = (0, utils_1.generate)(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
|
|
@@ -14,7 +14,7 @@ async function loadPresets(context) {
|
|
|
14
14
|
// We need to resolve presets from the perspective of the siteDir, since the
|
|
15
15
|
// siteDir's package.json declares the dependency on these presets.
|
|
16
16
|
const presetRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
17
|
-
const presets = context.siteConfig
|
|
17
|
+
const { presets } = context.siteConfig;
|
|
18
18
|
const unflatPlugins = [];
|
|
19
19
|
const unflatThemes = [];
|
|
20
20
|
presets.forEach((presetItem) => {
|
|
@@ -86,7 +86,7 @@ class CleanWebpackPlugin {
|
|
|
86
86
|
const statsAssets = stats.toJson({
|
|
87
87
|
all: false,
|
|
88
88
|
assets: true,
|
|
89
|
-
}).assets
|
|
89
|
+
}).assets ?? [];
|
|
90
90
|
const assets = statsAssets.map((asset) => asset.name);
|
|
91
91
|
/**
|
|
92
92
|
* Get all files that were in the previous build but not the current
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-4687",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"docusaurus": "bin/docusaurus.mjs"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
|
|
28
|
-
"watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\""
|
|
27
|
+
"build": "tsc -p tsconfig.server.json && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
|
|
28
|
+
"watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc -p tsconfig.server.json --watch\" \"tsc -p tsconfig.client.json --watch\""
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.17.2",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.17.2",
|
|
43
43
|
"@babel/traverse": "^7.17.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4687",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4687",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4687",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4687",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4687",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4687",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.1",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
53
|
"autoprefixer": "^10.4.2",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-4687",
|
|
110
|
+
"@docusaurus/types": "0.0.0-4687",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/nprogress": "^0.2.0",
|
|
113
113
|
"@types/react-dom": "^17.0.11",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "07732e16aa86d21c9c5713e03c7159201c2457de"
|
|
132
132
|
}
|