@docusaurus/theme-classic 2.0.0-beta.1ab8aa0af → 2.0.0-beta.2

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 (217) hide show
  1. package/codeTranslations/ar.json +2 -0
  2. package/codeTranslations/base.json +4 -0
  3. package/codeTranslations/bn.json +56 -0
  4. package/codeTranslations/da.json +2 -0
  5. package/codeTranslations/de.json +2 -0
  6. package/codeTranslations/es.json +2 -0
  7. package/codeTranslations/fa.json +2 -0
  8. package/codeTranslations/fil.json +2 -0
  9. package/codeTranslations/fr.json +2 -0
  10. package/codeTranslations/he.json +18 -16
  11. package/codeTranslations/hi.json +2 -0
  12. package/codeTranslations/ja.json +2 -0
  13. package/codeTranslations/ko.json +2 -0
  14. package/codeTranslations/pl.json +2 -0
  15. package/codeTranslations/pt-BR.json +2 -0
  16. package/codeTranslations/pt-PT.json +2 -0
  17. package/codeTranslations/ru.json +2 -0
  18. package/codeTranslations/tr.json +2 -0
  19. package/codeTranslations/vi.json +2 -0
  20. package/codeTranslations/zh-Hans.json +2 -0
  21. package/codeTranslations/zh-Hant.json +2 -0
  22. package/lib/index.js +28 -7
  23. package/lib/theme/AnnouncementBar/index.js +5 -7
  24. package/lib/theme/AnnouncementBar/styles.module.css +6 -6
  25. package/lib/theme/BlogListPage/index.js +2 -2
  26. package/lib/theme/BlogListPaginator/index.js +2 -2
  27. package/lib/theme/BlogPostItem/index.js +32 -23
  28. package/lib/theme/BlogPostItem/styles.module.css +5 -1
  29. package/lib/theme/BlogPostPage/index.js +4 -10
  30. package/lib/theme/BlogPostPaginator/index.js +3 -3
  31. package/lib/theme/BlogSidebar/index.js +11 -3
  32. package/lib/theme/BlogSidebar/styles.module.css +4 -6
  33. package/lib/theme/BlogTagsListPage/index.js +15 -20
  34. package/lib/theme/BlogTagsPostsPage/index.js +29 -33
  35. package/lib/theme/CodeBlock/index.js +11 -11
  36. package/lib/theme/CodeBlock/styles.module.css +4 -7
  37. package/lib/theme/DocItem/index.js +35 -26
  38. package/lib/theme/DocItem/styles.module.css +8 -10
  39. package/lib/theme/DocPage/index.js +43 -11
  40. package/lib/theme/DocPage/styles.module.css +7 -19
  41. package/lib/theme/DocPaginator/index.js +3 -3
  42. package/lib/theme/DocSidebar/index.js +23 -24
  43. package/lib/theme/DocSidebar/styles.module.css +0 -14
  44. package/lib/theme/DocVersionBanner/index.js +128 -0
  45. package/lib/theme/DocVersionSuggestions/index.js +4 -4
  46. package/lib/theme/Heading/index.js +18 -2
  47. package/lib/theme/Heading/styles.module.css +5 -0
  48. package/lib/theme/IconArrow/index.js +1 -1
  49. package/lib/theme/IconEdit/index.js +1 -1
  50. package/lib/theme/IconExternalLink/index.js +30 -0
  51. package/lib/theme/IconExternalLink/styles.module.css +12 -0
  52. package/lib/theme/IconLanguage/index.js +1 -1
  53. package/lib/theme/IconMenu/index.js +1 -2
  54. package/lib/theme/LastUpdated/index.js +17 -21
  55. package/lib/theme/Layout/styles.css +6 -0
  56. package/lib/theme/LayoutHead/index.js +3 -1
  57. package/lib/theme/LayoutProviders/index.js +7 -5
  58. package/lib/theme/Logo/index.js +13 -12
  59. package/lib/theme/MDXComponents/index.js +2 -2
  60. package/lib/theme/MDXPage/index.js +13 -15
  61. package/{src/theme/LastUpdated → lib/theme/MDXPage}/styles.module.css +2 -2
  62. package/lib/theme/Navbar/index.js +4 -4
  63. package/lib/theme/Navbar/styles.module.css +1 -1
  64. package/lib/theme/NavbarItem/DefaultNavbarItem.js +18 -4
  65. package/lib/theme/NavbarItem/DocNavbarItem.js +19 -11
  66. package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -4
  67. package/lib/theme/NavbarItem/SearchNavbarItem.js +1 -5
  68. package/lib/theme/NavbarItem/index.js +1 -1
  69. package/lib/theme/NotFound.js +9 -2
  70. package/lib/theme/SearchMetadatas/index.js +1 -1
  71. package/lib/theme/Seo/index.js +0 -1
  72. package/lib/theme/SkipToContent/index.js +6 -4
  73. package/lib/theme/SkipToContent/styles.module.css +1 -3
  74. package/lib/theme/TOC/styles.module.css +1 -1
  75. package/lib/theme/Tabs/index.js +2 -2
  76. package/lib/theme/ThemedImage/index.js +2 -1
  77. package/lib/theme/ThemedImage/styles.module.css +7 -0
  78. package/lib/theme/Toggle/index.js +12 -24
  79. package/lib/theme/Toggle/styles.css +103 -0
  80. package/lib/theme/Toggle/styles.module.css +0 -97
  81. package/lib/theme/UserPreferencesProvider/index.js +1 -9
  82. package/lib/theme/hooks/useHideableNavbar.js +2 -2
  83. package/lib/theme/hooks/useTabGroupChoice.js +2 -4
  84. package/lib/theme/hooks/useThemeContext.js +1 -1
  85. package/lib/theme/hooks/useUserPreferencesContext.js +1 -1
  86. package/lib/types.d.ts +10 -12
  87. package/lib/validateThemeConfig.js +3 -3
  88. package/lib-next/index.js +31 -8
  89. package/lib-next/theme/AnnouncementBar/index.js +5 -9
  90. package/lib-next/theme/AnnouncementBar/styles.module.css +6 -6
  91. package/lib-next/theme/BlogListPage/index.js +2 -2
  92. package/lib-next/theme/BlogPostItem/index.js +41 -24
  93. package/lib-next/theme/BlogPostItem/styles.module.css +5 -1
  94. package/lib-next/theme/BlogPostPage/index.js +4 -8
  95. package/lib-next/theme/BlogPostPaginator/index.js +1 -1
  96. package/lib-next/theme/BlogSidebar/index.js +12 -3
  97. package/lib-next/theme/BlogSidebar/styles.module.css +4 -6
  98. package/lib-next/theme/BlogTagsListPage/index.js +17 -23
  99. package/lib-next/theme/BlogTagsPostsPage/index.js +36 -40
  100. package/lib-next/theme/CodeBlock/index.js +10 -9
  101. package/lib-next/theme/CodeBlock/styles.module.css +4 -7
  102. package/lib-next/theme/DocItem/index.js +41 -41
  103. package/lib-next/theme/DocItem/styles.module.css +8 -10
  104. package/lib-next/theme/DocPage/index.js +36 -9
  105. package/lib-next/theme/DocPage/styles.module.css +7 -19
  106. package/lib-next/theme/DocPaginator/index.js +1 -1
  107. package/lib-next/theme/DocSidebar/index.js +28 -21
  108. package/lib-next/theme/DocSidebar/styles.module.css +0 -14
  109. package/lib-next/theme/DocVersionBanner/index.js +127 -0
  110. package/lib-next/theme/DocVersionSuggestions/index.js +4 -4
  111. package/lib-next/theme/Heading/index.js +17 -1
  112. package/lib-next/theme/Heading/styles.module.css +5 -0
  113. package/lib-next/theme/IconArrow/index.js +1 -1
  114. package/lib-next/theme/IconEdit/index.js +3 -5
  115. package/lib-next/theme/IconExternalLink/index.js +26 -0
  116. package/{lib/theme/NavbarItem → lib-next/theme/IconExternalLink}/styles.module.css +4 -5
  117. package/lib-next/theme/IconLanguage/index.js +1 -1
  118. package/lib-next/theme/IconMenu/index.js +1 -4
  119. package/lib-next/theme/LastUpdated/index.js +34 -39
  120. package/lib-next/theme/Layout/styles.css +6 -0
  121. package/lib-next/theme/LayoutHead/index.js +5 -1
  122. package/lib-next/theme/LayoutProviders/index.js +11 -6
  123. package/lib-next/theme/Logo/index.js +12 -8
  124. package/lib-next/theme/MDXPage/index.js +13 -17
  125. package/lib-next/theme/{LastUpdated → MDXPage}/styles.module.css +2 -2
  126. package/lib-next/theme/Navbar/index.js +2 -2
  127. package/lib-next/theme/Navbar/styles.module.css +1 -1
  128. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +19 -2
  129. package/lib-next/theme/NavbarItem/DocNavbarItem.js +23 -9
  130. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +6 -6
  131. package/lib-next/theme/NavbarItem/SearchNavbarItem.js +1 -6
  132. package/lib-next/theme/NavbarItem/index.js +1 -1
  133. package/lib-next/theme/NotFound.js +6 -2
  134. package/lib-next/theme/SearchMetadatas/index.js +1 -1
  135. package/lib-next/theme/Seo/index.js +0 -1
  136. package/lib-next/theme/SkipToContent/index.js +3 -3
  137. package/lib-next/theme/SkipToContent/styles.module.css +1 -3
  138. package/lib-next/theme/TOC/styles.module.css +1 -1
  139. package/lib-next/theme/ThemedImage/index.js +2 -3
  140. package/lib-next/theme/ThemedImage/styles.module.css +7 -0
  141. package/lib-next/theme/Toggle/index.js +9 -24
  142. package/lib-next/theme/Toggle/styles.css +103 -0
  143. package/lib-next/theme/Toggle/styles.module.css +0 -97
  144. package/lib-next/theme/UserPreferencesProvider/index.js +0 -4
  145. package/lib-next/theme/hooks/useHideableNavbar.js +3 -3
  146. package/lib-next/theme/hooks/useTabGroupChoice.js +2 -4
  147. package/lib-next/theme/hooks/useThemeContext.js +1 -1
  148. package/lib-next/theme/hooks/useUserPreferencesContext.js +1 -1
  149. package/lib-next/types.d.ts +10 -12
  150. package/lib-next/validateThemeConfig.js +3 -3
  151. package/package.json +18 -17
  152. package/src/index.ts +32 -8
  153. package/src/theme/AnnouncementBar/index.tsx +6 -9
  154. package/src/theme/AnnouncementBar/styles.module.css +6 -6
  155. package/src/theme/BlogListPage/index.tsx +2 -2
  156. package/src/theme/BlogPostItem/index.tsx +40 -24
  157. package/src/theme/BlogPostItem/styles.module.css +5 -1
  158. package/src/theme/BlogPostPage/index.tsx +4 -8
  159. package/src/theme/BlogPostPaginator/index.tsx +1 -1
  160. package/src/theme/BlogSidebar/index.tsx +12 -3
  161. package/src/theme/BlogSidebar/styles.module.css +4 -6
  162. package/src/theme/BlogTagsListPage/index.tsx +17 -22
  163. package/src/theme/BlogTagsPostsPage/index.tsx +33 -43
  164. package/src/theme/CodeBlock/index.tsx +10 -9
  165. package/src/theme/CodeBlock/styles.module.css +4 -7
  166. package/src/theme/DocItem/index.tsx +40 -40
  167. package/src/theme/DocItem/styles.module.css +8 -10
  168. package/src/theme/DocPage/index.tsx +29 -9
  169. package/src/theme/DocPage/styles.module.css +7 -19
  170. package/src/theme/DocPaginator/index.tsx +1 -1
  171. package/src/theme/DocSidebar/index.tsx +28 -21
  172. package/src/theme/DocSidebar/styles.module.css +0 -14
  173. package/src/theme/{DocVersionSuggestions → DocVersionBanner}/index.tsx +46 -43
  174. package/src/theme/Heading/index.tsx +22 -1
  175. package/src/theme/Heading/styles.module.css +5 -0
  176. package/src/theme/IconArrow/index.tsx +1 -1
  177. package/src/theme/IconEdit/index.tsx +3 -5
  178. package/src/theme/IconExternalLink/index.tsx +32 -0
  179. package/src/theme/IconExternalLink/styles.module.css +12 -0
  180. package/src/theme/IconLanguage/index.tsx +1 -1
  181. package/src/theme/IconMenu/index.tsx +1 -4
  182. package/src/theme/LastUpdated/index.tsx +34 -39
  183. package/src/theme/Layout/styles.css +6 -0
  184. package/src/theme/LayoutHead/index.tsx +5 -1
  185. package/src/theme/LayoutProviders/index.tsx +11 -6
  186. package/src/theme/Logo/index.tsx +10 -6
  187. package/src/theme/MDXPage/index.tsx +14 -17
  188. package/{lib/theme/LastUpdated → src/theme/MDXPage}/styles.module.css +2 -2
  189. package/src/theme/Navbar/index.tsx +2 -2
  190. package/src/theme/Navbar/styles.module.css +1 -1
  191. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +15 -2
  192. package/src/theme/NavbarItem/DocNavbarItem.tsx +29 -10
  193. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +7 -6
  194. package/src/theme/NavbarItem/SearchNavbarItem.tsx +1 -6
  195. package/src/theme/NavbarItem/index.tsx +1 -1
  196. package/src/theme/NotFound.tsx +6 -2
  197. package/src/theme/SearchMetadatas/index.tsx +1 -1
  198. package/src/theme/Seo/index.tsx +0 -1
  199. package/src/theme/SkipToContent/index.tsx +3 -3
  200. package/src/theme/SkipToContent/styles.module.css +1 -3
  201. package/src/theme/TOC/styles.module.css +1 -1
  202. package/src/theme/ThemedImage/index.tsx +3 -3
  203. package/src/theme/ThemedImage/styles.module.css +7 -0
  204. package/src/theme/Toggle/index.tsx +9 -22
  205. package/src/theme/Toggle/styles.css +103 -0
  206. package/src/theme/Toggle/styles.module.css +0 -97
  207. package/src/theme/UserPreferencesProvider/index.tsx +0 -5
  208. package/src/theme/hooks/useHideableNavbar.ts +3 -3
  209. package/src/theme/hooks/useTabGroupChoice.ts +2 -2
  210. package/src/theme/hooks/useThemeContext.ts +1 -1
  211. package/src/theme/hooks/useUserPreferencesContext.ts +1 -1
  212. package/src/types.d.ts +10 -12
  213. package/src/validateThemeConfig.js +3 -3
  214. package/update-code-translations.js +1 -0
  215. package/lib-next/theme/NavbarItem/styles.module.css +0 -13
  216. package/src/theme/NavbarItem/styles.module.css +0 -13
  217. package/src/theme/hooks/useAnnouncementBar.ts +0 -58
@@ -10,14 +10,14 @@ import clsx from 'clsx';
10
10
  import {MDXProvider} from '@mdx-js/react';
11
11
  import Translate, {translate} from '@docusaurus/Translate';
12
12
  import Link from '@docusaurus/Link';
13
+ import {usePluralForm} from '@docusaurus/theme-common';
13
14
  import MDXComponents from '@theme/MDXComponents';
14
15
  import Seo from '@theme/Seo';
16
+ import EditThisPage from '@theme/EditThisPage';
15
17
  import type {Props} from '@theme/BlogPostItem';
16
18
 
17
19
  import styles from './styles.module.css';
18
20
 
19
- import {usePluralForm} from '@docusaurus/theme-common';
20
-
21
21
  // Very simple pluralization: probably good enough for now
22
22
  function useReadingTimePlural() {
23
23
  const {selectMessage} = usePluralForm();
@@ -47,8 +47,16 @@ function BlogPostItem(props: Props): JSX.Element {
47
47
  truncated,
48
48
  isBlogPostPage = false,
49
49
  } = props;
50
- const {date, formattedDate, permalink, tags, readingTime} = metadata;
51
- const {author, title, image, keywords} = frontMatter;
50
+ const {
51
+ date,
52
+ formattedDate,
53
+ permalink,
54
+ tags,
55
+ readingTime,
56
+ title,
57
+ editUrl,
58
+ } = metadata;
59
+ const {author, image, keywords} = frontMatter;
52
60
 
53
61
  const authorURL = frontMatter.author_url || frontMatter.authorURL;
54
62
  const authorTitle = frontMatter.author_title || frontMatter.authorTitle;
@@ -60,20 +68,18 @@ function BlogPostItem(props: Props): JSX.Element {
60
68
 
61
69
  return (
62
70
  <header>
63
- <TitleHeading
64
- className={clsx('margin-bottom--sm', styles.blogPostTitle)}>
71
+ <TitleHeading className={styles.blogPostTitle}>
65
72
  {isBlogPostPage ? title : <Link to={permalink}>{title}</Link>}
66
73
  </TitleHeading>
67
- <div className="margin-vert--md">
68
- <time dateTime={date} className={styles.blogPostDate}>
69
- {formattedDate}
70
- {readingTime && (
71
- <>
72
- {' · '}
73
- {readingTimePlural(readingTime)}
74
- </>
75
- )}
76
- </time>
74
+ <div className={clsx(styles.blogPostData, 'margin-vert--md')}>
75
+ <time dateTime={date}>{formattedDate}</time>
76
+
77
+ {readingTime && (
78
+ <>
79
+ {' · '}
80
+ {readingTimePlural(readingTime)}
81
+ </>
82
+ )}
77
83
  </div>
78
84
  <div className="avatar margin-vert--md">
79
85
  {authorImageURL && (
@@ -84,9 +90,9 @@ function BlogPostItem(props: Props): JSX.Element {
84
90
  <div className="avatar__intro">
85
91
  {author && (
86
92
  <>
87
- <h4 className="avatar__name">
93
+ <div className="avatar__name">
88
94
  <Link href={authorURL}>{author}</Link>
89
- </h4>
95
+ </div>
90
96
  <small className="avatar__subtitle">{authorTitle}</small>
91
97
  </>
92
98
  )}
@@ -106,16 +112,19 @@ function BlogPostItem(props: Props): JSX.Element {
106
112
  <MDXProvider components={MDXComponents}>{children}</MDXProvider>
107
113
  </div>
108
114
  {(tags.length > 0 || truncated) && (
109
- <footer className="row margin-vert--lg">
115
+ <footer
116
+ className={clsx('row docusaurus-mt-lg', {
117
+ [styles.blogPostDetailsFull]: isBlogPostPage,
118
+ })}>
110
119
  {tags.length > 0 && (
111
120
  <div className="col">
112
- <strong>
121
+ <b>
113
122
  <Translate
114
123
  id="theme.tags.tagsListLabel"
115
124
  description="The label alongside a tag list">
116
125
  Tags:
117
126
  </Translate>
118
- </strong>
127
+ </b>
119
128
  {tags.map(({label, permalink: tagPermalink}) => (
120
129
  <Link
121
130
  key={tagPermalink}
@@ -126,18 +135,25 @@ function BlogPostItem(props: Props): JSX.Element {
126
135
  ))}
127
136
  </div>
128
137
  )}
129
- {truncated && (
138
+
139
+ {isBlogPostPage && editUrl && (
140
+ <div className="col margin-top--sm">
141
+ <EditThisPage editUrl={editUrl} />
142
+ </div>
143
+ )}
144
+
145
+ {!isBlogPostPage && truncated && (
130
146
  <div className="col text--right">
131
147
  <Link
132
148
  to={metadata.permalink}
133
149
  aria-label={`Read more about ${title}`}>
134
- <strong>
150
+ <b>
135
151
  <Translate
136
152
  id="theme.blog.post.readMore"
137
153
  description="The label used in blog post item excerpts to link to full blog posts">
138
154
  Read More
139
155
  </Translate>
140
- </strong>
156
+ </b>
141
157
  </Link>
142
158
  </div>
143
159
  )}
@@ -9,6 +9,10 @@
9
9
  font-size: 3rem;
10
10
  }
11
11
 
12
- .blogPostDate {
12
+ .blogPostData {
13
13
  font-size: 0.9rem;
14
14
  }
15
+
16
+ .blogPostDetailsFull {
17
+ flex-direction: column;
18
+ }
@@ -12,13 +12,12 @@ import BlogPostPaginator from '@theme/BlogPostPaginator';
12
12
  import type {Props} from '@theme/BlogPostPage';
13
13
  import BlogSidebar from '@theme/BlogSidebar';
14
14
  import TOC from '@theme/TOC';
15
- import EditThisPage from '@theme/EditThisPage';
16
15
  import {ThemeClassNames} from '@docusaurus/theme-common';
17
16
 
18
17
  function BlogPostPage(props: Props): JSX.Element {
19
18
  const {content: BlogPostContents, sidebar} = props;
20
19
  const {frontMatter, metadata} = BlogPostContents;
21
- const {title, description, nextItem, prevItem, editUrl} = metadata;
20
+ const {title, description, nextItem, prevItem} = metadata;
22
21
  const {hide_table_of_contents: hideTableOfContents} = frontMatter;
23
22
 
24
23
  return (
@@ -30,9 +29,9 @@ function BlogPostPage(props: Props): JSX.Element {
30
29
  {BlogPostContents && (
31
30
  <div className="container margin-vert--lg">
32
31
  <div className="row">
33
- <div className="col col--3">
32
+ <aside className="col col--3">
34
33
  <BlogSidebar sidebar={sidebar} />
35
- </div>
34
+ </aside>
36
35
  <main className="col col--7">
37
36
  <BlogPostItem
38
37
  frontMatter={frontMatter}
@@ -40,11 +39,8 @@ function BlogPostPage(props: Props): JSX.Element {
40
39
  isBlogPostPage>
41
40
  <BlogPostContents />
42
41
  </BlogPostItem>
43
- <div>{editUrl && <EditThisPage editUrl={editUrl} />}</div>
44
42
  {(nextItem || prevItem) && (
45
- <div className="margin-vert--xl">
46
- <BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
47
- </div>
43
+ <BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
48
44
  )}
49
45
  </main>
50
46
  {!hideTableOfContents && BlogPostContents.toc && (
@@ -15,7 +15,7 @@ function BlogPostPaginator(props: Props): JSX.Element {
15
15
 
16
16
  return (
17
17
  <nav
18
- className="pagination-nav"
18
+ className="pagination-nav docusaurus-mt-lg"
19
19
  aria-label={translate({
20
20
  id: 'theme.blog.post.paginator.navAriaLabel',
21
21
  message: 'Blog post page navigation',
@@ -10,14 +10,23 @@ import clsx from 'clsx';
10
10
  import Link from '@docusaurus/Link';
11
11
  import type {Props} from '@theme/BlogSidebar';
12
12
  import styles from './styles.module.css';
13
+ import {translate} from '@docusaurus/Translate';
13
14
 
14
15
  export default function BlogSidebar({sidebar}: Props): JSX.Element | null {
15
16
  if (sidebar.items.length === 0) {
16
17
  return null;
17
18
  }
18
19
  return (
19
- <div className={clsx(styles.sidebar, 'thin-scrollbar')}>
20
- <h3 className={styles.sidebarItemTitle}>{sidebar.title}</h3>
20
+ <nav
21
+ className={clsx(styles.sidebar, 'thin-scrollbar')}
22
+ aria-label={translate({
23
+ id: 'theme.blog.sidebar.navAriaLabel',
24
+ message: 'Blog recent posts navigation',
25
+ description: 'The ARIA label for recent posts in the blog sidebar',
26
+ })}>
27
+ <div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
28
+ {sidebar.title}
29
+ </div>
21
30
  <ul className={styles.sidebarItemList}>
22
31
  {sidebar.items.map((item) => {
23
32
  return (
@@ -33,6 +42,6 @@ export default function BlogSidebar({sidebar}: Props): JSX.Element | null {
33
42
  );
34
43
  })}
35
44
  </ul>
36
- </div>
45
+ </nav>
37
46
  );
38
47
  }
@@ -6,7 +6,6 @@
6
6
  */
7
7
 
8
8
  .sidebar {
9
- display: inherit;
10
9
  max-height: calc(100vh - (var(--ifm-navbar-height) + 2rem));
11
10
  overflow-y: auto;
12
11
  position: sticky;
@@ -14,25 +13,24 @@
14
13
  }
15
14
 
16
15
  .sidebarItemTitle {
17
- margin-bottom: 0.5rem;
16
+ font-size: var(--ifm-h3-font-size);
17
+ font-weight: var(--ifm-font-weight-bold);
18
18
  }
19
19
 
20
20
  .sidebarItemList {
21
- overflow-y: auto;
21
+ list-style: none;
22
22
  font-size: 0.9rem;
23
23
  padding-left: 0;
24
24
  }
25
25
 
26
26
  .sidebarItem {
27
- list-style-type: none;
28
- margin: 0.8rem 0;
27
+ margin-top: 0.7rem;
29
28
  }
30
29
 
31
30
  .sidebarItemLink {
32
31
  color: var(--ifm-font-color-base);
33
32
  }
34
33
  .sidebarItemLink:hover {
35
- color: var(--ifm-color-primary);
36
34
  text-decoration: none;
37
35
  }
38
36
  .sidebarItemLinkActive {
@@ -11,7 +11,7 @@ import Layout from '@theme/Layout';
11
11
  import Link from '@docusaurus/Link';
12
12
  import type {Props} from '@theme/BlogTagsListPage';
13
13
  import BlogSidebar from '@theme/BlogSidebar';
14
- import Translate from '@docusaurus/Translate';
14
+ import {translate} from '@docusaurus/Translate';
15
15
  import {ThemeClassNames} from '@docusaurus/theme-common';
16
16
 
17
17
  function getCategoryOfTag(tag: string) {
@@ -21,6 +21,11 @@ function getCategoryOfTag(tag: string) {
21
21
 
22
22
  function BlogTagsListPage(props: Props): JSX.Element {
23
23
  const {tags, sidebar} = props;
24
+ const title = translate({
25
+ id: 'theme.tags.tagsPageTitle',
26
+ message: 'Tags',
27
+ description: 'The title of the tag list page',
28
+ });
24
29
 
25
30
  const tagCategories: {[category: string]: string[]} = {};
26
31
  Object.keys(tags).forEach((tag) => {
@@ -28,16 +33,13 @@ function BlogTagsListPage(props: Props): JSX.Element {
28
33
  tagCategories[category] = tagCategories[category] || [];
29
34
  tagCategories[category].push(tag);
30
35
  });
31
- const tagsList = Object.entries(tagCategories).sort(([a], [b]) => {
32
- if (a === b) {
33
- return 0;
34
- }
35
- return a > b ? 1 : -1;
36
- });
36
+ const tagsList = Object.entries(tagCategories).sort(([a], [b]) =>
37
+ a.localeCompare(b),
38
+ );
37
39
  const tagsSection = tagsList
38
40
  .map(([category, tagsForCategory]) => (
39
- <div key={category}>
40
- <h3>{category}</h3>
41
+ <article key={category}>
42
+ <h2>{category}</h2>
41
43
  {tagsForCategory.map((tag) => (
42
44
  <Link
43
45
  className="padding-right--md"
@@ -47,14 +49,13 @@ function BlogTagsListPage(props: Props): JSX.Element {
47
49
  </Link>
48
50
  ))}
49
51
  <hr />
50
- </div>
52
+ </article>
51
53
  ))
52
54
  .filter((item) => item != null);
53
55
 
54
56
  return (
55
57
  <Layout
56
- title="Tags"
57
- description="Blog Tags"
58
+ title={title}
58
59
  wrapperClassName={ThemeClassNames.wrapper.blogPages}
59
60
  pageClassName={ThemeClassNames.page.blogTagsListPage}
60
61
  searchMetadatas={{
@@ -63,18 +64,12 @@ function BlogTagsListPage(props: Props): JSX.Element {
63
64
  }}>
64
65
  <div className="container margin-vert--lg">
65
66
  <div className="row">
66
- <div className="col col--3">
67
+ <aside className="col col--3">
67
68
  <BlogSidebar sidebar={sidebar} />
68
- </div>
69
+ </aside>
69
70
  <main className="col col--7">
70
- <h1>
71
- <Translate
72
- id="theme.tags.tagsPageTitle"
73
- description="The title of the tag list page">
74
- Tags
75
- </Translate>
76
- </h1>
77
- <div className="margin-vert--lg">{tagsSection}</div>
71
+ <h1>{title}</h1>
72
+ <section className="margin-vert--lg">{tagsSection}</section>
78
73
  </main>
79
74
  </div>
80
75
  </div>
@@ -33,32 +33,22 @@ function useBlogPostsPlural() {
33
33
  );
34
34
  }
35
35
 
36
- function BlogTagsPostPageTitle({
37
- tagName,
38
- count,
39
- }: {
40
- tagName: string;
41
- count: number;
42
- }) {
43
- const blogPostsPlural = useBlogPostsPlural();
44
- return (
45
- <Translate
46
- id="theme.blog.tagTitle"
47
- description="The title of the page for a blog tag"
48
- values={{nPosts: blogPostsPlural(count), tagName}}>
49
- {'{nPosts} tagged with "{tagName}"'}
50
- </Translate>
51
- );
52
- }
53
-
54
36
  function BlogTagsPostPage(props: Props): JSX.Element {
55
37
  const {metadata, items, sidebar} = props;
56
38
  const {allTagsPath, name: tagName, count} = metadata;
39
+ const blogPostsPlural = useBlogPostsPlural();
40
+ const title = translate(
41
+ {
42
+ id: 'theme.blog.tagTitle',
43
+ description: 'The title of the page for a blog tag',
44
+ message: '{nPosts} tagged with "{tagName}"',
45
+ },
46
+ {nPosts: blogPostsPlural(count), tagName},
47
+ );
57
48
 
58
49
  return (
59
50
  <Layout
60
- title={`Posts tagged "${tagName}"`}
61
- description={`Blog | Tagged "${tagName}"`}
51
+ title={title}
62
52
  wrapperClassName={ThemeClassNames.wrapper.blogPages}
63
53
  pageClassName={ThemeClassNames.page.blogTagsPostPage}
64
54
  searchMetadatas={{
@@ -67,31 +57,31 @@ function BlogTagsPostPage(props: Props): JSX.Element {
67
57
  }}>
68
58
  <div className="container margin-vert--lg">
69
59
  <div className="row">
70
- <div className="col col--3">
60
+ <aside className="col col--3">
71
61
  <BlogSidebar sidebar={sidebar} />
72
- </div>
62
+ </aside>
73
63
  <main className="col col--7">
74
- <h1>
75
- <BlogTagsPostPageTitle count={count} tagName={tagName} />
76
- </h1>
77
- <Link href={allTagsPath}>
78
- <Translate
79
- id="theme.tags.tagsPageLink"
80
- description="The label of the link targeting the tag list page">
81
- View All Tags
82
- </Translate>
83
- </Link>
84
- <div className="margin-vert--xl">
85
- {items.map(({content: BlogPostContent}) => (
86
- <BlogPostItem
87
- key={BlogPostContent.metadata.permalink}
88
- frontMatter={BlogPostContent.frontMatter}
89
- metadata={BlogPostContent.metadata}
90
- truncated>
91
- <BlogPostContent />
92
- </BlogPostItem>
93
- ))}
94
- </div>
64
+ <header className="margin-bottom--xl">
65
+ <h1>{title}</h1>
66
+
67
+ <Link href={allTagsPath}>
68
+ <Translate
69
+ id="theme.tags.tagsPageLink"
70
+ description="The label of the link targeting the tag list page">
71
+ View All Tags
72
+ </Translate>
73
+ </Link>
74
+ </header>
75
+
76
+ {items.map(({content: BlogPostContent}) => (
77
+ <BlogPostItem
78
+ key={BlogPostContent.metadata.permalink}
79
+ frontMatter={BlogPostContent.frontMatter}
80
+ metadata={BlogPostContent.metadata}
81
+ truncated>
82
+ <BlogPostContent />
83
+ </BlogPostItem>
84
+ ))}
95
85
  </main>
96
86
  </div>
97
87
  </div>
@@ -207,13 +207,14 @@ export default function CodeBlock({
207
207
  </div>
208
208
  )}
209
209
  <div className={clsx(styles.codeBlockContent, language)}>
210
- <div
210
+ <pre
211
211
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
212
212
  tabIndex={0}
213
213
  className={clsx(className, styles.codeBlock, 'thin-scrollbar', {
214
214
  [styles.codeBlockWithTitle]: codeBlockTitle,
215
- })}>
216
- <div className={styles.codeBlockLines} style={style}>
215
+ })}
216
+ style={style}>
217
+ <code className={styles.codeBlockLines}>
217
218
  {tokens.map((line, i) => {
218
219
  if (line.length === 1 && line[0].content === '') {
219
220
  line[0].content = '\n'; // eslint-disable-line no-param-reassign
@@ -222,19 +223,19 @@ export default function CodeBlock({
222
223
  const lineProps = getLineProps({line, key: i});
223
224
 
224
225
  if (highlightLines.includes(i + 1)) {
225
- lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`;
226
+ lineProps.className += ' docusaurus-highlight-code-line';
226
227
  }
227
228
 
228
229
  return (
229
- <div key={i} {...lineProps}>
230
+ <span key={i} {...lineProps}>
230
231
  {line.map((token, key) => (
231
232
  <span key={key} {...getTokenProps({token, key})} />
232
233
  ))}
233
- </div>
234
+ </span>
234
235
  );
235
236
  })}
236
- </div>
237
- </div>
237
+ </code>
238
+ </pre>
238
239
 
239
240
  <button
240
241
  ref={button}
@@ -244,7 +245,7 @@ export default function CodeBlock({
244
245
  message: 'Copy code to clipboard',
245
246
  description: 'The ARIA label for copy code blocks button',
246
247
  })}
247
- className={clsx(styles.copyButton)}
248
+ className={clsx(styles.copyButton, 'clean-btn')}
248
249
  onClick={handleCopyCode}>
249
250
  {showCopied ? (
250
251
  <Translate
@@ -25,8 +25,7 @@
25
25
  }
26
26
 
27
27
  .codeBlock {
28
- overflow: auto;
29
- border-radius: var(--ifm-global-radius);
28
+ padding: 0;
30
29
  }
31
30
 
32
31
  .codeBlockWithTitle {
@@ -36,10 +35,8 @@
36
35
 
37
36
  .copyButton {
38
37
  background: rgba(0, 0, 0, 0.3);
39
- border: none;
40
38
  border-radius: var(--ifm-global-radius);
41
39
  color: var(--ifm-color-white);
42
- cursor: pointer;
43
40
  opacity: 0;
44
41
  user-select: none;
45
42
  padding: 0.4rem 0.5rem;
@@ -56,12 +53,12 @@
56
53
  }
57
54
 
58
55
  .codeBlockLines {
59
- font: var(--ifm-code-font-size) / var(--ifm-pre-line-height)
60
- var(--ifm-font-family-monospace);
61
- white-space: pre;
56
+ font: inherit;
62
57
  float: left;
63
58
  min-width: 100%;
64
59
  padding: var(--ifm-pre-padding);
60
+ display: flex;
61
+ flex-direction: column;
65
62
  }
66
63
 
67
64
  @media print {
@@ -7,23 +7,20 @@
7
7
 
8
8
  import React from 'react';
9
9
  import DocPaginator from '@theme/DocPaginator';
10
- import DocVersionSuggestions from '@theme/DocVersionSuggestions';
10
+ import DocVersionBanner from '@theme/DocVersionBanner';
11
11
  import Seo from '@theme/Seo';
12
12
  import LastUpdated from '@theme/LastUpdated';
13
13
  import type {Props} from '@theme/DocItem';
14
14
  import TOC from '@theme/TOC';
15
15
  import EditThisPage from '@theme/EditThisPage';
16
+ import {MainHeading} from '@theme/Heading';
16
17
 
17
18
  import clsx from 'clsx';
18
19
  import styles from './styles.module.css';
19
- import {
20
- useActivePlugin,
21
- useVersions,
22
- useActiveVersion,
23
- } from '@theme/hooks/useDocs';
20
+ import {useActivePlugin, useVersions} from '@theme/hooks/useDocs';
24
21
 
25
22
  function DocItem(props: Props): JSX.Element {
26
- const {content: DocContent} = props;
23
+ const {content: DocContent, versionMetadata} = props;
27
24
  const {metadata, frontMatter} = DocContent;
28
25
  const {
29
26
  image,
@@ -42,64 +39,67 @@ function DocItem(props: Props): JSX.Element {
42
39
 
43
40
  const {pluginId} = useActivePlugin({failfast: true});
44
41
  const versions = useVersions(pluginId);
45
- const version = useActiveVersion(pluginId);
46
42
 
47
43
  // If site is not versioned or only one version is included
48
44
  // we don't show the version badge
49
45
  // See https://github.com/facebook/docusaurus/issues/3362
50
46
  const showVersionBadge = versions.length > 1;
51
47
 
52
- // For meta title, using frontMatter.title in priority over a potential # title found in markdown
53
- // See https://github.com/facebook/docusaurus/issues/4665#issuecomment-825831367
54
- const metaTitle = frontMatter.title || title;
48
+ // We only add a title if:
49
+ // - user asks to hide it with frontmatter
50
+ // - the markdown content does not already contain a top-level h1 heading
51
+ const shouldAddTitle =
52
+ !hideTitle && typeof DocContent.contentTitle === 'undefined';
55
53
 
56
54
  return (
57
55
  <>
58
- <Seo {...{title: metaTitle, description, keywords, image}} />
56
+ <Seo {...{title, description, keywords, image}} />
59
57
 
60
58
  <div className="row">
61
59
  <div
62
60
  className={clsx('col', {
63
61
  [styles.docItemCol]: !hideTableOfContents,
64
62
  })}>
65
- <DocVersionSuggestions />
63
+ <DocVersionBanner versionMetadata={versionMetadata} />
66
64
  <div className={styles.docItemContainer}>
67
65
  <article>
68
66
  {showVersionBadge && (
69
- <div>
70
- <span className="badge badge--secondary">
71
- Version: {version.label}
72
- </span>
73
- </div>
74
- )}
75
- {!hideTitle && (
76
- <header>
77
- <h1 className={styles.docTitle}>{title}</h1>
78
- </header>
67
+ <span className="badge badge--secondary">
68
+ Version: {versionMetadata.label}
69
+ </span>
79
70
  )}
71
+
80
72
  <div className="markdown">
73
+ {/*
74
+ Title can be declared inside md content or declared through frontmatter and added manually
75
+ To make both cases consistent, the added title is added under the same div.markdown block
76
+ See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
77
+ */}
78
+ {shouldAddTitle && <MainHeading>{title}</MainHeading>}
79
+
81
80
  <DocContent />
82
81
  </div>
83
- </article>
84
- {(editUrl || lastUpdatedAt || lastUpdatedBy) && (
85
- <div className="margin-vert--xl">
86
- <div className="row">
82
+
83
+ {(editUrl || lastUpdatedAt || lastUpdatedBy) && (
84
+ <footer className="row docusaurus-mt-lg">
87
85
  <div className="col">
88
86
  {editUrl && <EditThisPage editUrl={editUrl} />}
89
87
  </div>
90
- {(lastUpdatedAt || lastUpdatedBy) && (
91
- <LastUpdated
92
- lastUpdatedAt={lastUpdatedAt}
93
- formattedLastUpdatedAt={formattedLastUpdatedAt}
94
- lastUpdatedBy={lastUpdatedBy}
95
- />
96
- )}
97
- </div>
98
- </div>
99
- )}
100
- <div className="margin-vert--lg">
101
- <DocPaginator metadata={metadata} />
102
- </div>
88
+
89
+ <div className={clsx('col', styles.lastUpdated)}>
90
+ {(lastUpdatedAt || lastUpdatedBy) && (
91
+ <LastUpdated
92
+ lastUpdatedAt={lastUpdatedAt}
93
+ formattedLastUpdatedAt={formattedLastUpdatedAt}
94
+ lastUpdatedBy={lastUpdatedBy}
95
+ />
96
+ )}
97
+ </div>
98
+ </footer>
99
+ )}
100
+ </article>
101
+
102
+ <DocPaginator metadata={metadata} />
103
103
  </div>
104
104
  </div>
105
105
  {!hideTableOfContents && DocContent.toc && (