@docusaurus/theme-classic 0.0.0-5273 → 0.0.0-5281

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.
@@ -24,6 +24,13 @@ function getSwizzleConfig() {
24
24
  },
25
25
  description: 'The color mode toggle to switch between light and dark mode.',
26
26
  },
27
+ DocCardList: {
28
+ actions: {
29
+ eject: 'safe',
30
+ wrap: 'safe',
31
+ },
32
+ description: 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
33
+ },
27
34
  DocSidebar: {
28
35
  actions: {
29
36
  eject: 'unsafe',
@@ -6,4 +6,4 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  import type { Props } from '@theme/DocCardList';
9
- export default function DocCardList({ items, className }: Props): JSX.Element;
9
+ export default function DocCardList(props: Props): JSX.Element;
@@ -6,21 +6,24 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
- import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
9
+ import {
10
+ useCurrentSidebarCategory,
11
+ filterDocCardListItems,
12
+ } from '@docusaurus/theme-common';
10
13
  import DocCard from '@theme/DocCard';
11
- // Filter categories that don't have a link.
12
- function filterItems(items) {
13
- return items.filter((item) => {
14
- if (item.type === 'category') {
15
- return !!findFirstCategoryLink(item);
16
- }
17
- return true;
18
- });
14
+ function DocCardListForCurrentSidebarCategory({className}) {
15
+ const category = useCurrentSidebarCategory();
16
+ return <DocCardList items={category.items} className={className} />;
19
17
  }
20
- export default function DocCardList({items, className}) {
18
+ export default function DocCardList(props) {
19
+ const {items, className} = props;
20
+ if (!items) {
21
+ return <DocCardListForCurrentSidebarCategory {...props} />;
22
+ }
23
+ const filteredItems = filterDocCardListItems(items);
21
24
  return (
22
25
  <section className={clsx('row', className)}>
23
- {filterItems(items).map((item, index) => (
26
+ {filteredItems.map((item, index) => (
24
27
  <article key={index} className="col col--6 margin-bottom--lg">
25
28
  <DocCard item={item} />
26
29
  </article>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5273",
3
+ "version": "0.0.0-5281",
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-5273",
24
- "@docusaurus/mdx-loader": "0.0.0-5273",
25
- "@docusaurus/module-type-aliases": "0.0.0-5273",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5273",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5273",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5273",
29
- "@docusaurus/theme-common": "0.0.0-5273",
30
- "@docusaurus/theme-translations": "0.0.0-5273",
31
- "@docusaurus/types": "0.0.0-5273",
32
- "@docusaurus/utils": "0.0.0-5273",
33
- "@docusaurus/utils-common": "0.0.0-5273",
34
- "@docusaurus/utils-validation": "0.0.0-5273",
23
+ "@docusaurus/core": "0.0.0-5281",
24
+ "@docusaurus/mdx-loader": "0.0.0-5281",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5281",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5281",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5281",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5281",
29
+ "@docusaurus/theme-common": "0.0.0-5281",
30
+ "@docusaurus/theme-translations": "0.0.0-5281",
31
+ "@docusaurus/types": "0.0.0-5281",
32
+ "@docusaurus/utils": "0.0.0-5281",
33
+ "@docusaurus/utils-common": "0.0.0-5281",
34
+ "@docusaurus/utils-validation": "0.0.0-5281",
35
35
  "@mdx-js/react": "^1.6.22",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=16.14"
64
64
  },
65
- "gitHead": "4687ad21af8c136d492fc1416432d6f1550c2225"
65
+ "gitHead": "30e8125600e78fb976c2d0861ac89314116d6936"
66
66
  }
@@ -28,6 +28,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
28
28
  description:
29
29
  'The color mode toggle to switch between light and dark mode.',
30
30
  },
31
+ DocCardList: {
32
+ actions: {
33
+ eject: 'safe',
34
+ wrap: 'safe',
35
+ },
36
+ description:
37
+ 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
38
+ },
31
39
  DocSidebar: {
32
40
  actions: {
33
41
  eject: 'unsafe', // Too much technical code in sidebar, not very safe atm
@@ -7,25 +7,27 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {findFirstCategoryLink} from '@docusaurus/theme-common/internal';
10
+ import {
11
+ useCurrentSidebarCategory,
12
+ filterDocCardListItems,
13
+ } from '@docusaurus/theme-common';
11
14
  import DocCard from '@theme/DocCard';
12
15
  import type {Props} from '@theme/DocCardList';
13
- import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
14
16
 
15
- // Filter categories that don't have a link.
16
- function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
17
- return items.filter((item) => {
18
- if (item.type === 'category') {
19
- return !!findFirstCategoryLink(item);
20
- }
21
- return true;
22
- });
17
+ function DocCardListForCurrentSidebarCategory({className}: Props) {
18
+ const category = useCurrentSidebarCategory();
19
+ return <DocCardList items={category.items} className={className} />;
23
20
  }
24
21
 
25
- export default function DocCardList({items, className}: Props): JSX.Element {
22
+ export default function DocCardList(props: Props): JSX.Element {
23
+ const {items, className} = props;
24
+ if (!items) {
25
+ return <DocCardListForCurrentSidebarCategory {...props} />;
26
+ }
27
+ const filteredItems = filterDocCardListItems(items);
26
28
  return (
27
29
  <section className={clsx('row', className)}>
28
- {filterItems(items).map((item, index) => (
30
+ {filteredItems.map((item, index) => (
29
31
  <article key={index} className="col col--6 margin-bottom--lg">
30
32
  <DocCard item={item} />
31
33
  </article>
@@ -336,7 +336,7 @@ declare module '@theme/DocCardList' {
336
336
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
337
337
 
338
338
  export interface Props {
339
- readonly items: PropSidebarItem[];
339
+ readonly items?: PropSidebarItem[];
340
340
  readonly className?: string;
341
341
  }
342
342