@docusaurus/theme-classic 0.0.0-5836 → 0.0.0-5838

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.
@@ -11,10 +11,27 @@ import {
11
11
  findFirstSidebarItemLink,
12
12
  useDocById,
13
13
  } from '@docusaurus/theme-common/internal';
14
+ import {usePluralForm} from '@docusaurus/theme-common';
14
15
  import isInternalUrl from '@docusaurus/isInternalUrl';
15
16
  import {translate} from '@docusaurus/Translate';
16
17
  import Heading from '@theme/Heading';
17
18
  import styles from './styles.module.css';
19
+ function useCategoryItemsPlural() {
20
+ const {selectMessage} = usePluralForm();
21
+ return (count) =>
22
+ selectMessage(
23
+ count,
24
+ translate(
25
+ {
26
+ message: '{count} items',
27
+ id: 'theme.docs.DocCard.categoryDescription.plurals',
28
+ description:
29
+ 'The default description for a category card in the generated index about how many items this category includes',
30
+ },
31
+ {count},
32
+ ),
33
+ );
34
+ }
18
35
  function CardContainer({href, children}) {
19
36
  return (
20
37
  <Link
@@ -45,6 +62,7 @@ function CardLayout({href, icon, title, description}) {
45
62
  }
46
63
  function CardCategory({item}) {
47
64
  const href = findFirstSidebarItemLink(item);
65
+ const categoryItemsPlural = useCategoryItemsPlural();
48
66
  // Unexpected: categories that don't have a link have been filtered upfront
49
67
  if (!href) {
50
68
  return null;
@@ -54,18 +72,7 @@ function CardCategory({item}) {
54
72
  href={href}
55
73
  icon="🗃️"
56
74
  title={item.label}
57
- description={
58
- item.description ??
59
- translate(
60
- {
61
- message: '{count} items',
62
- id: 'theme.docs.DocCard.categoryDescription',
63
- description:
64
- 'The default description for a category card in the generated index about how many items this category includes',
65
- },
66
- {count: item.items.length},
67
- )
68
- }
75
+ description={item.description ?? categoryItemsPlural(item.items.length)}
69
76
  />
70
77
  );
71
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5836",
3
+ "version": "0.0.0-5838",
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-5836",
24
- "@docusaurus/mdx-loader": "0.0.0-5836",
25
- "@docusaurus/module-type-aliases": "0.0.0-5836",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5836",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5836",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5836",
29
- "@docusaurus/theme-common": "0.0.0-5836",
30
- "@docusaurus/theme-translations": "0.0.0-5836",
31
- "@docusaurus/types": "0.0.0-5836",
32
- "@docusaurus/utils": "0.0.0-5836",
33
- "@docusaurus/utils-common": "0.0.0-5836",
34
- "@docusaurus/utils-validation": "0.0.0-5836",
23
+ "@docusaurus/core": "0.0.0-5838",
24
+ "@docusaurus/mdx-loader": "0.0.0-5838",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5838",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5838",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5838",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5838",
29
+ "@docusaurus/theme-common": "0.0.0-5838",
30
+ "@docusaurus/theme-translations": "0.0.0-5838",
31
+ "@docusaurus/types": "0.0.0-5838",
32
+ "@docusaurus/utils": "0.0.0-5838",
33
+ "@docusaurus/utils-common": "0.0.0-5838",
34
+ "@docusaurus/utils-validation": "0.0.0-5838",
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": "3e0099e87cc86720ed1cbfcd3df76437ecefaf49"
64
+ "gitHead": "9d51d009a6677ee7e2d1a8c8a0e31d70fc4cd5bd"
65
65
  }
@@ -12,6 +12,7 @@ import {
12
12
  findFirstSidebarItemLink,
13
13
  useDocById,
14
14
  } from '@docusaurus/theme-common/internal';
15
+ import {usePluralForm} from '@docusaurus/theme-common';
15
16
  import isInternalUrl from '@docusaurus/isInternalUrl';
16
17
  import {translate} from '@docusaurus/Translate';
17
18
 
@@ -24,6 +25,23 @@ import type {
24
25
 
25
26
  import styles from './styles.module.css';
26
27
 
28
+ function useCategoryItemsPlural() {
29
+ const {selectMessage} = usePluralForm();
30
+ return (count: number) =>
31
+ selectMessage(
32
+ count,
33
+ translate(
34
+ {
35
+ message: '{count} items',
36
+ id: 'theme.docs.DocCard.categoryDescription.plurals',
37
+ description:
38
+ 'The default description for a category card in the generated index about how many items this category includes',
39
+ },
40
+ {count},
41
+ ),
42
+ );
43
+ }
44
+
27
45
  function CardContainer({
28
46
  href,
29
47
  children,
@@ -76,6 +94,7 @@ function CardCategory({
76
94
  item: PropSidebarItemCategory;
77
95
  }): JSX.Element | null {
78
96
  const href = findFirstSidebarItemLink(item);
97
+ const categoryItemsPlural = useCategoryItemsPlural();
79
98
 
80
99
  // Unexpected: categories that don't have a link have been filtered upfront
81
100
  if (!href) {
@@ -87,18 +106,7 @@ function CardCategory({
87
106
  href={href}
88
107
  icon="🗃️"
89
108
  title={item.label}
90
- description={
91
- item.description ??
92
- translate(
93
- {
94
- message: '{count} items',
95
- id: 'theme.docs.DocCard.categoryDescription',
96
- description:
97
- 'The default description for a category card in the generated index about how many items this category includes',
98
- },
99
- {count: item.items.length},
100
- )
101
- }
109
+ description={item.description ?? categoryItemsPlural(item.items.length)}
102
110
  />
103
111
  );
104
112
  }