@docusaurus/theme-classic 0.0.0-5985 → 0.0.0-5987
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/options.js +12 -0
- package/lib/theme/BlogSidebar/Content/index.d.ts +11 -0
- package/lib/theme/BlogSidebar/Content/index.js +41 -0
- package/lib/theme/BlogSidebar/Desktop/index.d.ts +4 -1
- package/lib/theme/BlogSidebar/Desktop/index.js +24 -17
- package/lib/theme/BlogSidebar/Desktop/styles.module.css +5 -0
- package/lib/theme/BlogSidebar/Mobile/index.d.ts +4 -1
- package/lib/theme/BlogSidebar/Mobile/index.js +25 -17
- package/lib/theme/BlogSidebar/Mobile/styles.module.css +10 -0
- package/package.json +14 -14
- package/src/options.ts +18 -2
- package/src/theme/BlogSidebar/Content/index.tsx +57 -0
- package/src/theme/BlogSidebar/Desktop/index.tsx +27 -17
- package/src/theme/BlogSidebar/Desktop/styles.module.css +5 -0
- package/src/theme/BlogSidebar/Mobile/index.tsx +29 -17
- package/src/theme/BlogSidebar/Mobile/styles.module.css +10 -0
- package/src/theme-classic.d.ts +13 -0
package/lib/options.js
CHANGED
|
@@ -28,6 +28,16 @@ const DocsSchema = utils_validation_1.Joi.object({
|
|
|
28
28
|
autoCollapseCategories: utils_validation_1.Joi.bool().default(DEFAULT_DOCS_CONFIG.sidebar.autoCollapseCategories),
|
|
29
29
|
}).default(DEFAULT_DOCS_CONFIG.sidebar),
|
|
30
30
|
}).default(DEFAULT_DOCS_CONFIG);
|
|
31
|
+
const DEFAULT_BLOG_CONFIG = {
|
|
32
|
+
sidebar: {
|
|
33
|
+
groupByYear: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const BlogSchema = utils_validation_1.Joi.object({
|
|
37
|
+
sidebar: utils_validation_1.Joi.object({
|
|
38
|
+
groupByYear: utils_validation_1.Joi.bool().default(DEFAULT_BLOG_CONFIG.sidebar.groupByYear),
|
|
39
|
+
}).default(DEFAULT_BLOG_CONFIG.sidebar),
|
|
40
|
+
}).default(DEFAULT_BLOG_CONFIG);
|
|
31
41
|
const DEFAULT_COLOR_MODE_CONFIG = {
|
|
32
42
|
defaultMode: 'light',
|
|
33
43
|
disableSwitch: false,
|
|
@@ -36,6 +46,7 @@ const DEFAULT_COLOR_MODE_CONFIG = {
|
|
|
36
46
|
exports.DEFAULT_CONFIG = {
|
|
37
47
|
colorMode: DEFAULT_COLOR_MODE_CONFIG,
|
|
38
48
|
docs: DEFAULT_DOCS_CONFIG,
|
|
49
|
+
blog: DEFAULT_BLOG_CONFIG,
|
|
39
50
|
metadata: [],
|
|
40
51
|
prism: {
|
|
41
52
|
additionalLanguages: [],
|
|
@@ -295,6 +306,7 @@ exports.ThemeConfigSchema = utils_validation_1.Joi.object({
|
|
|
295
306
|
colorMode: ColorModeSchema,
|
|
296
307
|
image: utils_validation_1.Joi.string(),
|
|
297
308
|
docs: DocsSchema,
|
|
309
|
+
blog: BlogSchema,
|
|
298
310
|
metadata: utils_validation_1.Joi.array()
|
|
299
311
|
.items(HtmlMetadataSchema)
|
|
300
312
|
.default(exports.DEFAULT_CONFIG.metadata),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
|
+
import type { Props } from '@theme/BlogSidebar/Content';
|
|
9
|
+
declare function BlogSidebarContent({ items, yearGroupHeadingClassName, ListComponent, }: Props): ReactNode;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<typeof BlogSidebarContent>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, {memo} from 'react';
|
|
8
|
+
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import {groupBlogSidebarItemsByYear} from '@docusaurus/theme-common/internal';
|
|
10
|
+
import Heading from '@theme/Heading';
|
|
11
|
+
function BlogSidebarYearGroup({year, yearGroupHeadingClassName, children}) {
|
|
12
|
+
return (
|
|
13
|
+
<div role="group">
|
|
14
|
+
<Heading as="h3" className={yearGroupHeadingClassName}>
|
|
15
|
+
{year}
|
|
16
|
+
</Heading>
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function BlogSidebarContent({items, yearGroupHeadingClassName, ListComponent}) {
|
|
22
|
+
const themeConfig = useThemeConfig();
|
|
23
|
+
if (themeConfig.blog.sidebar.groupByYear) {
|
|
24
|
+
const itemsByYear = groupBlogSidebarItemsByYear(items);
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
{itemsByYear.map(([year, yearItems]) => (
|
|
28
|
+
<BlogSidebarYearGroup
|
|
29
|
+
key={year}
|
|
30
|
+
year={year}
|
|
31
|
+
yearGroupHeadingClassName={yearGroupHeadingClassName}>
|
|
32
|
+
<ListComponent items={yearItems} />
|
|
33
|
+
</BlogSidebarYearGroup>
|
|
34
|
+
))}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
return <ListComponent items={items} />;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export default memo(BlogSidebarContent);
|
|
@@ -4,5 +4,8 @@
|
|
|
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
|
+
import React from 'react';
|
|
7
8
|
import type { Props } from '@theme/BlogSidebar/Desktop';
|
|
8
|
-
|
|
9
|
+
declare function BlogSidebarDesktop({ sidebar }: Props): React.JSX.Element;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<typeof BlogSidebarDesktop>;
|
|
11
|
+
export default _default;
|
|
@@ -4,13 +4,27 @@
|
|
|
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
|
-
import React from 'react';
|
|
7
|
+
import React, {memo} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import Link from '@docusaurus/Link';
|
|
10
9
|
import {translate} from '@docusaurus/Translate';
|
|
11
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useVisibleBlogSidebarItems,
|
|
12
|
+
BlogSidebarItemList,
|
|
13
|
+
} from '@docusaurus/theme-common/internal';
|
|
14
|
+
import BlogSidebarContent from '@theme/BlogSidebar/Content';
|
|
12
15
|
import styles from './styles.module.css';
|
|
13
|
-
|
|
16
|
+
const ListComponent = ({items}) => {
|
|
17
|
+
return (
|
|
18
|
+
<BlogSidebarItemList
|
|
19
|
+
items={items}
|
|
20
|
+
ulClassName={clsx(styles.sidebarItemList, 'clean-list')}
|
|
21
|
+
liClassName={styles.sidebarItem}
|
|
22
|
+
linkClassName={styles.sidebarItemLink}
|
|
23
|
+
linkActiveClassName={styles.sidebarItemLinkActive}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
function BlogSidebarDesktop({sidebar}) {
|
|
14
28
|
const items = useVisibleBlogSidebarItems(sidebar.items);
|
|
15
29
|
return (
|
|
16
30
|
<aside className="col col--3">
|
|
@@ -24,20 +38,13 @@ export default function BlogSidebarDesktop({sidebar}) {
|
|
|
24
38
|
<div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
|
|
25
39
|
{sidebar.title}
|
|
26
40
|
</div>
|
|
27
|
-
<
|
|
28
|
-
{items
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
to={item.permalink}
|
|
33
|
-
className={styles.sidebarItemLink}
|
|
34
|
-
activeClassName={styles.sidebarItemLinkActive}>
|
|
35
|
-
{item.title}
|
|
36
|
-
</Link>
|
|
37
|
-
</li>
|
|
38
|
-
))}
|
|
39
|
-
</ul>
|
|
41
|
+
<BlogSidebarContent
|
|
42
|
+
items={items}
|
|
43
|
+
ListComponent={ListComponent}
|
|
44
|
+
yearGroupHeadingClassName={styles.yearGroupHeading}
|
|
45
|
+
/>
|
|
40
46
|
</nav>
|
|
41
47
|
</aside>
|
|
42
48
|
);
|
|
43
49
|
}
|
|
50
|
+
export default memo(BlogSidebarDesktop);
|
|
@@ -4,5 +4,8 @@
|
|
|
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
|
+
import React from 'react';
|
|
7
8
|
import type { Props } from '@theme/BlogSidebar/Mobile';
|
|
8
|
-
|
|
9
|
+
declare function BlogSidebarMobile(props: Props): JSX.Element;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<typeof BlogSidebarMobile>;
|
|
11
|
+
export default _default;
|
|
@@ -4,29 +4,36 @@
|
|
|
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
|
-
import React from 'react';
|
|
8
|
-
import
|
|
9
|
-
|
|
7
|
+
import React, {memo} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
useVisibleBlogSidebarItems,
|
|
10
|
+
BlogSidebarItemList,
|
|
11
|
+
} from '@docusaurus/theme-common/internal';
|
|
10
12
|
import {NavbarSecondaryMenuFiller} from '@docusaurus/theme-common';
|
|
13
|
+
import BlogSidebarContent from '@theme/BlogSidebar/Content';
|
|
14
|
+
import styles from './styles.module.css';
|
|
15
|
+
const ListComponent = ({items}) => {
|
|
16
|
+
return (
|
|
17
|
+
<BlogSidebarItemList
|
|
18
|
+
items={items}
|
|
19
|
+
ulClassName="menu__list"
|
|
20
|
+
liClassName="menu__list-item"
|
|
21
|
+
linkClassName="menu__link"
|
|
22
|
+
linkActiveClassName="menu__link--active"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
11
26
|
function BlogSidebarMobileSecondaryMenu({sidebar}) {
|
|
12
27
|
const items = useVisibleBlogSidebarItems(sidebar.items);
|
|
13
28
|
return (
|
|
14
|
-
<
|
|
15
|
-
{items
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
to={item.permalink}
|
|
20
|
-
className="menu__link"
|
|
21
|
-
activeClassName="menu__link--active">
|
|
22
|
-
{item.title}
|
|
23
|
-
</Link>
|
|
24
|
-
</li>
|
|
25
|
-
))}
|
|
26
|
-
</ul>
|
|
29
|
+
<BlogSidebarContent
|
|
30
|
+
items={items}
|
|
31
|
+
ListComponent={ListComponent}
|
|
32
|
+
yearGroupHeadingClassName={styles.yearGroupHeading}
|
|
33
|
+
/>
|
|
27
34
|
);
|
|
28
35
|
}
|
|
29
|
-
|
|
36
|
+
function BlogSidebarMobile(props) {
|
|
30
37
|
return (
|
|
31
38
|
<NavbarSecondaryMenuFiller
|
|
32
39
|
component={BlogSidebarMobileSecondaryMenu}
|
|
@@ -34,3 +41,4 @@ export default function BlogSidebarMobile(props) {
|
|
|
34
41
|
/>
|
|
35
42
|
);
|
|
36
43
|
}
|
|
44
|
+
export default memo(BlogSidebarMobile);
|
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-5987",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "0.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
25
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
28
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
31
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
34
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
23
|
+
"@docusaurus/core": "0.0.0-5987",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5987",
|
|
25
|
+
"@docusaurus/module-type-aliases": "0.0.0-5987",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5987",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5987",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5987",
|
|
29
|
+
"@docusaurus/theme-common": "0.0.0-5987",
|
|
30
|
+
"@docusaurus/theme-translations": "0.0.0-5987",
|
|
31
|
+
"@docusaurus/types": "0.0.0-5987",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-5987",
|
|
33
|
+
"@docusaurus/utils-common": "0.0.0-5987",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-5987",
|
|
35
35
|
"@mdx-js/react": "^3.0.0",
|
|
36
36
|
"clsx": "^2.0.0",
|
|
37
37
|
"copy-text-to-clipboard": "^3.2.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=18.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "89b1afe104ab4f3fb765d2ba875d34753f77efe8"
|
|
65
65
|
}
|
package/src/options.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
} from '@docusaurus/types';
|
|
16
16
|
|
|
17
17
|
const defaultPrismTheme = themes.palenight;
|
|
18
|
+
|
|
18
19
|
const DEFAULT_DOCS_CONFIG: ThemeConfig['docs'] = {
|
|
19
20
|
versionPersistence: 'localStorage',
|
|
20
21
|
sidebar: {
|
|
@@ -22,11 +23,12 @@ const DEFAULT_DOCS_CONFIG: ThemeConfig['docs'] = {
|
|
|
22
23
|
autoCollapseCategories: false,
|
|
23
24
|
},
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
const DocsSchema = Joi.object<ThemeConfig['docs']>({
|
|
26
28
|
versionPersistence: Joi.string()
|
|
27
29
|
.equal('localStorage', 'none')
|
|
28
30
|
.default(DEFAULT_DOCS_CONFIG.versionPersistence),
|
|
29
|
-
sidebar: Joi.object({
|
|
31
|
+
sidebar: Joi.object<ThemeConfig['docs']['sidebar']>({
|
|
30
32
|
hideable: Joi.bool().default(DEFAULT_DOCS_CONFIG.sidebar.hideable),
|
|
31
33
|
autoCollapseCategories: Joi.bool().default(
|
|
32
34
|
DEFAULT_DOCS_CONFIG.sidebar.autoCollapseCategories,
|
|
@@ -34,6 +36,18 @@ const DocsSchema = Joi.object({
|
|
|
34
36
|
}).default(DEFAULT_DOCS_CONFIG.sidebar),
|
|
35
37
|
}).default(DEFAULT_DOCS_CONFIG);
|
|
36
38
|
|
|
39
|
+
const DEFAULT_BLOG_CONFIG: ThemeConfig['blog'] = {
|
|
40
|
+
sidebar: {
|
|
41
|
+
groupByYear: true,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const BlogSchema = Joi.object<ThemeConfig['blog']>({
|
|
46
|
+
sidebar: Joi.object<ThemeConfig['blog']['sidebar']>({
|
|
47
|
+
groupByYear: Joi.bool().default(DEFAULT_BLOG_CONFIG.sidebar.groupByYear),
|
|
48
|
+
}).default(DEFAULT_BLOG_CONFIG.sidebar),
|
|
49
|
+
}).default(DEFAULT_BLOG_CONFIG);
|
|
50
|
+
|
|
37
51
|
const DEFAULT_COLOR_MODE_CONFIG: ThemeConfig['colorMode'] = {
|
|
38
52
|
defaultMode: 'light',
|
|
39
53
|
disableSwitch: false,
|
|
@@ -43,6 +57,7 @@ const DEFAULT_COLOR_MODE_CONFIG: ThemeConfig['colorMode'] = {
|
|
|
43
57
|
export const DEFAULT_CONFIG: ThemeConfig = {
|
|
44
58
|
colorMode: DEFAULT_COLOR_MODE_CONFIG,
|
|
45
59
|
docs: DEFAULT_DOCS_CONFIG,
|
|
60
|
+
blog: DEFAULT_BLOG_CONFIG,
|
|
46
61
|
metadata: [],
|
|
47
62
|
prism: {
|
|
48
63
|
additionalLanguages: [],
|
|
@@ -333,6 +348,7 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
|
|
|
333
348
|
colorMode: ColorModeSchema,
|
|
334
349
|
image: Joi.string(),
|
|
335
350
|
docs: DocsSchema,
|
|
351
|
+
blog: BlogSchema,
|
|
336
352
|
metadata: Joi.array()
|
|
337
353
|
.items(HtmlMetadataSchema)
|
|
338
354
|
.default(DEFAULT_CONFIG.metadata),
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, {memo, type ReactNode} from 'react';
|
|
8
|
+
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
9
|
+
import {groupBlogSidebarItemsByYear} from '@docusaurus/theme-common/internal';
|
|
10
|
+
import Heading from '@theme/Heading';
|
|
11
|
+
import type {Props} from '@theme/BlogSidebar/Content';
|
|
12
|
+
|
|
13
|
+
function BlogSidebarYearGroup({
|
|
14
|
+
year,
|
|
15
|
+
yearGroupHeadingClassName,
|
|
16
|
+
children,
|
|
17
|
+
}: {
|
|
18
|
+
year: string;
|
|
19
|
+
yearGroupHeadingClassName?: string;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<div role="group">
|
|
24
|
+
<Heading as="h3" className={yearGroupHeadingClassName}>
|
|
25
|
+
{year}
|
|
26
|
+
</Heading>
|
|
27
|
+
{children}
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function BlogSidebarContent({
|
|
33
|
+
items,
|
|
34
|
+
yearGroupHeadingClassName,
|
|
35
|
+
ListComponent,
|
|
36
|
+
}: Props): ReactNode {
|
|
37
|
+
const themeConfig = useThemeConfig();
|
|
38
|
+
if (themeConfig.blog.sidebar.groupByYear) {
|
|
39
|
+
const itemsByYear = groupBlogSidebarItemsByYear(items);
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{itemsByYear.map(([year, yearItems]) => (
|
|
43
|
+
<BlogSidebarYearGroup
|
|
44
|
+
key={year}
|
|
45
|
+
year={year}
|
|
46
|
+
yearGroupHeadingClassName={yearGroupHeadingClassName}>
|
|
47
|
+
<ListComponent items={yearItems} />
|
|
48
|
+
</BlogSidebarYearGroup>
|
|
49
|
+
))}
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
return <ListComponent items={items} />;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default memo(BlogSidebarContent);
|
|
@@ -5,16 +5,32 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, {memo} from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import Link from '@docusaurus/Link';
|
|
11
10
|
import {translate} from '@docusaurus/Translate';
|
|
12
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useVisibleBlogSidebarItems,
|
|
13
|
+
BlogSidebarItemList,
|
|
14
|
+
} from '@docusaurus/theme-common/internal';
|
|
15
|
+
import BlogSidebarContent from '@theme/BlogSidebar/Content';
|
|
16
|
+
import type {Props as BlogSidebarContentProps} from '@theme/BlogSidebar/Content';
|
|
13
17
|
import type {Props} from '@theme/BlogSidebar/Desktop';
|
|
14
18
|
|
|
15
19
|
import styles from './styles.module.css';
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
const ListComponent: BlogSidebarContentProps['ListComponent'] = ({items}) => {
|
|
22
|
+
return (
|
|
23
|
+
<BlogSidebarItemList
|
|
24
|
+
items={items}
|
|
25
|
+
ulClassName={clsx(styles.sidebarItemList, 'clean-list')}
|
|
26
|
+
liClassName={styles.sidebarItem}
|
|
27
|
+
linkClassName={styles.sidebarItemLink}
|
|
28
|
+
linkActiveClassName={styles.sidebarItemLinkActive}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function BlogSidebarDesktop({sidebar}: Props) {
|
|
18
34
|
const items = useVisibleBlogSidebarItems(sidebar.items);
|
|
19
35
|
return (
|
|
20
36
|
<aside className="col col--3">
|
|
@@ -28,20 +44,14 @@ export default function BlogSidebarDesktop({sidebar}: Props): JSX.Element {
|
|
|
28
44
|
<div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
|
|
29
45
|
{sidebar.title}
|
|
30
46
|
</div>
|
|
31
|
-
<
|
|
32
|
-
{items
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
to={item.permalink}
|
|
37
|
-
className={styles.sidebarItemLink}
|
|
38
|
-
activeClassName={styles.sidebarItemLinkActive}>
|
|
39
|
-
{item.title}
|
|
40
|
-
</Link>
|
|
41
|
-
</li>
|
|
42
|
-
))}
|
|
43
|
-
</ul>
|
|
47
|
+
<BlogSidebarContent
|
|
48
|
+
items={items}
|
|
49
|
+
ListComponent={ListComponent}
|
|
50
|
+
yearGroupHeadingClassName={styles.yearGroupHeading}
|
|
51
|
+
/>
|
|
44
52
|
</nav>
|
|
45
53
|
</aside>
|
|
46
54
|
);
|
|
47
55
|
}
|
|
56
|
+
|
|
57
|
+
export default memo(BlogSidebarDesktop);
|
|
@@ -5,32 +5,42 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import
|
|
10
|
-
|
|
8
|
+
import React, {memo} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
useVisibleBlogSidebarItems,
|
|
11
|
+
BlogSidebarItemList,
|
|
12
|
+
} from '@docusaurus/theme-common/internal';
|
|
11
13
|
import {NavbarSecondaryMenuFiller} from '@docusaurus/theme-common';
|
|
14
|
+
import BlogSidebarContent from '@theme/BlogSidebar/Content';
|
|
12
15
|
import type {Props} from '@theme/BlogSidebar/Mobile';
|
|
16
|
+
import type {Props as BlogSidebarContentProps} from '@theme/BlogSidebar/Content';
|
|
17
|
+
|
|
18
|
+
import styles from './styles.module.css';
|
|
19
|
+
|
|
20
|
+
const ListComponent: BlogSidebarContentProps['ListComponent'] = ({items}) => {
|
|
21
|
+
return (
|
|
22
|
+
<BlogSidebarItemList
|
|
23
|
+
items={items}
|
|
24
|
+
ulClassName="menu__list"
|
|
25
|
+
liClassName="menu__list-item"
|
|
26
|
+
linkClassName="menu__link"
|
|
27
|
+
linkActiveClassName="menu__link--active"
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
13
31
|
|
|
14
32
|
function BlogSidebarMobileSecondaryMenu({sidebar}: Props): JSX.Element {
|
|
15
33
|
const items = useVisibleBlogSidebarItems(sidebar.items);
|
|
16
34
|
return (
|
|
17
|
-
<
|
|
18
|
-
{items
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
to={item.permalink}
|
|
23
|
-
className="menu__link"
|
|
24
|
-
activeClassName="menu__link--active">
|
|
25
|
-
{item.title}
|
|
26
|
-
</Link>
|
|
27
|
-
</li>
|
|
28
|
-
))}
|
|
29
|
-
</ul>
|
|
35
|
+
<BlogSidebarContent
|
|
36
|
+
items={items}
|
|
37
|
+
ListComponent={ListComponent}
|
|
38
|
+
yearGroupHeadingClassName={styles.yearGroupHeading}
|
|
39
|
+
/>
|
|
30
40
|
);
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
function BlogSidebarMobile(props: Props): JSX.Element {
|
|
34
44
|
return (
|
|
35
45
|
<NavbarSecondaryMenuFiller
|
|
36
46
|
component={BlogSidebarMobileSecondaryMenu}
|
|
@@ -38,3 +48,5 @@ export default function BlogSidebarMobile(props: Props): JSX.Element {
|
|
|
38
48
|
/>
|
|
39
49
|
);
|
|
40
50
|
}
|
|
51
|
+
|
|
52
|
+
export default memo(BlogSidebarMobile);
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -194,6 +194,19 @@ declare module '@theme/BlogListPaginator' {
|
|
|
194
194
|
export default function BlogListPaginator(props: Props): JSX.Element;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
declare module '@theme/BlogSidebar/Content' {
|
|
198
|
+
import type {ReactNode, ComponentType} from 'react';
|
|
199
|
+
import type {BlogSidebarItem} from '@docusaurus/plugin-content-blog';
|
|
200
|
+
|
|
201
|
+
export interface Props {
|
|
202
|
+
readonly items: BlogSidebarItem[];
|
|
203
|
+
readonly ListComponent: ComponentType<{items: BlogSidebarItem[]}>;
|
|
204
|
+
readonly yearGroupHeadingClassName?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export default function BlogSidebarContent(props: Props): ReactNode;
|
|
208
|
+
}
|
|
209
|
+
|
|
197
210
|
declare module '@theme/BlogSidebar/Desktop' {
|
|
198
211
|
import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
|
|
199
212
|
|