@docusaurus/theme-common 3.4.0 → 3.5.1

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.
Files changed (95) hide show
  1. package/lib/index.d.ts +5 -6
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +18 -6
  4. package/lib/index.js.map +1 -1
  5. package/lib/internal.d.ts +2 -9
  6. package/lib/internal.d.ts.map +1 -1
  7. package/lib/internal.js +2 -9
  8. package/lib/internal.js.map +1 -1
  9. package/lib/translations/blogTranslations.d.ts +19 -0
  10. package/lib/translations/blogTranslations.d.ts.map +1 -0
  11. package/lib/translations/blogTranslations.js +48 -0
  12. package/lib/translations/blogTranslations.js.map +1 -0
  13. package/lib/{utils/unlistedUtils.d.ts → translations/contentVisibilityTranslations.d.ts} +3 -2
  14. package/lib/translations/contentVisibilityTranslations.d.ts.map +1 -0
  15. package/lib/translations/contentVisibilityTranslations.js +39 -0
  16. package/lib/translations/contentVisibilityTranslations.js.map +1 -0
  17. package/lib/utils/ThemeClassNames.d.ts +3 -0
  18. package/lib/utils/ThemeClassNames.d.ts.map +1 -1
  19. package/lib/utils/ThemeClassNames.js +3 -0
  20. package/lib/utils/ThemeClassNames.js.map +1 -1
  21. package/lib/utils/errorBoundaryUtils.d.ts +0 -1
  22. package/lib/utils/errorBoundaryUtils.d.ts.map +1 -1
  23. package/lib/utils/jsUtils.d.ts +1 -0
  24. package/lib/utils/jsUtils.d.ts.map +1 -1
  25. package/lib/utils/jsUtils.js +14 -0
  26. package/lib/utils/jsUtils.js.map +1 -1
  27. package/lib/utils/searchUtils.d.ts +0 -13
  28. package/lib/utils/searchUtils.d.ts.map +1 -1
  29. package/lib/utils/searchUtils.js +0 -39
  30. package/lib/utils/searchUtils.js.map +1 -1
  31. package/lib/utils/storageUtils.d.ts +0 -1
  32. package/lib/utils/storageUtils.d.ts.map +1 -1
  33. package/lib/utils/tabsUtils.d.ts +2 -2
  34. package/lib/utils/tabsUtils.d.ts.map +1 -1
  35. package/lib/utils/useThemeConfig.d.ts +5 -0
  36. package/lib/utils/useThemeConfig.d.ts.map +1 -1
  37. package/lib/utils/useThemeConfig.js.map +1 -1
  38. package/package.json +9 -11
  39. package/src/index.ts +27 -16
  40. package/src/internal.ts +8 -36
  41. package/src/translations/blogTranslations.tsx +79 -0
  42. package/src/{utils/unlistedUtils.tsx → translations/contentVisibilityTranslations.tsx} +25 -2
  43. package/src/types.d.ts +0 -3
  44. package/src/utils/ThemeClassNames.ts +3 -0
  45. package/src/utils/jsUtils.ts +18 -0
  46. package/src/utils/searchUtils.ts +0 -58
  47. package/src/utils/useThemeConfig.ts +6 -0
  48. package/lib/contexts/blogPost.d.ts +0 -33
  49. package/lib/contexts/blogPost.d.ts.map +0 -1
  50. package/lib/contexts/blogPost.js +0 -46
  51. package/lib/contexts/blogPost.js.map +0 -1
  52. package/lib/contexts/doc.d.ts +0 -30
  53. package/lib/contexts/doc.d.ts.map +0 -1
  54. package/lib/contexts/doc.js +0 -48
  55. package/lib/contexts/doc.js.map +0 -1
  56. package/lib/contexts/docSidebarItemsExpandedState.d.ts +0 -31
  57. package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +0 -1
  58. package/lib/contexts/docSidebarItemsExpandedState.js +0 -28
  59. package/lib/contexts/docSidebarItemsExpandedState.js.map +0 -1
  60. package/lib/contexts/docsPreferredVersion.d.ts +0 -30
  61. package/lib/contexts/docsPreferredVersion.d.ts.map +0 -1
  62. package/lib/contexts/docsPreferredVersion.js +0 -130
  63. package/lib/contexts/docsPreferredVersion.js.map +0 -1
  64. package/lib/contexts/docsSidebar.d.ts +0 -26
  65. package/lib/contexts/docsSidebar.d.ts.map +0 -1
  66. package/lib/contexts/docsSidebar.js +0 -30
  67. package/lib/contexts/docsSidebar.js.map +0 -1
  68. package/lib/contexts/docsVersion.d.ts +0 -20
  69. package/lib/contexts/docsVersion.d.ts.map +0 -1
  70. package/lib/contexts/docsVersion.js +0 -26
  71. package/lib/contexts/docsVersion.js.map +0 -1
  72. package/lib/utils/blogUtils.d.ts +0 -13
  73. package/lib/utils/blogUtils.d.ts.map +0 -1
  74. package/lib/utils/blogUtils.js +0 -24
  75. package/lib/utils/blogUtils.js.map +0 -1
  76. package/lib/utils/docsUtils.d.ts +0 -109
  77. package/lib/utils/docsUtils.d.ts.map +0 -1
  78. package/lib/utils/docsUtils.js +0 -276
  79. package/lib/utils/docsUtils.js.map +0 -1
  80. package/lib/utils/structuredDataUtils.d.ts +0 -12
  81. package/lib/utils/structuredDataUtils.d.ts.map +0 -1
  82. package/lib/utils/structuredDataUtils.js +0 -123
  83. package/lib/utils/structuredDataUtils.js.map +0 -1
  84. package/lib/utils/unlistedUtils.d.ts.map +0 -1
  85. package/lib/utils/unlistedUtils.js +0 -26
  86. package/lib/utils/unlistedUtils.js.map +0 -1
  87. package/src/contexts/blogPost.tsx +0 -80
  88. package/src/contexts/doc.tsx +0 -71
  89. package/src/contexts/docSidebarItemsExpandedState.tsx +0 -55
  90. package/src/contexts/docsPreferredVersion.tsx +0 -251
  91. package/src/contexts/docsSidebar.tsx +0 -50
  92. package/src/contexts/docsVersion.tsx +0 -36
  93. package/src/utils/blogUtils.ts +0 -32
  94. package/src/utils/docsUtils.tsx +0 -418
  95. package/src/utils/structuredDataUtils.ts +0 -177
@@ -1 +1 @@
1
- {"version":3,"file":"useThemeConfig.js","sourceRoot":"","sources":["../../src/utils/useThemeConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AA0HpE;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,oBAAoB,EAAE,CAAC,UAAU,CAAC,WAA0B,CAAC;AACtE,CAAC"}
1
+ {"version":3,"file":"useThemeConfig.js","sourceRoot":"","sources":["../../src/utils/useThemeConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAgIpE;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,oBAAoB,EAAE,CAAC,UAAU,CAAC,WAA0B,CAAC;AACtE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-common",
3
- "version": "3.4.0",
3
+ "version": "3.5.1",
4
4
  "description": "Common code for Docusaurus themes.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -30,13 +30,10 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@docusaurus/mdx-loader": "3.4.0",
34
- "@docusaurus/module-type-aliases": "3.4.0",
35
- "@docusaurus/plugin-content-blog": "3.4.0",
36
- "@docusaurus/plugin-content-docs": "3.4.0",
37
- "@docusaurus/plugin-content-pages": "3.4.0",
38
- "@docusaurus/utils": "3.4.0",
39
- "@docusaurus/utils-common": "3.4.0",
33
+ "@docusaurus/mdx-loader": "3.5.1",
34
+ "@docusaurus/module-type-aliases": "3.5.1",
35
+ "@docusaurus/utils": "3.5.1",
36
+ "@docusaurus/utils-common": "3.5.1",
40
37
  "@types/history": "^4.7.11",
41
38
  "@types/react": "*",
42
39
  "@types/react-router-config": "*",
@@ -47,18 +44,19 @@
47
44
  "utility-types": "^3.10.0"
48
45
  },
49
46
  "devDependencies": {
50
- "@docusaurus/core": "3.4.0",
51
- "@docusaurus/types": "3.4.0",
47
+ "@docusaurus/core": "3.5.1",
48
+ "@docusaurus/types": "3.5.1",
52
49
  "fs-extra": "^11.1.1",
53
50
  "lodash": "^4.17.21",
54
51
  "schema-dts": "^1.1.2"
55
52
  },
56
53
  "peerDependencies": {
54
+ "@docusaurus/plugin-content-docs": "*",
57
55
  "react": "^18.0.0",
58
56
  "react-dom": "^18.0.0"
59
57
  },
60
58
  "engines": {
61
59
  "node": ">=18.0"
62
60
  },
63
- "gitHead": "49e9a2143274a8dd795659b417b470bc42abbd6e"
61
+ "gitHead": "5acbc57bd62f3f808ef72007cd67d4c410d13829"
64
62
  }
package/src/index.ts CHANGED
@@ -5,6 +5,29 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ // TODO Docusaurus v4: remove these workarounds as a breaking change
9
+ // and remove docs plugin peerDeps in theme-common/package.json
10
+ // This is public API surface that we need to keep for v3
11
+ // See https://github.com/facebook/docusaurus/pull/10316
12
+ export function useCurrentSidebarCategory(...args: unknown[]): unknown {
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ return require('@docusaurus/plugin-content-docs/client').useCurrentSidebarCategory(
15
+ ...args,
16
+ );
17
+ }
18
+ export function filterDocCardListItems(...args: unknown[]): unknown {
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ return require('@docusaurus/plugin-content-docs/client').filterDocCardListItems(
21
+ ...args,
22
+ );
23
+ }
24
+ export function useDocsPreferredVersion(...args: unknown[]): unknown {
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ return require('@docusaurus/plugin-content-docs/client').useDocsPreferredVersion(
27
+ ...args,
28
+ );
29
+ }
30
+
8
31
  /*
9
32
  * APIs to document
10
33
  */
@@ -32,18 +55,6 @@ export {
32
55
  listStorageKeys,
33
56
  } from './utils/storageUtils';
34
57
 
35
- export {useContextualSearchFilters} from './utils/searchUtils';
36
-
37
- export {
38
- useCurrentSidebarCategory,
39
- filterDocCardListItems,
40
- } from './utils/docsUtils';
41
-
42
- export {
43
- useBlogListPageStructuredData,
44
- useBlogPostStructuredData,
45
- } from './utils/structuredDataUtils';
46
-
47
58
  export {usePluralForm} from './utils/usePluralForm';
48
59
 
49
60
  export {useCollapsible, Collapsible} from './components/Collapsible';
@@ -90,12 +101,10 @@ export {isMultiColumnFooterLinks} from './utils/footerUtils';
90
101
 
91
102
  export {isRegexpStringMatch} from './utils/regexpUtils';
92
103
 
93
- export {duplicates, uniq} from './utils/jsUtils';
104
+ export {duplicates, uniq, groupBy} from './utils/jsUtils';
94
105
 
95
106
  export {usePrismTheme} from './hooks/usePrismTheme';
96
107
 
97
- export {useDocsPreferredVersion} from './contexts/docsPreferredVersion';
98
-
99
108
  export {processAdmonitionProps} from './utils/admonitionUtils';
100
109
 
101
110
  export {
@@ -114,7 +123,9 @@ export {
114
123
  UnlistedBannerTitle,
115
124
  UnlistedBannerMessage,
116
125
  UnlistedMetadata,
117
- } from './utils/unlistedUtils';
126
+ DraftBannerTitle,
127
+ DraftBannerMessage,
128
+ } from './translations/contentVisibilityTranslations';
118
129
 
119
130
  export {
120
131
  ErrorBoundaryTryAgainButton,
package/src/internal.ts CHANGED
@@ -18,25 +18,6 @@
18
18
  // eslint-disable-next-line no-restricted-syntax
19
19
  export * from './index';
20
20
 
21
- export {
22
- DocSidebarItemsExpandedStateProvider,
23
- useDocSidebarItemsExpandedState,
24
- } from './contexts/docSidebarItemsExpandedState';
25
- export {DocsVersionProvider, useDocsVersion} from './contexts/docsVersion';
26
- export {DocsSidebarProvider, useDocsSidebar} from './contexts/docsSidebar';
27
-
28
- export {DocProvider, useDoc, type DocContextValue} from './contexts/doc';
29
- export {
30
- BlogPostProvider,
31
- useBlogPost,
32
- type BlogPostContextValue,
33
- } from './contexts/blogPost';
34
-
35
- export {
36
- useDocsPreferredVersionByPluginId,
37
- DocsPreferredVersionContextProvider,
38
- } from './contexts/docsPreferredVersion';
39
-
40
21
  export {
41
22
  AnnouncementBarProvider,
42
23
  useAnnouncementBar,
@@ -59,22 +40,7 @@ export {
59
40
  containsLineNumbers,
60
41
  } from './utils/codeBlockUtils';
61
42
 
62
- export {docVersionSearchTag, DEFAULT_SEARCH_TAG} from './utils/searchUtils';
63
-
64
- export {
65
- isDocsPluginEnabled,
66
- useDocById,
67
- findSidebarCategory,
68
- findFirstSidebarItemLink,
69
- isActiveSidebarItem,
70
- isVisibleSidebarItem,
71
- useVisibleSidebarItems,
72
- useSidebarBreadcrumbs,
73
- useDocsVersionCandidates,
74
- useLayoutDoc,
75
- useLayoutDocsSidebar,
76
- useDocRootMetadata,
77
- } from './utils/docsUtils';
43
+ export {DEFAULT_SEARCH_TAG} from './utils/searchUtils';
78
44
 
79
45
  export {useTitleFormatter} from './utils/generalUtils';
80
46
 
@@ -113,7 +79,6 @@ export {
113
79
  type TOCHighlightConfig,
114
80
  } from './hooks/useTOCHighlight';
115
81
 
116
- export {useVisibleBlogSidebarItems} from './utils/blogUtils';
117
82
  export {useDateTimeFormat} from './utils/IntlUtils';
118
83
 
119
84
  export {useHideableNavbar} from './hooks/useHideableNavbar';
@@ -125,3 +90,10 @@ export {useLockBodyScroll} from './hooks/useLockBodyScroll';
125
90
  export {useCodeWordWrap} from './hooks/useCodeWordWrap';
126
91
  export {getPrismCssVariables} from './utils/codeBlockUtils';
127
92
  export {useBackToTopButton} from './hooks/useBackToTopButton';
93
+
94
+ export {
95
+ useBlogTagsPostsPageTitle,
96
+ useBlogAuthorPageTitle,
97
+ translateBlogAuthorsListPageTitle,
98
+ BlogAuthorsListViewAllLabel,
99
+ } from './translations/blogTranslations';
@@ -0,0 +1,79 @@
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
+
8
+ import React, {type ReactNode} from 'react';
9
+ import Translate, {translate} from '@docusaurus/Translate';
10
+ import {usePluralForm} from '../utils/usePluralForm';
11
+
12
+ // Only used locally
13
+ function useBlogPostsPlural(): (count: number) => string {
14
+ const {selectMessage} = usePluralForm();
15
+ return (count: number) =>
16
+ selectMessage(
17
+ count,
18
+ translate(
19
+ {
20
+ id: 'theme.blog.post.plurals',
21
+ description:
22
+ 'Pluralized label for "{count} posts". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',
23
+ message: 'One post|{count} posts',
24
+ },
25
+ {count},
26
+ ),
27
+ );
28
+ }
29
+
30
+ export function useBlogTagsPostsPageTitle(tag: {
31
+ label: string;
32
+ count: number;
33
+ }): string {
34
+ const blogPostsPlural = useBlogPostsPlural();
35
+ return translate(
36
+ {
37
+ id: 'theme.blog.tagTitle',
38
+ description: 'The title of the page for a blog tag',
39
+ message: '{nPosts} tagged with "{tagName}"',
40
+ },
41
+ {nPosts: blogPostsPlural(tag.count), tagName: tag.label},
42
+ );
43
+ }
44
+
45
+ export function useBlogAuthorPageTitle(author: {
46
+ key: string;
47
+ name?: string;
48
+ count: number;
49
+ }): string {
50
+ const blogPostsPlural = useBlogPostsPlural();
51
+ return translate(
52
+ {
53
+ id: 'theme.blog.author.pageTitle',
54
+ description: 'The title of the page for a blog author',
55
+ message: '{authorName} - {nPosts}',
56
+ },
57
+ {
58
+ nPosts: blogPostsPlural(author.count),
59
+ authorName: author.name || author.key,
60
+ },
61
+ );
62
+ }
63
+
64
+ export const translateBlogAuthorsListPageTitle = (): string =>
65
+ translate({
66
+ id: 'theme.blog.authorsList.pageTitle',
67
+ message: 'Authors',
68
+ description: 'The title of the authors page',
69
+ });
70
+
71
+ export function BlogAuthorsListViewAllLabel(): ReactNode {
72
+ return (
73
+ <Translate
74
+ id="theme.blog.authorsList.viewAll"
75
+ description="The label of the link targeting the blog authors page">
76
+ View All Authors
77
+ </Translate>
78
+ );
79
+ }
@@ -12,7 +12,7 @@ import Head from '@docusaurus/Head';
12
12
  export function UnlistedBannerTitle(): JSX.Element {
13
13
  return (
14
14
  <Translate
15
- id="theme.unlistedContent.title"
15
+ id="theme.contentVisibility.unlistedBanner.title"
16
16
  description="The unlisted content banner title">
17
17
  Unlisted page
18
18
  </Translate>
@@ -22,7 +22,7 @@ export function UnlistedBannerTitle(): JSX.Element {
22
22
  export function UnlistedBannerMessage(): JSX.Element {
23
23
  return (
24
24
  <Translate
25
- id="theme.unlistedContent.message"
25
+ id="theme.contentVisibility.unlistedBanner.message"
26
26
  description="The unlisted content banner message">
27
27
  This page is unlisted. Search engines will not index it, and only users
28
28
  having a direct link can access it.
@@ -30,6 +30,8 @@ export function UnlistedBannerMessage(): JSX.Element {
30
30
  );
31
31
  }
32
32
 
33
+ // TODO Docusaurus v4 breaking change (since it's v3 public theme-common API :/)
34
+ // Move this to theme/ContentVisibility/Unlisted
33
35
  export function UnlistedMetadata(): JSX.Element {
34
36
  return (
35
37
  <Head>
@@ -37,3 +39,24 @@ export function UnlistedMetadata(): JSX.Element {
37
39
  </Head>
38
40
  );
39
41
  }
42
+
43
+ export function DraftBannerTitle(): JSX.Element {
44
+ return (
45
+ <Translate
46
+ id="theme.contentVisibility.draftBanner.title"
47
+ description="The draft content banner title">
48
+ Draft page
49
+ </Translate>
50
+ );
51
+ }
52
+
53
+ export function DraftBannerMessage(): JSX.Element {
54
+ return (
55
+ <Translate
56
+ id="theme.contentVisibility.draftBanner.message"
57
+ description="The draft content banner message">
58
+ This page is a draft. It will only be visible in dev and be excluded from
59
+ the production build.
60
+ </Translate>
61
+ );
62
+ }
package/src/types.d.ts CHANGED
@@ -6,6 +6,3 @@
6
6
  */
7
7
 
8
8
  /// <reference types="@docusaurus/module-type-aliases" />
9
- /// <reference types="@docusaurus/plugin-content-blog" />
10
- /// <reference types="@docusaurus/plugin-content-docs" />
11
- /// <reference types="@docusaurus/plugin-content-pages" />
@@ -18,6 +18,8 @@ export const ThemeClassNames = {
18
18
  blogPostPage: 'blog-post-page',
19
19
  blogTagsListPage: 'blog-tags-list-page',
20
20
  blogTagPostListPage: 'blog-tags-post-list-page',
21
+ blogAuthorsListPage: 'blog-authors-list-page',
22
+ blogAuthorsPostsPage: 'blog-authors-posts-page',
21
23
 
22
24
  docsDocPage: 'docs-doc-page',
23
25
  docsTagsListPage: 'docs-tags-list-page',
@@ -41,6 +43,7 @@ export const ThemeClassNames = {
41
43
  codeBlock: 'theme-code-block',
42
44
  admonition: 'theme-admonition',
43
45
  unlistedBanner: 'theme-unlisted-banner',
46
+ draftBanner: 'theme-draft-banner',
44
47
 
45
48
  admonitionType: (type: string) => `theme-admonition-${type}`,
46
49
  },
@@ -34,3 +34,21 @@ export function uniq<T>(arr: T[]): T[] {
34
34
  // Note: had problems with [...new Set()]: https://github.com/facebook/docusaurus/issues/4972#issuecomment-863895061
35
35
  return Array.from(new Set(arr));
36
36
  }
37
+
38
+ // TODO 2025: replace by std Object.groupBy ?
39
+ // This is a local polyfill with exact same TS signature
40
+ // see https://github.com/microsoft/TypeScript/blob/main/src/lib/esnext.object.d.ts
41
+ export function groupBy<K extends PropertyKey, T>(
42
+ items: Iterable<T>,
43
+ keySelector: (item: T, index: number) => K,
44
+ ): Partial<Record<K, T[]>> {
45
+ const result: Partial<Record<K, T[]>> = {};
46
+ let index = 0;
47
+ for (const item of items) {
48
+ const key = keySelector(item, index);
49
+ result[key] ??= [];
50
+ result[key]!.push(item);
51
+ index += 1;
52
+ }
53
+ return result;
54
+ }
@@ -5,62 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {
9
- useAllDocsData,
10
- useActivePluginAndVersion,
11
- } from '@docusaurus/plugin-content-docs/client';
12
- import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
13
- import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
14
-
15
8
  export const DEFAULT_SEARCH_TAG = 'default';
16
-
17
- /** The search tag to append as each doc's metadata. */
18
- export function docVersionSearchTag(
19
- pluginId: string,
20
- versionName: string,
21
- ): string {
22
- return `docs-${pluginId}-${versionName}`;
23
- }
24
-
25
- /**
26
- * Gets the relevant context information for contextual search.
27
- *
28
- * The value is generic and not coupled to Algolia/DocSearch, since we may want
29
- * to support multiple search engines, or allowing users to use their own search
30
- * engine solution.
31
- */
32
- export function useContextualSearchFilters(): {locale: string; tags: string[]} {
33
- const {i18n} = useDocusaurusContext();
34
- const allDocsData = useAllDocsData();
35
- const activePluginAndVersion = useActivePluginAndVersion();
36
- const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
37
-
38
- // This can't use more specialized hooks because we are mapping over all
39
- // plugin instances.
40
- function getDocPluginTags(pluginId: string) {
41
- const activeVersion =
42
- activePluginAndVersion?.activePlugin.pluginId === pluginId
43
- ? activePluginAndVersion.activeVersion
44
- : undefined;
45
-
46
- const preferredVersion = docsPreferredVersionByPluginId[pluginId];
47
-
48
- const latestVersion = allDocsData[pluginId]!.versions.find(
49
- (v) => v.isLast,
50
- )!;
51
-
52
- const version = activeVersion ?? preferredVersion ?? latestVersion;
53
-
54
- return docVersionSearchTag(pluginId, version.name);
55
- }
56
-
57
- const tags = [
58
- DEFAULT_SEARCH_TAG,
59
- ...Object.keys(allDocsData).map(getDocPluginTags),
60
- ];
61
-
62
- return {
63
- locale: i18n.currentLocale,
64
- tags,
65
- };
66
- }
@@ -109,6 +109,12 @@ export type ThemeConfig = {
109
109
  };
110
110
  };
111
111
 
112
+ blog: {
113
+ sidebar: {
114
+ groupByYear: boolean;
115
+ };
116
+ };
117
+
112
118
  // TODO we should complete this theme config type over time
113
119
  // and share it across all themes
114
120
  // and use it in the Joi validation schema?
@@ -1,33 +0,0 @@
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 { type ReactNode } from 'react';
8
- import type { PropBlogPostContent } from '@docusaurus/plugin-content-blog';
9
- /**
10
- * The React context value returned by the `useBlogPost()` hook.
11
- * It contains useful data related to the currently browsed blog post.
12
- */
13
- export type BlogPostContextValue = Pick<PropBlogPostContent, 'metadata' | 'frontMatter' | 'assets' | 'toc'> & {
14
- readonly isBlogPostPage: boolean;
15
- };
16
- /**
17
- * This is a very thin layer around the `content` received from the MDX loader.
18
- * It provides metadata about the blog post to the children tree.
19
- */
20
- export declare function BlogPostProvider({ children, content, isBlogPostPage, }: {
21
- children: ReactNode;
22
- content: PropBlogPostContent;
23
- isBlogPostPage?: boolean;
24
- }): JSX.Element;
25
- /**
26
- * Returns the data of the currently browsed blog post. Gives access to
27
- * front matter, metadata, TOC, etc.
28
- * When swizzling a low-level component (e.g. the "Edit this page" link)
29
- * and you need some extra metadata, you don't have to drill the props
30
- * all the way through the component tree: simply use this hook instead.
31
- */
32
- export declare function useBlogPost(): BlogPostContextValue;
33
- //# sourceMappingURL=blogPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blogPost.d.ts","sourceRoot":"","sources":["../../src/contexts/blogPost.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAU,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAGjE,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,mBAAmB,EACnB,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,KAAK,CAC9C,GAAG;IACF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC,CAAC;AA4BF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,OAAO,EACP,cAAsB,GACvB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,GAAG,CAAC,OAAO,CAGd;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,oBAAoB,CAMlD"}
@@ -1,46 +0,0 @@
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, { useMemo, useContext } from 'react';
8
- import { ReactContextError } from '../utils/reactUtils';
9
- const Context = React.createContext(null);
10
- /**
11
- * Note: we don't use `PropBlogPostContent` as context value on purpose.
12
- * Metadata is currently stored inside the MDX component, but we may want to
13
- * change that in the future.
14
- */
15
- function useContextValue({ content, isBlogPostPage, }) {
16
- return useMemo(() => ({
17
- metadata: content.metadata,
18
- frontMatter: content.frontMatter,
19
- assets: content.assets,
20
- toc: content.toc,
21
- isBlogPostPage,
22
- }), [content, isBlogPostPage]);
23
- }
24
- /**
25
- * This is a very thin layer around the `content` received from the MDX loader.
26
- * It provides metadata about the blog post to the children tree.
27
- */
28
- export function BlogPostProvider({ children, content, isBlogPostPage = false, }) {
29
- const contextValue = useContextValue({ content, isBlogPostPage });
30
- return <Context.Provider value={contextValue}>{children}</Context.Provider>;
31
- }
32
- /**
33
- * Returns the data of the currently browsed blog post. Gives access to
34
- * front matter, metadata, TOC, etc.
35
- * When swizzling a low-level component (e.g. the "Edit this page" link)
36
- * and you need some extra metadata, you don't have to drill the props
37
- * all the way through the component tree: simply use this hook instead.
38
- */
39
- export function useBlogPost() {
40
- const blogPost = useContext(Context);
41
- if (blogPost === null) {
42
- throw new ReactContextError('BlogPostProvider');
43
- }
44
- return blogPost;
45
- }
46
- //# sourceMappingURL=blogPost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blogPost.js","sourceRoot":"","sources":["../../src/contexts/blogPost.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAkB,UAAU,EAAC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAetD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAA8B,IAAI,CAAC,CAAC;AAEvE;;;;GAIG;AACH,SAAS,eAAe,CAAC,EACvB,OAAO,EACP,cAAc,GAIf;IACC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,cAAc;KACf,CAAC,EACF,CAAC,OAAO,EAAE,cAAc,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,OAAO,EACP,cAAc,GAAG,KAAK,GAKvB;IACC,MAAM,YAAY,GAAG,eAAe,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;IAChE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,30 +0,0 @@
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 { type ReactNode } from 'react';
8
- import type { PropDocContent } from '@docusaurus/plugin-content-docs';
9
- /**
10
- * The React context value returned by the `useDoc()` hook.
11
- * It contains useful data related to the currently browsed doc.
12
- */
13
- export type DocContextValue = Pick<PropDocContent, 'metadata' | 'frontMatter' | 'toc' | 'assets' | 'contentTitle'>;
14
- /**
15
- * This is a very thin layer around the `content` received from the MDX loader.
16
- * It provides metadata about the doc to the children tree.
17
- */
18
- export declare function DocProvider({ children, content, }: {
19
- children: ReactNode;
20
- content: PropDocContent;
21
- }): JSX.Element;
22
- /**
23
- * Returns the data of the currently browsed doc. Gives access to the doc's MDX
24
- * Component, front matter, metadata, TOC, etc. When swizzling a low-level
25
- * component (e.g. the "Edit this page" link) and you need some extra metadata,
26
- * you don't have to drill the props all the way through the component tree:
27
- * simply use this hook instead.
28
- */
29
- export declare function useDoc(): DocContextValue;
30
- //# sourceMappingURL=doc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/contexts/doc.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAU,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,cAAc,EACd,UAAU,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,cAAc,CAC/D,CAAC;AAwBF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,IAAI,eAAe,CAMxC"}
@@ -1,48 +0,0 @@
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, { useMemo, useContext } from 'react';
8
- import { ReactContextError } from '../utils/reactUtils';
9
- const Context = React.createContext(null);
10
- /**
11
- * Note: we don't use `PropDoc` as context value on purpose. Metadata is
12
- * currently stored inside the MDX component, but we may want to change that in
13
- * the future. This layer is a good opportunity to decouple storage from
14
- * consuming API, potentially allowing us to provide metadata as both props and
15
- * route context without duplicating the chunks in the future.
16
- */
17
- function useContextValue(content) {
18
- return useMemo(() => ({
19
- metadata: content.metadata,
20
- frontMatter: content.frontMatter,
21
- assets: content.assets,
22
- contentTitle: content.contentTitle,
23
- toc: content.toc,
24
- }), [content]);
25
- }
26
- /**
27
- * This is a very thin layer around the `content` received from the MDX loader.
28
- * It provides metadata about the doc to the children tree.
29
- */
30
- export function DocProvider({ children, content, }) {
31
- const contextValue = useContextValue(content);
32
- return <Context.Provider value={contextValue}>{children}</Context.Provider>;
33
- }
34
- /**
35
- * Returns the data of the currently browsed doc. Gives access to the doc's MDX
36
- * Component, front matter, metadata, TOC, etc. When swizzling a low-level
37
- * component (e.g. the "Edit this page" link) and you need some extra metadata,
38
- * you don't have to drill the props all the way through the component tree:
39
- * simply use this hook instead.
40
- */
41
- export function useDoc() {
42
- const doc = useContext(Context);
43
- if (doc === null) {
44
- throw new ReactContextError('DocProvider');
45
- }
46
- return doc;
47
- }
48
- //# sourceMappingURL=doc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/contexts/doc.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAkB,UAAU,EAAC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAYtD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAyB,IAAI,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAuB;IAC9C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,EACF,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM;IACpB,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,31 +0,0 @@
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 { type ReactNode } from 'react';
8
- type ContextValue = {
9
- /**
10
- * The item that the user last opened, `null` when there's none open. On
11
- * initial render, it will always be `null`, which doesn't necessarily mean
12
- * there's no category open (can have 0, 1, or many being initially open).
13
- */
14
- expandedItem: number | null;
15
- /**
16
- * Set the currently expanded item, when the user opens one. Set the value to
17
- * `null` when the user closes an open category.
18
- */
19
- setExpandedItem: (a: number | null) => void;
20
- };
21
- /**
22
- * Should be used to wrap one sidebar category level. This provider syncs the
23
- * expanded states of all sibling categories, and categories can choose to
24
- * collapse itself if another one is expanded.
25
- */
26
- export declare function DocSidebarItemsExpandedStateProvider({ children, }: {
27
- children: ReactNode;
28
- }): JSX.Element;
29
- export declare function useDocSidebarItemsExpandedState(): ContextValue;
30
- export {};
31
- //# sourceMappingURL=docSidebarItemsExpandedState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docSidebarItemsExpandedState.d.ts","sourceRoot":"","sources":["../../src/contexts/docSidebarItemsExpandedState.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAC,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AAG3E,KAAK,YAAY,GAAG;IAClB;;;;OAIG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7C,CAAC;AAOF;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,EACnD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAQd;AAED,wBAAgB,+BAA+B,IAAI,YAAY,CAM9D"}