@docusaurus/theme-classic 0.0.0-4523 → 0.0.0-4527
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 +6 -4
- package/lib/validateThemeConfig.js +4 -4
- package/lib-next/theme/BackToTopButton/index.js +5 -3
- package/lib-next/theme/BlogPostAuthor/index.js +17 -20
- package/lib-next/theme/BlogPostPage/index.js +3 -2
- package/lib-next/theme/CodeBlock/index.js +2 -1
- package/lib-next/theme/Details/index.js +2 -1
- package/lib-next/theme/DocItem/index.js +3 -2
- package/lib-next/theme/DocPage/index.js +1 -1
- package/lib-next/theme/DocSidebarItem/index.js +18 -8
- package/lib-next/theme/MDXComponents/index.js +4 -3
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -2
- package/lib-next/theme/NavbarItem/index.js +2 -2
- package/lib-next/theme/SearchBar.js +1 -1
- package/lib-next/theme/TOC/index.js +1 -1
- package/lib-next/theme/Tabs/index.js +1 -1
- package/package.json +13 -13
- package/src/index.ts +6 -4
- package/src/theme/BackToTopButton/index.tsx +7 -4
- package/src/theme/BlogPostAuthor/index.tsx +17 -20
- package/src/theme/BlogPostPage/index.tsx +3 -2
- package/src/theme/CodeBlock/index.tsx +2 -1
- package/src/theme/Details/index.tsx +2 -1
- package/src/theme/DocItem/index.tsx +3 -2
- package/src/theme/DocPage/index.tsx +1 -1
- package/src/theme/DocSidebarItem/index.tsx +17 -8
- package/src/theme/MDXComponents/index.tsx +4 -3
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -2
- package/src/theme/NavbarItem/index.tsx +2 -2
- package/src/theme/SearchBar.tsx +1 -1
- package/src/theme/TOC/index.tsx +1 -1
- package/src/theme/Tabs/index.tsx +1 -1
- package/src/translations.ts +1 -1
- package/src/validateThemeConfig.ts +4 -4
package/lib/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
35
|
*/
|
|
36
36
|
const requireFromDocusaurusCore = (0, _module.createRequire)(require.resolve('@docusaurus/core/package.json'));
|
|
37
37
|
const ContextReplacementPlugin = requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin'); // Need to be inlined to prevent dark mode FOUC
|
|
38
|
-
// Make sure
|
|
38
|
+
// Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
|
|
39
39
|
|
|
40
40
|
const ThemeStorageKey = 'theme';
|
|
41
41
|
|
|
@@ -76,15 +76,17 @@ const noFlashColorMode = ({
|
|
|
76
76
|
setDataThemeAttribute(defaultMode === 'dark' ? 'dark' : 'light');
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
})();`; // Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
79
|
+
})();`; // Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
80
|
+
// we need to support older nodejs versions without ESM support
|
|
80
81
|
// TODO: import from theme-common once we only support Node.js with ESM support
|
|
81
82
|
// + move all those announcementBar stuff there too
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
const AnnouncementBarDismissStorageKey = 'docusaurus.announcement.dismiss';
|
|
85
86
|
exports.AnnouncementBarDismissStorageKey = AnnouncementBarDismissStorageKey;
|
|
86
|
-
const AnnouncementBarDismissDataAttribute = 'data-announcement-bar-initially-dismissed'; // We always render the announcement bar html on the server, to prevent layout
|
|
87
|
-
// The theme can use CSS + the data attribute to hide
|
|
87
|
+
const AnnouncementBarDismissDataAttribute = 'data-announcement-bar-initially-dismissed'; // We always render the announcement bar html on the server, to prevent layout
|
|
88
|
+
// shifts on React hydration. The theme can use CSS + the data attribute to hide
|
|
89
|
+
// the announcement bar asap (before React hydration)
|
|
88
90
|
|
|
89
91
|
const AnnouncementBarInlineJavaScript = `
|
|
90
92
|
(function() {
|
|
@@ -58,8 +58,8 @@ const NavbarItemPosition = _utilsValidation.Joi.string().equal('left', 'right').
|
|
|
58
58
|
const NavbarItemBaseSchema = _utilsValidation.Joi.object({
|
|
59
59
|
label: _utilsValidation.Joi.string(),
|
|
60
60
|
className: _utilsValidation.Joi.string()
|
|
61
|
-
}) // We allow any unknown attributes on the links
|
|
62
|
-
//
|
|
61
|
+
}) // We allow any unknown attributes on the links (users may need additional
|
|
62
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
63
63
|
.unknown();
|
|
64
64
|
|
|
65
65
|
const DefaultNavbarItemSchema = NavbarItemBaseSchema.append({
|
|
@@ -208,8 +208,8 @@ const FooterLinkItemSchema = _utilsValidation.Joi.object({
|
|
|
208
208
|
href: _utilsValidation.URISchema,
|
|
209
209
|
html: _utilsValidation.Joi.string(),
|
|
210
210
|
label: _utilsValidation.Joi.string()
|
|
211
|
-
}).xor('to', 'href', 'html').with('to', 'label').with('href', 'label').nand('html', 'label') // We allow any unknown attributes on the links
|
|
212
|
-
//
|
|
211
|
+
}).xor('to', 'href', 'html').with('to', 'label').with('href', 'label').nand('html', 'label') // We allow any unknown attributes on the links (users may need additional
|
|
212
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
213
213
|
.unknown();
|
|
214
214
|
|
|
215
215
|
const CustomCssSchema = _utilsValidation.Joi.alternatives().try(_utilsValidation.Joi.array().items(_utilsValidation.Joi.string().required()), _utilsValidation.Joi.string().required()).optional();
|
|
@@ -17,7 +17,9 @@ const threshold = 300; // Not all have support for smooth scrolling (particularl
|
|
|
17
17
|
// TODO proper detection is currently unreliable!
|
|
18
18
|
// see https://github.com/wessberg/scroll-behavior-polyfill/issues/16
|
|
19
19
|
|
|
20
|
-
const SupportsNativeSmoothScrolling = false; // const SupportsNativeSmoothScrolling =
|
|
20
|
+
const SupportsNativeSmoothScrolling = false; // const SupportsNativeSmoothScrolling =
|
|
21
|
+
// ExecutionEnvironment.canUseDOM &&
|
|
22
|
+
// 'scrollBehavior' in document.documentElement.style;
|
|
21
23
|
|
|
22
24
|
function smoothScrollTopNative() {
|
|
23
25
|
window.scrollTo({
|
|
@@ -41,8 +43,8 @@ function smoothScrollTopPolyfill() {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
rafRecursion(); // Break the recursion
|
|
45
|
-
//
|
|
46
|
+
rafRecursion(); // Break the recursion. Prevents the user from "fighting" against that
|
|
47
|
+
// recursion producing a weird UX
|
|
46
48
|
|
|
47
49
|
return () => raf && cancelAnimationFrame(raf);
|
|
48
50
|
}
|
|
@@ -18,27 +18,24 @@ function BlogPostAuthor({author}) {
|
|
|
18
18
|
</Link>
|
|
19
19
|
)}
|
|
20
20
|
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<span itemProp="name">{name}</span>
|
|
32
|
-
</Link>
|
|
33
|
-
</div>
|
|
34
|
-
{title && (
|
|
35
|
-
<small className="avatar__subtitle" itemProp="description">
|
|
36
|
-
{title}
|
|
37
|
-
</small>
|
|
38
|
-
)}
|
|
21
|
+
{name && (
|
|
22
|
+
<div
|
|
23
|
+
className="avatar__intro"
|
|
24
|
+
itemProp="author"
|
|
25
|
+
itemScope
|
|
26
|
+
itemType="https://schema.org/Person">
|
|
27
|
+
<div className="avatar__name">
|
|
28
|
+
<Link href={url} itemProp="url">
|
|
29
|
+
<span itemProp="name">{name}</span>
|
|
30
|
+
</Link>
|
|
39
31
|
</div>
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
{title && (
|
|
33
|
+
<small className="avatar__subtitle" itemProp="description">
|
|
34
|
+
{title}
|
|
35
|
+
</small>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
)}
|
|
42
39
|
</div>
|
|
43
40
|
);
|
|
44
41
|
}
|
|
@@ -48,8 +48,9 @@ function BlogPostPage(props) {
|
|
|
48
48
|
/>
|
|
49
49
|
) : undefined
|
|
50
50
|
}>
|
|
51
|
-
<Seo // TODO refactor needed: it's a bit annoying but Seo MUST be inside
|
|
52
|
-
// otherwise
|
|
51
|
+
<Seo // TODO refactor needed: it's a bit annoying but Seo MUST be inside
|
|
52
|
+
// BlogLayout, otherwise default image (set by BlogLayout) would shadow
|
|
53
|
+
// the custom blog post image
|
|
53
54
|
title={title}
|
|
54
55
|
description={description}
|
|
55
56
|
keywords={keywords}
|
|
@@ -43,7 +43,8 @@ export default function CodeBlock({
|
|
|
43
43
|
|
|
44
44
|
const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
|
|
45
45
|
const prismTheme = usePrismTheme(); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
|
|
46
|
-
// When the children is not a simple string, we just return a styled block
|
|
46
|
+
// When the children is not a simple string, we just return a styled block
|
|
47
|
+
// without actually highlighting.
|
|
47
48
|
|
|
48
49
|
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
49
50
|
return (
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {Details as DetailsGeneric} from '@docusaurus/theme-common';
|
|
10
|
-
import styles from './styles.module.css'; // Should we have a custom details/summary comp in Infima instead of reusing
|
|
10
|
+
import styles from './styles.module.css'; // Should we have a custom details/summary comp in Infima instead of reusing
|
|
11
|
+
// alert classes?
|
|
11
12
|
|
|
12
13
|
const InfimaClasses = 'alert alert--info';
|
|
13
14
|
export default function Details({...props}) {
|
|
@@ -74,8 +74,9 @@ export default function DocItem(props) {
|
|
|
74
74
|
<div
|
|
75
75
|
className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
|
|
76
76
|
{/*
|
|
77
|
-
Title can be declared inside md content or declared through
|
|
78
|
-
To make both cases consistent,
|
|
77
|
+
Title can be declared inside md content or declared through
|
|
78
|
+
front matter and added manually. To make both cases consistent,
|
|
79
|
+
the added title is added under the same div.markdown block
|
|
79
80
|
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
|
|
80
81
|
*/}
|
|
81
82
|
{shouldAddTitle && (
|
|
@@ -152,7 +152,7 @@ function DocPage(props) {
|
|
|
152
152
|
return (
|
|
153
153
|
<>
|
|
154
154
|
<Head>
|
|
155
|
-
{/* TODO we should add a core addRoute({htmlClassName})
|
|
155
|
+
{/* TODO we should add a core addRoute({htmlClassName}) action */}
|
|
156
156
|
<html className={versionMetadata.className} />
|
|
157
157
|
</Head>
|
|
158
158
|
<DocsVersionProvider version={versionMetadata}>
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
ThemeClassNames,
|
|
16
16
|
useThemeConfig,
|
|
17
17
|
useDocSidebarItemsExpandedState,
|
|
18
|
+
isSamePath,
|
|
18
19
|
} from '@docusaurus/theme-common';
|
|
19
20
|
import Link from '@docusaurus/Link';
|
|
20
21
|
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
@@ -36,7 +37,8 @@ export default function DocSidebarItem({item, ...props}) {
|
|
|
36
37
|
default:
|
|
37
38
|
return <DocSidebarItemLink item={item} {...props} />;
|
|
38
39
|
}
|
|
39
|
-
} // If we navigate to a category and it becomes active, it should automatically
|
|
40
|
+
} // If we navigate to a category and it becomes active, it should automatically
|
|
41
|
+
// expand itself
|
|
40
42
|
|
|
41
43
|
function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
|
|
42
44
|
const wasActive = usePrevious(isActive);
|
|
@@ -47,11 +49,15 @@ function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
|
|
|
47
49
|
setCollapsed(false);
|
|
48
50
|
}
|
|
49
51
|
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* When a collapsible category has no link, we still link it to its first child
|
|
55
|
+
* during SSR as a temporary fallback. This allows to be able to navigate inside
|
|
56
|
+
* the category even when JS fails to load, is delayed or simply disabled
|
|
57
|
+
* React hydration becomes an optional progressive enhancement
|
|
58
|
+
* see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
|
59
|
+
* see https://github.com/facebook/docusaurus/issues/3030
|
|
60
|
+
*/
|
|
55
61
|
|
|
56
62
|
function useCategoryHrefWithSSRFallback(item) {
|
|
57
63
|
const isBrowser = useIsBrowser();
|
|
@@ -80,6 +86,7 @@ function DocSidebarItemCategory({
|
|
|
80
86
|
const {items, label, collapsible, className, href} = item;
|
|
81
87
|
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
82
88
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
89
|
+
const isCurrentPage = isSamePath(href, activePath);
|
|
83
90
|
const {collapsed, setCollapsed} = useCollapsible({
|
|
84
91
|
// active categories are always initialized as expanded
|
|
85
92
|
// the default (item.collapsed) is only used for non-active categories
|
|
@@ -131,7 +138,10 @@ function DocSidebarItemCategory({
|
|
|
131
138
|
},
|
|
132
139
|
className,
|
|
133
140
|
)}>
|
|
134
|
-
<div
|
|
141
|
+
<div
|
|
142
|
+
className={clsx('menu__list-item-collapsible', {
|
|
143
|
+
'menu__list-item-collapsible--active': isCurrentPage,
|
|
144
|
+
})}>
|
|
135
145
|
<Link
|
|
136
146
|
className={clsx('menu__link', {
|
|
137
147
|
'menu__link--sublist': collapsible && !href,
|
|
@@ -155,7 +165,7 @@ function DocSidebarItemCategory({
|
|
|
155
165
|
onItemClick?.(item);
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
|
-
aria-current={
|
|
168
|
+
aria-current={isCurrentPage ? 'page' : undefined}
|
|
159
169
|
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
|
160
170
|
{...props}>
|
|
161
171
|
{label}
|
|
@@ -10,8 +10,8 @@ import Link from '@docusaurus/Link';
|
|
|
10
10
|
import CodeBlock from '@theme/CodeBlock';
|
|
11
11
|
import Heading from '@theme/Heading';
|
|
12
12
|
import Details from '@theme/Details';
|
|
13
|
-
import './styles.css'; // MDX elements are wrapped through the MDX pragma
|
|
14
|
-
//
|
|
13
|
+
import './styles.css'; // MDX elements are wrapped through the MDX pragma. In some cases (notably usage
|
|
14
|
+
// with Head/Helmet) we need to unwrap those elements.
|
|
15
15
|
|
|
16
16
|
function unwrapMDXElement(element) {
|
|
17
17
|
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
@@ -45,7 +45,8 @@ const MDXComponents = {
|
|
|
45
45
|
/>
|
|
46
46
|
),
|
|
47
47
|
details: (props) => {
|
|
48
|
-
const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the
|
|
48
|
+
const items = React.Children.toArray(props.children); // Split summary item from the rest to pass it as a separate prop to the
|
|
49
|
+
// Details theme component
|
|
49
50
|
|
|
50
51
|
const summary = items.find((item) => item?.props?.mdxType === 'summary');
|
|
51
52
|
const children = <>{items.filter((item) => item !== summary)}</>;
|
|
@@ -68,8 +68,8 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
68
68
|
const dropdownTo =
|
|
69
69
|
mobile && items.length > 1
|
|
70
70
|
? undefined
|
|
71
|
-
: getVersionMainDoc(dropdownVersion).path; // We don't want to render a version dropdown with 0 or 1 item
|
|
72
|
-
//
|
|
71
|
+
: getVersionMainDoc(dropdownVersion).path; // We don't want to render a version dropdown with 0 or 1 item. If we build
|
|
72
|
+
// the site with a single docs version (onlyIncludeVersions: ['1.0.0']),
|
|
73
73
|
// We'd rather render a button instead of a dropdown
|
|
74
74
|
|
|
75
75
|
if (items.length <= 1) {
|
|
@@ -14,8 +14,8 @@ const NavbarItemComponents = {
|
|
|
14
14
|
localeDropdown: () => LocaleDropdownNavbarItem,
|
|
15
15
|
search: () => SearchNavbarItem,
|
|
16
16
|
dropdown: () => DropdownNavbarItem,
|
|
17
|
-
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
18
|
-
// See https://github.com/facebook/docusaurus/issues/3360
|
|
17
|
+
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
18
|
+
// loaded. See https://github.com/facebook/docusaurus/issues/3360
|
|
19
19
|
|
|
20
20
|
/* eslint-disable @typescript-eslint/no-var-requires, global-require */
|
|
21
21
|
docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
// By default, the classic theme does not provide any SearchBar implementation
|
|
8
|
-
// If you swizzled this
|
|
8
|
+
// If you swizzled this, it is your responsibility to provide an implementation
|
|
9
9
|
// Tip: swizzle the SearchBar from the Algolia theme for inspiration:
|
|
10
10
|
// npm run swizzle @docusaurus/theme-search-algolia SearchBar
|
|
11
11
|
export {default} from '@docusaurus/Noop';
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import TOCItems from '@theme/TOCItems';
|
|
10
10
|
import styles from './styles.module.css'; // Using a custom className
|
|
11
|
-
// This prevents
|
|
11
|
+
// This prevents TOCInline/TOCCollapsible getting highlighted by mistake
|
|
12
12
|
|
|
13
13
|
const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
|
|
14
14
|
const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
|
|
@@ -42,7 +42,7 @@ function TabsComponent(props) {
|
|
|
42
42
|
);
|
|
43
43
|
});
|
|
44
44
|
const values =
|
|
45
|
-
valuesProp ?? //
|
|
45
|
+
valuesProp ?? // Only pick keys that we recognize. MDX would inject some keys by default
|
|
46
46
|
children.map(({props: {value, label, attributes}}) => ({
|
|
47
47
|
value,
|
|
48
48
|
label,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4527",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4527",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4527",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4527",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4527",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4527",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4527",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4527",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4527",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4527",
|
|
33
33
|
"@mdx-js/react": "^1.6.21",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"rtlcss": "^3.3.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
46
|
-
"@docusaurus/types": "0.0.0-
|
|
45
|
+
"@docusaurus/module-type-aliases": "0.0.0-4527",
|
|
46
|
+
"@docusaurus/types": "0.0.0-4527",
|
|
47
47
|
"@types/mdx-js__react": "^1.5.4",
|
|
48
48
|
"@types/parse-numeric-range": "^0.0.1",
|
|
49
49
|
"@types/prismjs": "^1.16.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "fdd9e4feffd46f92b4ee3c519026bff7f2de6d05"
|
|
66
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ const ContextReplacementPlugin: typeof webpack.ContextReplacementPlugin =
|
|
|
23
23
|
requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin');
|
|
24
24
|
|
|
25
25
|
// Need to be inlined to prevent dark mode FOUC
|
|
26
|
-
// Make sure
|
|
26
|
+
// Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
|
|
27
27
|
const ThemeStorageKey = 'theme';
|
|
28
28
|
const noFlashColorMode = ({
|
|
29
29
|
defaultMode,
|
|
@@ -64,15 +64,17 @@ const noFlashColorMode = ({
|
|
|
64
64
|
}
|
|
65
65
|
})();`;
|
|
66
66
|
|
|
67
|
-
// Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
67
|
+
// Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
68
|
+
// we need to support older nodejs versions without ESM support
|
|
68
69
|
// TODO: import from theme-common once we only support Node.js with ESM support
|
|
69
70
|
// + move all those announcementBar stuff there too
|
|
70
71
|
export const AnnouncementBarDismissStorageKey =
|
|
71
72
|
'docusaurus.announcement.dismiss';
|
|
72
73
|
const AnnouncementBarDismissDataAttribute =
|
|
73
74
|
'data-announcement-bar-initially-dismissed';
|
|
74
|
-
// We always render the announcement bar html on the server, to prevent layout
|
|
75
|
-
// The theme can use CSS + the data attribute to hide
|
|
75
|
+
// We always render the announcement bar html on the server, to prevent layout
|
|
76
|
+
// shifts on React hydration. The theme can use CSS + the data attribute to hide
|
|
77
|
+
// the announcement bar asap (before React hydration)
|
|
76
78
|
const AnnouncementBarInlineJavaScript = `
|
|
77
79
|
(function() {
|
|
78
80
|
function isDismissed() {
|
|
@@ -22,7 +22,9 @@ const threshold = 300;
|
|
|
22
22
|
// TODO proper detection is currently unreliable!
|
|
23
23
|
// see https://github.com/wessberg/scroll-behavior-polyfill/issues/16
|
|
24
24
|
const SupportsNativeSmoothScrolling = false;
|
|
25
|
-
// const SupportsNativeSmoothScrolling =
|
|
25
|
+
// const SupportsNativeSmoothScrolling =
|
|
26
|
+
// ExecutionEnvironment.canUseDOM &&
|
|
27
|
+
// 'scrollBehavior' in document.documentElement.style;
|
|
26
28
|
|
|
27
29
|
type CancelScrollTop = () => void;
|
|
28
30
|
|
|
@@ -44,13 +46,14 @@ function smoothScrollTopPolyfill(): CancelScrollTop {
|
|
|
44
46
|
}
|
|
45
47
|
rafRecursion();
|
|
46
48
|
|
|
47
|
-
// Break the recursion
|
|
48
|
-
//
|
|
49
|
+
// Break the recursion. Prevents the user from "fighting" against that
|
|
50
|
+
// recursion producing a weird UX
|
|
49
51
|
return () => raf && cancelAnimationFrame(raf);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
type UseSmoothScrollTopReturn = {
|
|
53
|
-
// We use a cancel function because the non-native smooth scroll-top
|
|
55
|
+
// We use a cancel function because the non-native smooth scroll-top
|
|
56
|
+
// implementation must be interrupted if user scroll down
|
|
54
57
|
smoothScrollTop: () => void;
|
|
55
58
|
cancelScrollToTop: CancelScrollTop;
|
|
56
59
|
};
|
|
@@ -21,27 +21,24 @@ function BlogPostAuthor({author}: Props): JSX.Element {
|
|
|
21
21
|
</Link>
|
|
22
22
|
)}
|
|
23
23
|
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<span itemProp="name">{name}</span>
|
|
35
|
-
</Link>
|
|
36
|
-
</div>
|
|
37
|
-
{title && (
|
|
38
|
-
<small className="avatar__subtitle" itemProp="description">
|
|
39
|
-
{title}
|
|
40
|
-
</small>
|
|
41
|
-
)}
|
|
24
|
+
{name && (
|
|
25
|
+
<div
|
|
26
|
+
className="avatar__intro"
|
|
27
|
+
itemProp="author"
|
|
28
|
+
itemScope
|
|
29
|
+
itemType="https://schema.org/Person">
|
|
30
|
+
<div className="avatar__name">
|
|
31
|
+
<Link href={url} itemProp="url">
|
|
32
|
+
<span itemProp="name">{name}</span>
|
|
33
|
+
</Link>
|
|
42
34
|
</div>
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
{title && (
|
|
36
|
+
<small className="avatar__subtitle" itemProp="description">
|
|
37
|
+
{title}
|
|
38
|
+
</small>
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
45
42
|
</div>
|
|
46
43
|
);
|
|
47
44
|
}
|
|
@@ -53,8 +53,9 @@ function BlogPostPage(props: Props): JSX.Element {
|
|
|
53
53
|
) : undefined
|
|
54
54
|
}>
|
|
55
55
|
<Seo
|
|
56
|
-
// TODO refactor needed: it's a bit annoying but Seo MUST be inside
|
|
57
|
-
// otherwise
|
|
56
|
+
// TODO refactor needed: it's a bit annoying but Seo MUST be inside
|
|
57
|
+
// BlogLayout, otherwise default image (set by BlogLayout) would shadow
|
|
58
|
+
// the custom blog post image
|
|
58
59
|
title={title}
|
|
59
60
|
description={description}
|
|
60
61
|
keywords={keywords}
|
|
@@ -51,7 +51,8 @@ export default function CodeBlock({
|
|
|
51
51
|
const prismTheme = usePrismTheme();
|
|
52
52
|
|
|
53
53
|
// <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
|
|
54
|
-
// When the children is not a simple string, we just return a styled block
|
|
54
|
+
// When the children is not a simple string, we just return a styled block
|
|
55
|
+
// without actually highlighting.
|
|
55
56
|
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
56
57
|
return (
|
|
57
58
|
<Highlight
|
|
@@ -11,7 +11,8 @@ import {Details as DetailsGeneric} from '@docusaurus/theme-common';
|
|
|
11
11
|
import type {Props} from '@theme/Details';
|
|
12
12
|
import styles from './styles.module.css';
|
|
13
13
|
|
|
14
|
-
// Should we have a custom details/summary comp in Infima instead of reusing
|
|
14
|
+
// Should we have a custom details/summary comp in Infima instead of reusing
|
|
15
|
+
// alert classes?
|
|
15
16
|
const InfimaClasses = 'alert alert--info';
|
|
16
17
|
|
|
17
18
|
export default function Details({...props}: Props): JSX.Element {
|
|
@@ -75,8 +75,9 @@ export default function DocItem(props: Props): JSX.Element {
|
|
|
75
75
|
<div
|
|
76
76
|
className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
|
|
77
77
|
{/*
|
|
78
|
-
Title can be declared inside md content or declared through
|
|
79
|
-
To make both cases consistent,
|
|
78
|
+
Title can be declared inside md content or declared through
|
|
79
|
+
front matter and added manually. To make both cases consistent,
|
|
80
|
+
the added title is added under the same div.markdown block
|
|
80
81
|
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
|
|
81
82
|
*/}
|
|
82
83
|
{shouldAddTitle && (
|
|
@@ -168,7 +168,7 @@ function DocPage(props: Props): JSX.Element {
|
|
|
168
168
|
return (
|
|
169
169
|
<>
|
|
170
170
|
<Head>
|
|
171
|
-
{/* TODO we should add a core addRoute({htmlClassName})
|
|
171
|
+
{/* TODO we should add a core addRoute({htmlClassName}) action */}
|
|
172
172
|
<html className={versionMetadata.className} />
|
|
173
173
|
</Head>
|
|
174
174
|
<DocsVersionProvider version={versionMetadata}>
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
ThemeClassNames,
|
|
17
17
|
useThemeConfig,
|
|
18
18
|
useDocSidebarItemsExpandedState,
|
|
19
|
+
isSamePath,
|
|
19
20
|
} from '@docusaurus/theme-common';
|
|
20
21
|
import Link from '@docusaurus/Link';
|
|
21
22
|
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
@@ -48,7 +49,8 @@ export default function DocSidebarItem({
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
// If we navigate to a category and it becomes active, it should automatically
|
|
52
|
+
// If we navigate to a category and it becomes active, it should automatically
|
|
53
|
+
// expand itself
|
|
52
54
|
function useAutoExpandActiveCategory({
|
|
53
55
|
isActive,
|
|
54
56
|
collapsed,
|
|
@@ -67,11 +69,14 @@ function useAutoExpandActiveCategory({
|
|
|
67
69
|
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* When a collapsible category has no link, we still link it to its first child
|
|
74
|
+
* during SSR as a temporary fallback. This allows to be able to navigate inside
|
|
75
|
+
* the category even when JS fails to load, is delayed or simply disabled
|
|
76
|
+
* React hydration becomes an optional progressive enhancement
|
|
77
|
+
* see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
|
78
|
+
* see https://github.com/facebook/docusaurus/issues/3030
|
|
79
|
+
*/
|
|
75
80
|
function useCategoryHrefWithSSRFallback(
|
|
76
81
|
item: PropSidebarItemCategory,
|
|
77
82
|
): string | undefined {
|
|
@@ -101,6 +106,7 @@ function DocSidebarItemCategory({
|
|
|
101
106
|
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
102
107
|
|
|
103
108
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
109
|
+
const isCurrentPage = isSamePath(href, activePath);
|
|
104
110
|
|
|
105
111
|
const {collapsed, setCollapsed} = useCollapsible({
|
|
106
112
|
// active categories are always initialized as expanded
|
|
@@ -148,7 +154,10 @@ function DocSidebarItemCategory({
|
|
|
148
154
|
},
|
|
149
155
|
className,
|
|
150
156
|
)}>
|
|
151
|
-
<div
|
|
157
|
+
<div
|
|
158
|
+
className={clsx('menu__list-item-collapsible', {
|
|
159
|
+
'menu__list-item-collapsible--active': isCurrentPage,
|
|
160
|
+
})}>
|
|
152
161
|
<Link
|
|
153
162
|
className={clsx('menu__link', {
|
|
154
163
|
'menu__link--sublist': collapsible && !href,
|
|
@@ -171,7 +180,7 @@ function DocSidebarItemCategory({
|
|
|
171
180
|
onItemClick?.(item);
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
|
-
aria-current={
|
|
183
|
+
aria-current={isCurrentPage ? 'page' : undefined}
|
|
175
184
|
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
|
176
185
|
{...props}>
|
|
177
186
|
{label}
|
|
@@ -19,8 +19,8 @@ import type {MDXComponentsObject} from '@theme/MDXComponents';
|
|
|
19
19
|
|
|
20
20
|
import './styles.css';
|
|
21
21
|
|
|
22
|
-
// MDX elements are wrapped through the MDX pragma
|
|
23
|
-
//
|
|
22
|
+
// MDX elements are wrapped through the MDX pragma. In some cases (notably usage
|
|
23
|
+
// with Head/Helmet) we need to unwrap those elements.
|
|
24
24
|
function unwrapMDXElement(element: ReactElement) {
|
|
25
25
|
if (element?.props?.mdxType && element?.props?.originalType) {
|
|
26
26
|
const {mdxType, originalType, ...newProps} = element.props;
|
|
@@ -55,7 +55,8 @@ const MDXComponents: MDXComponentsObject = {
|
|
|
55
55
|
),
|
|
56
56
|
details: (props): JSX.Element => {
|
|
57
57
|
const items = React.Children.toArray(props.children) as ReactElement[];
|
|
58
|
-
// Split summary item from the rest to pass it as a separate prop to the
|
|
58
|
+
// Split summary item from the rest to pass it as a separate prop to the
|
|
59
|
+
// Details theme component
|
|
59
60
|
const summary: ReactElement<ComponentProps<'summary'>> = items.find(
|
|
60
61
|
(item) => item?.props?.mdxType === 'summary',
|
|
61
62
|
)!;
|
|
@@ -78,8 +78,8 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
78
78
|
? undefined
|
|
79
79
|
: getVersionMainDoc(dropdownVersion).path;
|
|
80
80
|
|
|
81
|
-
// We don't want to render a version dropdown with 0 or 1 item
|
|
82
|
-
//
|
|
81
|
+
// We don't want to render a version dropdown with 0 or 1 item. If we build
|
|
82
|
+
// the site with a single docs version (onlyIncludeVersions: ['1.0.0']),
|
|
83
83
|
// We'd rather render a button instead of a dropdown
|
|
84
84
|
if (items.length <= 1) {
|
|
85
85
|
return (
|
|
@@ -25,8 +25,8 @@ const NavbarItemComponents: Record<
|
|
|
25
25
|
search: () => SearchNavbarItem,
|
|
26
26
|
dropdown: () => DropdownNavbarItem,
|
|
27
27
|
|
|
28
|
-
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
29
|
-
// See https://github.com/facebook/docusaurus/issues/3360
|
|
28
|
+
// Need to lazy load these items as we don't know for sure the docs plugin is
|
|
29
|
+
// loaded. See https://github.com/facebook/docusaurus/issues/3360
|
|
30
30
|
/* eslint-disable @typescript-eslint/no-var-requires, global-require */
|
|
31
31
|
docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default,
|
|
32
32
|
docsVersionDropdown: () =>
|
package/src/theme/SearchBar.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// By default, the classic theme does not provide any SearchBar implementation
|
|
9
|
-
// If you swizzled this
|
|
9
|
+
// If you swizzled this, it is your responsibility to provide an implementation
|
|
10
10
|
// Tip: swizzle the SearchBar from the Algolia theme for inspiration:
|
|
11
11
|
// npm run swizzle @docusaurus/theme-search-algolia SearchBar
|
|
12
12
|
export {default} from '@docusaurus/Noop';
|
package/src/theme/TOC/index.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import TOCItems from '@theme/TOCItems';
|
|
|
12
12
|
import styles from './styles.module.css';
|
|
13
13
|
|
|
14
14
|
// Using a custom className
|
|
15
|
-
// This prevents
|
|
15
|
+
// This prevents TOCInline/TOCCollapsible getting highlighted by mistake
|
|
16
16
|
const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
|
|
17
17
|
const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
|
|
18
18
|
|
package/src/theme/Tabs/index.tsx
CHANGED
|
@@ -55,7 +55,7 @@ function TabsComponent(props: Props): JSX.Element {
|
|
|
55
55
|
});
|
|
56
56
|
const values =
|
|
57
57
|
valuesProp ??
|
|
58
|
-
//
|
|
58
|
+
// Only pick keys that we recognize. MDX would inject some keys by default
|
|
59
59
|
children.map(({props: {value, label, attributes}}) => ({
|
|
60
60
|
value,
|
|
61
61
|
label,
|
package/src/translations.ts
CHANGED
|
@@ -171,7 +171,7 @@ export function translateThemeConfig({
|
|
|
171
171
|
themeConfig,
|
|
172
172
|
translationFiles,
|
|
173
173
|
}: {
|
|
174
|
-
//
|
|
174
|
+
// To make TS correctly figure out the contravariance in parameter.
|
|
175
175
|
// In practice it's always normalized
|
|
176
176
|
themeConfig: ThemeConfig;
|
|
177
177
|
translationFiles: TranslationFile[];
|
|
@@ -54,8 +54,8 @@ const NavbarItemBaseSchema = Joi.object({
|
|
|
54
54
|
label: Joi.string(),
|
|
55
55
|
className: Joi.string(),
|
|
56
56
|
})
|
|
57
|
-
// We allow any unknown attributes on the links
|
|
58
|
-
//
|
|
57
|
+
// We allow any unknown attributes on the links (users may need additional
|
|
58
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
59
59
|
.unknown();
|
|
60
60
|
|
|
61
61
|
const DefaultNavbarItemSchema = NavbarItemBaseSchema.append({
|
|
@@ -251,8 +251,8 @@ const FooterLinkItemSchema = Joi.object({
|
|
|
251
251
|
.with('to', 'label')
|
|
252
252
|
.with('href', 'label')
|
|
253
253
|
.nand('html', 'label')
|
|
254
|
-
// We allow any unknown attributes on the links
|
|
255
|
-
//
|
|
254
|
+
// We allow any unknown attributes on the links (users may need additional
|
|
255
|
+
// attributes like target, aria-role, data-customAttribute...)
|
|
256
256
|
.unknown();
|
|
257
257
|
|
|
258
258
|
const CustomCssSchema = Joi.alternatives()
|