@docusaurus/theme-classic 3.5.2 → 3.6.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/index.js +2 -5
- package/lib/theme/Blog/Components/Author/index.js +1 -1
- package/lib/theme/Blog/Pages/BlogAuthorsPostsPage/index.js +12 -3
- package/lib/theme/BlogPostPage/Metadata/index.js +1 -1
- package/lib/theme/ColorModeToggle/index.js +2 -1
- package/lib/theme/Heading/styles.module.css +1 -1
- package/lib/theme/prism-include-languages.js +5 -0
- package/package.json +16 -15
- package/src/index.ts +2 -11
- package/src/theme/Blog/Components/Author/index.tsx +1 -1
- package/src/theme/Blog/Pages/BlogAuthorsPostsPage/index.tsx +12 -3
- package/src/theme/BlogPostPage/Metadata/index.tsx +1 -1
- package/src/theme/ColorModeToggle/index.tsx +2 -1
- package/src/theme/Heading/styles.module.css +1 -1
- package/src/theme/prism-include-languages.ts +6 -0
package/lib/index.js
CHANGED
|
@@ -10,13 +10,10 @@ exports.validateOptions = exports.validateThemeConfig = exports.getSwizzleConfig
|
|
|
10
10
|
exports.default = themeClassic;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
-
const module_1 = require("module");
|
|
14
13
|
const rtlcss_1 = tslib_1.__importDefault(require("rtlcss"));
|
|
15
14
|
const theme_translations_1 = require("@docusaurus/theme-translations");
|
|
16
15
|
const translations_1 = require("./translations");
|
|
17
16
|
const inlineScripts_1 = require("./inlineScripts");
|
|
18
|
-
const requireFromDocusaurusCore = (0, module_1.createRequire)(require.resolve('@docusaurus/core/package.json'));
|
|
19
|
-
const ContextReplacementPlugin = requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin');
|
|
20
17
|
function getInfimaCSSFile(direction) {
|
|
21
18
|
return `infima/dist/css/default/default${direction === 'rtl' ? '-rtl' : ''}.css`;
|
|
22
19
|
}
|
|
@@ -54,7 +51,7 @@ function themeClassic(context, options) {
|
|
|
54
51
|
modules.push(...customCss.map((p) => path_1.default.resolve(context.siteDir, p)));
|
|
55
52
|
return modules;
|
|
56
53
|
},
|
|
57
|
-
configureWebpack() {
|
|
54
|
+
configureWebpack(__config, __isServer, { currentBundler }) {
|
|
58
55
|
const prismLanguages = additionalLanguages
|
|
59
56
|
.map((lang) => `prism-${lang}`)
|
|
60
57
|
.join('|');
|
|
@@ -63,7 +60,7 @@ function themeClassic(context, options) {
|
|
|
63
60
|
// This allows better optimization by only bundling those components
|
|
64
61
|
// that the user actually needs, because the modules are dynamically
|
|
65
62
|
// required and can't be known during compile time.
|
|
66
|
-
new ContextReplacementPlugin(/prismjs[\\/]components$/, new RegExp(`^./(${prismLanguages})$`)),
|
|
63
|
+
new currentBundler.instance.ContextReplacementPlugin(/prismjs[\\/]components$/, new RegExp(`^./(${prismLanguages})$`)),
|
|
67
64
|
],
|
|
68
65
|
};
|
|
69
66
|
},
|
|
@@ -70,7 +70,7 @@ export default function BlogAuthor({as, author, className, count}) {
|
|
|
70
70
|
<AuthorName name={name} as={as} />
|
|
71
71
|
</MaybeLink>
|
|
72
72
|
)}
|
|
73
|
-
{count && <AuthorBlogPostCount count={count} />}
|
|
73
|
+
{count !== undefined && <AuthorBlogPostCount count={count} />}
|
|
74
74
|
</div>
|
|
75
75
|
{!!title && <AuthorTitle title={title} />}
|
|
76
76
|
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
useBlogAuthorPageTitle,
|
|
16
16
|
BlogAuthorsListViewAllLabel,
|
|
17
|
+
BlogAuthorNoPostsLabel,
|
|
17
18
|
} from '@docusaurus/theme-common/internal';
|
|
18
19
|
import Link from '@docusaurus/Link';
|
|
19
20
|
import {useBlogMetadata} from '@docusaurus/plugin-content-blog/client';
|
|
@@ -47,9 +48,17 @@ function Content({author, items, sidebar, listMetadata}) {
|
|
|
47
48
|
{author.description && <p>{author.description}</p>}
|
|
48
49
|
<ViewAllAuthorsLink />
|
|
49
50
|
</header>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
{items.length === 0 ? (
|
|
52
|
+
<p>
|
|
53
|
+
<BlogAuthorNoPostsLabel />
|
|
54
|
+
</p>
|
|
55
|
+
) : (
|
|
56
|
+
<>
|
|
57
|
+
<hr />
|
|
58
|
+
<BlogPostItems items={items} />
|
|
59
|
+
<BlogListPaginator metadata={listMetadata} />
|
|
60
|
+
</>
|
|
61
|
+
)}
|
|
53
62
|
</BlogLayout>
|
|
54
63
|
);
|
|
55
64
|
}
|
|
@@ -48,7 +48,8 @@ function ColorModeToggle({className, buttonClassName, value, onChange}) {
|
|
|
48
48
|
disabled={!isBrowser}
|
|
49
49
|
title={title}
|
|
50
50
|
aria-label={title}
|
|
51
|
-
aria-live="polite"
|
|
51
|
+
aria-live="polite"
|
|
52
|
+
aria-pressed={value === 'dark' ? 'true' : 'false'}>
|
|
52
53
|
<IconLightMode
|
|
53
54
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
54
55
|
/>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/*
|
|
9
9
|
When the navbar is sticky, ensure that on anchor click,
|
|
10
10
|
the browser does not scroll that anchor behind the navbar
|
|
11
|
-
See https://
|
|
11
|
+
See https://x.com/JoshWComeau/status/1332015868725891076
|
|
12
12
|
*/
|
|
13
13
|
.anchorWithStickyNavbar {
|
|
14
14
|
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
|
|
@@ -16,6 +16,7 @@ export default function prismIncludeLanguages(PrismObject) {
|
|
|
16
16
|
// avoid polluting global namespace.
|
|
17
17
|
// You can mutate PrismObject: registering plugins, deleting languages... As
|
|
18
18
|
// long as you don't re-assign it
|
|
19
|
+
const PrismBefore = globalThis.Prism;
|
|
19
20
|
globalThis.Prism = PrismObject;
|
|
20
21
|
additionalLanguages.forEach((lang) => {
|
|
21
22
|
if (lang === 'php') {
|
|
@@ -25,5 +26,9 @@ export default function prismIncludeLanguages(PrismObject) {
|
|
|
25
26
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
26
27
|
require(`prismjs/components/prism-${lang}`);
|
|
27
28
|
});
|
|
29
|
+
// Clean up and eventually restore former globalThis.Prism object (if any)
|
|
28
30
|
delete globalThis.Prism;
|
|
31
|
+
if (typeof PrismBefore !== 'undefined') {
|
|
32
|
+
globalThis.Prism = PrismObject;
|
|
33
|
+
}
|
|
29
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,22 +20,23 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "3.
|
|
24
|
-
"@docusaurus/
|
|
25
|
-
"@docusaurus/
|
|
26
|
-
"@docusaurus/
|
|
27
|
-
"@docusaurus/plugin-content-
|
|
28
|
-
"@docusaurus/plugin-content-
|
|
29
|
-
"@docusaurus/
|
|
30
|
-
"@docusaurus/theme-
|
|
31
|
-
"@docusaurus/
|
|
32
|
-
"@docusaurus/
|
|
33
|
-
"@docusaurus/utils
|
|
34
|
-
"@docusaurus/utils-
|
|
23
|
+
"@docusaurus/core": "3.6.0",
|
|
24
|
+
"@docusaurus/logger": "3.6.0",
|
|
25
|
+
"@docusaurus/mdx-loader": "3.6.0",
|
|
26
|
+
"@docusaurus/module-type-aliases": "3.6.0",
|
|
27
|
+
"@docusaurus/plugin-content-blog": "3.6.0",
|
|
28
|
+
"@docusaurus/plugin-content-docs": "3.6.0",
|
|
29
|
+
"@docusaurus/plugin-content-pages": "3.6.0",
|
|
30
|
+
"@docusaurus/theme-common": "3.6.0",
|
|
31
|
+
"@docusaurus/theme-translations": "3.6.0",
|
|
32
|
+
"@docusaurus/types": "3.6.0",
|
|
33
|
+
"@docusaurus/utils": "3.6.0",
|
|
34
|
+
"@docusaurus/utils-common": "3.6.0",
|
|
35
|
+
"@docusaurus/utils-validation": "3.6.0",
|
|
35
36
|
"@mdx-js/react": "^3.0.0",
|
|
36
37
|
"clsx": "^2.0.0",
|
|
37
38
|
"copy-text-to-clipboard": "^3.2.0",
|
|
38
|
-
"infima": "0.2.0-alpha.
|
|
39
|
+
"infima": "0.2.0-alpha.45",
|
|
39
40
|
"lodash": "^4.17.21",
|
|
40
41
|
"nprogress": "^0.2.0",
|
|
41
42
|
"postcss": "^8.4.26",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"engines": {
|
|
62
63
|
"node": ">=18.0"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "05bba6d4f495ef6b0bec5d41453932bb97981830"
|
|
65
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
|
-
import {createRequire} from 'module';
|
|
10
9
|
import rtlcss from 'rtlcss';
|
|
11
10
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
12
11
|
import {getTranslationFiles, translateThemeConfig} from './translations';
|
|
@@ -19,14 +18,6 @@ import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
|
19
18
|
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
20
19
|
import type {Plugin as PostCssPlugin} from 'postcss';
|
|
21
20
|
import type {PluginOptions} from '@docusaurus/theme-classic';
|
|
22
|
-
import type webpack from 'webpack';
|
|
23
|
-
|
|
24
|
-
const requireFromDocusaurusCore = createRequire(
|
|
25
|
-
require.resolve('@docusaurus/core/package.json'),
|
|
26
|
-
);
|
|
27
|
-
const ContextReplacementPlugin = requireFromDocusaurusCore(
|
|
28
|
-
'webpack/lib/ContextReplacementPlugin',
|
|
29
|
-
) as typeof webpack.ContextReplacementPlugin;
|
|
30
21
|
|
|
31
22
|
function getInfimaCSSFile(direction: string) {
|
|
32
23
|
return `infima/dist/css/default/default${
|
|
@@ -89,7 +80,7 @@ export default function themeClassic(
|
|
|
89
80
|
return modules;
|
|
90
81
|
},
|
|
91
82
|
|
|
92
|
-
configureWebpack() {
|
|
83
|
+
configureWebpack(__config, __isServer, {currentBundler}) {
|
|
93
84
|
const prismLanguages = additionalLanguages
|
|
94
85
|
.map((lang) => `prism-${lang}`)
|
|
95
86
|
.join('|');
|
|
@@ -99,7 +90,7 @@ export default function themeClassic(
|
|
|
99
90
|
// This allows better optimization by only bundling those components
|
|
100
91
|
// that the user actually needs, because the modules are dynamically
|
|
101
92
|
// required and can't be known during compile time.
|
|
102
|
-
new ContextReplacementPlugin(
|
|
93
|
+
new currentBundler.instance.ContextReplacementPlugin(
|
|
103
94
|
/prismjs[\\/]components$/,
|
|
104
95
|
new RegExp(`^./(${prismLanguages})$`),
|
|
105
96
|
),
|
|
@@ -83,7 +83,7 @@ export default function BlogAuthor({
|
|
|
83
83
|
<AuthorName name={name} as={as} />
|
|
84
84
|
</MaybeLink>
|
|
85
85
|
)}
|
|
86
|
-
{count && <AuthorBlogPostCount count={count} />}
|
|
86
|
+
{count !== undefined && <AuthorBlogPostCount count={count} />}
|
|
87
87
|
</div>
|
|
88
88
|
{!!title && <AuthorTitle title={title} />}
|
|
89
89
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
useBlogAuthorPageTitle,
|
|
17
17
|
BlogAuthorsListViewAllLabel,
|
|
18
|
+
BlogAuthorNoPostsLabel,
|
|
18
19
|
} from '@docusaurus/theme-common/internal';
|
|
19
20
|
import Link from '@docusaurus/Link';
|
|
20
21
|
import {useBlogMetadata} from '@docusaurus/plugin-content-blog/client';
|
|
@@ -52,9 +53,17 @@ function Content({author, items, sidebar, listMetadata}: Props): JSX.Element {
|
|
|
52
53
|
{author.description && <p>{author.description}</p>}
|
|
53
54
|
<ViewAllAuthorsLink />
|
|
54
55
|
</header>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
{items.length === 0 ? (
|
|
57
|
+
<p>
|
|
58
|
+
<BlogAuthorNoPostsLabel />
|
|
59
|
+
</p>
|
|
60
|
+
) : (
|
|
61
|
+
<>
|
|
62
|
+
<hr />
|
|
63
|
+
<BlogPostItems items={items} />
|
|
64
|
+
<BlogListPaginator metadata={listMetadata} />
|
|
65
|
+
</>
|
|
66
|
+
)}
|
|
58
67
|
</BlogLayout>
|
|
59
68
|
);
|
|
60
69
|
}
|
|
@@ -17,7 +17,7 @@ export default function BlogPostPageMetadata(): JSX.Element {
|
|
|
17
17
|
const image = assets.image ?? frontMatter.image;
|
|
18
18
|
return (
|
|
19
19
|
<PageMetadata
|
|
20
|
-
title={title}
|
|
20
|
+
title={frontMatter.title_meta ?? title}
|
|
21
21
|
description={description}
|
|
22
22
|
keywords={keywords}
|
|
23
23
|
image={image}>
|
|
@@ -59,7 +59,8 @@ function ColorModeToggle({
|
|
|
59
59
|
disabled={!isBrowser}
|
|
60
60
|
title={title}
|
|
61
61
|
aria-label={title}
|
|
62
|
-
aria-live="polite"
|
|
62
|
+
aria-live="polite"
|
|
63
|
+
aria-pressed={value === 'dark' ? 'true' : 'false'}>
|
|
63
64
|
<IconLightMode
|
|
64
65
|
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
65
66
|
/>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/*
|
|
9
9
|
When the navbar is sticky, ensure that on anchor click,
|
|
10
10
|
the browser does not scroll that anchor behind the navbar
|
|
11
|
-
See https://
|
|
11
|
+
See https://x.com/JoshWComeau/status/1332015868725891076
|
|
12
12
|
*/
|
|
13
13
|
.anchorWithStickyNavbar {
|
|
14
14
|
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
|
|
@@ -23,6 +23,8 @@ export default function prismIncludeLanguages(
|
|
|
23
23
|
// avoid polluting global namespace.
|
|
24
24
|
// You can mutate PrismObject: registering plugins, deleting languages... As
|
|
25
25
|
// long as you don't re-assign it
|
|
26
|
+
|
|
27
|
+
const PrismBefore = globalThis.Prism;
|
|
26
28
|
globalThis.Prism = PrismObject;
|
|
27
29
|
|
|
28
30
|
additionalLanguages.forEach((lang) => {
|
|
@@ -34,5 +36,9 @@ export default function prismIncludeLanguages(
|
|
|
34
36
|
require(`prismjs/components/prism-${lang}`);
|
|
35
37
|
});
|
|
36
38
|
|
|
39
|
+
// Clean up and eventually restore former globalThis.Prism object (if any)
|
|
37
40
|
delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism;
|
|
41
|
+
if (typeof PrismBefore !== 'undefined') {
|
|
42
|
+
globalThis.Prism = PrismObject;
|
|
43
|
+
}
|
|
38
44
|
}
|