@docusaurus/core 2.0.0-rc.1 → 2.1.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/bin/docusaurus.mjs +2 -0
- package/lib/client/SiteMetadataDefaults.js +9 -1
- package/lib/client/preload.js +3 -1
- package/lib/commands/writeTranslations.js +11 -5
- package/lib/webpack/templates/index.html.template.ejs +0 -1
- package/lib/webpack/templates/ssr.html.template.d.ts +1 -1
- package/lib/webpack/templates/ssr.html.template.js +1 -5
- package/package.json +10 -10
package/bin/docusaurus.mjs
CHANGED
|
@@ -217,5 +217,7 @@ cli.parse(process.argv);
|
|
|
217
217
|
|
|
218
218
|
process.on('unhandledRejection', (err) => {
|
|
219
219
|
logger.error(err instanceof Error ? err.stack : err);
|
|
220
|
+
logger.info`Docusaurus version: number=${DOCUSAURUS_VERSION}
|
|
221
|
+
Node version: number=${process.version}`;
|
|
220
222
|
process.exit(1);
|
|
221
223
|
});
|
|
@@ -9,13 +9,21 @@ import Head from '@docusaurus/Head';
|
|
|
9
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
10
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
11
11
|
export default function SiteMetadataDefaults() {
|
|
12
|
-
const { siteConfig: { favicon, title }, i18n: { currentLocale, localeConfigs }, } = useDocusaurusContext();
|
|
12
|
+
const { siteConfig: { favicon, title, noIndex }, i18n: { currentLocale, localeConfigs }, } = useDocusaurusContext();
|
|
13
13
|
const faviconUrl = useBaseUrl(favicon);
|
|
14
14
|
const { htmlLang, direction: htmlDir } = localeConfigs[currentLocale];
|
|
15
15
|
return (<Head>
|
|
16
|
+
{/*
|
|
17
|
+
charSet + generator are handled in the html templates
|
|
18
|
+
See https://github.com/facebook/docusaurus/pull/7952
|
|
19
|
+
<meta charSet="UTF-8" />
|
|
20
|
+
<meta name="generator" content={`Docusaurus v${docusaurusVersion}`} />
|
|
21
|
+
*/}
|
|
16
22
|
<html lang={htmlLang} dir={htmlDir}/>
|
|
17
23
|
<title>{title}</title>
|
|
18
24
|
<meta property="og:title" content={title}/>
|
|
25
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
26
|
+
{noIndex && <meta name="robots" content="noindex, nofollow"/>}
|
|
19
27
|
{favicon && <link rel="icon" href={faviconUrl}/>}
|
|
20
28
|
</Head>);
|
|
21
29
|
}
|
package/lib/client/preload.js
CHANGED
|
@@ -15,6 +15,8 @@ import { matchRoutes } from 'react-router-config';
|
|
|
15
15
|
* @returns Promise object represents whether pathname has been preloaded
|
|
16
16
|
*/
|
|
17
17
|
export default function preload(pathname) {
|
|
18
|
-
const matches =
|
|
18
|
+
const matches = Array.from(new Set([pathname, decodeURI(pathname)]))
|
|
19
|
+
.map((p) => matchRoutes(routes, p))
|
|
20
|
+
.flat();
|
|
19
21
|
return Promise.all(matches.map((match) => match.route.component.preload?.()));
|
|
20
22
|
}
|
|
@@ -15,6 +15,14 @@ const init_1 = require("../server/plugins/init");
|
|
|
15
15
|
const translations_1 = require("../server/translations/translations");
|
|
16
16
|
const translationsExtractor_1 = require("../server/translations/translationsExtractor");
|
|
17
17
|
const utils_1 = require("../webpack/utils");
|
|
18
|
+
function resolveThemeCommonLibDir() {
|
|
19
|
+
try {
|
|
20
|
+
return path_1.default.dirname(require.resolve('@docusaurus/theme-common'));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* This is a hack, so that @docusaurus/theme-common translations are extracted!
|
|
20
28
|
* A theme doesn't have a way to express that one of its dependency (like
|
|
@@ -23,13 +31,11 @@ const utils_1 = require("../webpack/utils");
|
|
|
23
31
|
* We just make an exception and assume that user is using an official theme
|
|
24
32
|
*/
|
|
25
33
|
async function getExtraSourceCodeFilePaths() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return (0, translationsExtractor_1.globSourceCodeFilePaths)([themeCommonSourceDir]);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
34
|
+
const themeCommonLibDir = resolveThemeCommonLibDir();
|
|
35
|
+
if (!themeCommonLibDir) {
|
|
31
36
|
return []; // User may not use a Docusaurus official theme? Quite unlikely...
|
|
32
37
|
}
|
|
38
|
+
return (0, translationsExtractor_1.globSourceCodeFilePaths)([themeCommonLibDir]);
|
|
33
39
|
}
|
|
34
40
|
async function writePluginTranslationFiles({ localizationDir, plugin, options, }) {
|
|
35
41
|
if (plugin.getTranslationFiles) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
5
|
<meta name="generator" content="Docusaurus">
|
|
7
6
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
8
7
|
<%= htmlWebpackPlugin.options.headTags %>
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"
|
|
7
|
+
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <%~ it.headTags %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <link rel=\"preload\" href=\"<%= it.baseUrl %><%= script %>\" as=\"script\">\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\">\n <%~ it.appHtml %>\n </div>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\"></script>\n <% }); %>\n <%~ it.postBodyTags %>\n </body>\n</html>\n";
|
|
8
8
|
export default _default;
|
|
@@ -11,15 +11,11 @@ exports.default = `
|
|
|
11
11
|
<html <%~ it.htmlAttributes %>>
|
|
12
12
|
<head>
|
|
13
13
|
<meta charset="UTF-8">
|
|
14
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
15
14
|
<meta name="generator" content="Docusaurus v<%= it.version %>">
|
|
16
|
-
<% if (it.noIndex) { %>
|
|
17
|
-
<meta name="robots" content="noindex, nofollow" />
|
|
18
|
-
<% } %>
|
|
19
|
-
<%~ it.headTags %>
|
|
20
15
|
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
|
21
16
|
<%~ metaAttribute %>
|
|
22
17
|
<% }); %>
|
|
18
|
+
<%~ it.headTags %>
|
|
23
19
|
<% it.stylesheets.forEach((stylesheet) => { %>
|
|
24
20
|
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
|
25
21
|
<% }); %>
|
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": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.18.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.18.6",
|
|
45
45
|
"@babel/traverse": "^7.18.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "2.
|
|
47
|
-
"@docusaurus/logger": "2.
|
|
48
|
-
"@docusaurus/mdx-loader": "2.
|
|
46
|
+
"@docusaurus/cssnano-preset": "2.1.0",
|
|
47
|
+
"@docusaurus/logger": "2.1.0",
|
|
48
|
+
"@docusaurus/mdx-loader": "2.1.0",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "2.
|
|
51
|
-
"@docusaurus/utils-common": "2.
|
|
52
|
-
"@docusaurus/utils-validation": "2.
|
|
50
|
+
"@docusaurus/utils": "2.1.0",
|
|
51
|
+
"@docusaurus/utils-common": "2.1.0",
|
|
52
|
+
"@docusaurus/utils-validation": "2.1.0",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
54
|
"@svgr/webpack": "^6.2.1",
|
|
55
55
|
"autoprefixer": "^10.4.7",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "2.
|
|
110
|
-
"@docusaurus/types": "2.
|
|
109
|
+
"@docusaurus/module-type-aliases": "2.1.0",
|
|
110
|
+
"@docusaurus/types": "2.1.0",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/react-dom": "^18.0.6",
|
|
113
113
|
"@types/react-router-config": "^5.0.6",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": ">=16.14"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "be9b0942641184213485eba7fd75ceb0b328d3f4"
|
|
131
131
|
}
|