@docusaurus/theme-classic 0.0.0-4679 → 0.0.0-4683

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.
@@ -45,6 +45,10 @@ function getNavbarTranslationFile(navbar) {
45
45
  function translateNavbar(navbar, navbarTranslations) {
46
46
  var _navbarTranslations$t;
47
47
 
48
+ if (!navbarTranslations) {
49
+ return navbar;
50
+ }
51
+
48
52
  return { ...navbar,
49
53
  title: ((_navbarTranslations$t = navbarTranslations.title) === null || _navbarTranslations$t === void 0 ? void 0 : _navbarTranslations$t.message) ?? navbar.title,
50
54
  // TODO handle properly all the navbar item types here!
@@ -93,6 +97,10 @@ function getFooterTranslationFile(footer) {
93
97
  function translateFooter(footer, footerTranslations) {
94
98
  var _footerTranslations$c;
95
99
 
100
+ if (!footerTranslations) {
101
+ return footer;
102
+ }
103
+
96
104
  const links = isMultiColumnFooterLinks(footer.links) ? footer.links.map(link => {
97
105
  var _footerTranslations$;
98
106
 
@@ -137,10 +145,12 @@ function translateThemeConfig({
137
145
  themeConfig,
138
146
  translationFiles
139
147
  }) {
148
+ var _translationFilesMap$, _translationFilesMap$2;
149
+
140
150
  const translationFilesMap = _lodash.default.keyBy(translationFiles, f => f.path);
141
151
 
142
152
  return { ...themeConfig,
143
- navbar: translateNavbar(themeConfig.navbar, translationFilesMap.navbar.content),
144
- footer: themeConfig.footer ? translateFooter(themeConfig.footer, translationFilesMap.footer.content) : undefined
153
+ navbar: translateNavbar(themeConfig.navbar, (_translationFilesMap$ = translationFilesMap.navbar) === null || _translationFilesMap$ === void 0 ? void 0 : _translationFilesMap$.content),
154
+ footer: themeConfig.footer ? translateFooter(themeConfig.footer, (_translationFilesMap$2 = translationFilesMap.footer) === null || _translationFilesMap$2 === void 0 ? void 0 : _translationFilesMap$2.content) : undefined
145
155
  };
146
156
  }
@@ -156,7 +156,7 @@ export default function DocPage(props) {
156
156
  <html className={versionMetadata.className} />
157
157
  </Head>
158
158
  <DocsVersionProvider version={versionMetadata}>
159
- <DocsSidebarProvider sidebar={sidebar}>
159
+ <DocsSidebarProvider sidebar={sidebar ?? null}>
160
160
  <DocPageContent
161
161
  currentDocRoute={currentDocRoute}
162
162
  versionMetadata={versionMetadata}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4679",
3
+ "version": "0.0.0-4683",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,15 +21,15 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4679",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4679",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4679",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4679",
28
- "@docusaurus/theme-common": "0.0.0-4679",
29
- "@docusaurus/theme-translations": "0.0.0-4679",
30
- "@docusaurus/utils": "0.0.0-4679",
31
- "@docusaurus/utils-common": "0.0.0-4679",
32
- "@docusaurus/utils-validation": "0.0.0-4679",
24
+ "@docusaurus/core": "0.0.0-4683",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4683",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4683",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4683",
28
+ "@docusaurus/theme-common": "0.0.0-4683",
29
+ "@docusaurus/theme-translations": "0.0.0-4683",
30
+ "@docusaurus/utils": "0.0.0-4683",
31
+ "@docusaurus/utils-common": "0.0.0-4683",
32
+ "@docusaurus/utils-validation": "0.0.0-4683",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.3.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4679",
46
- "@docusaurus/types": "0.0.0-4679",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4683",
46
+ "@docusaurus/types": "0.0.0-4683",
47
47
  "@types/mdx-js__react": "^1.5.5",
48
48
  "@types/prismjs": "^1.26.0",
49
49
  "@types/rtlcss": "^3.1.2",
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": ">=14"
61
61
  },
62
- "gitHead": "446224a0b9b4f91bb8676d85518b5d7af0221044"
62
+ "gitHead": "57af658e8e5cf53b765ba7267a2b1c062e0bf6a1"
63
63
  }
package/src/index.ts CHANGED
@@ -107,7 +107,7 @@ export default function docusaurusThemeClassic(
107
107
  prism: {additionalLanguages = []} = {},
108
108
  } = themeConfig;
109
109
  const {customCss} = options || {};
110
- const {direction} = localeConfigs[currentLocale];
110
+ const {direction} = localeConfigs[currentLocale]!;
111
111
 
112
112
  return {
113
113
  name: 'docusaurus-theme-classic',
@@ -133,7 +133,7 @@ export default function BackToTopButton(): JSX.Element {
133
133
  ThemeClassNames.common.backToTopButton,
134
134
  styles.backToTopButton,
135
135
  {
136
- [styles.backToTopButtonShow]: show,
136
+ [styles.backToTopButtonShow!]: show,
137
137
  },
138
138
  )}
139
139
  type="button"
@@ -114,7 +114,7 @@ export default function BlogPostItem(props: Props): JSX.Element {
114
114
  {(tagsExists || truncated) && (
115
115
  <footer
116
116
  className={clsx('row docusaurus-mt-lg', {
117
- [styles.blogPostDetailsFull]: isBlogPostPage,
117
+ [styles.blogPostDetailsFull!]: isBlogPostPage,
118
118
  })}>
119
119
  {tagsExists && (
120
120
  <div className={clsx('col', {'col--9': truncatedPost})}>
@@ -128,8 +128,8 @@ export default function CodeBlock({
128
128
  style={style}>
129
129
  <code className={styles.codeBlockLines}>
130
130
  {tokens.map((line, i) => {
131
- if (line.length === 1 && line[0].content === '\n') {
132
- line[0].content = '';
131
+ if (line.length === 1 && line[0]!.content === '\n') {
132
+ line[0]!.content = '';
133
133
  }
134
134
 
135
135
  const lineProps = getLineProps({line, key: i});
@@ -32,9 +32,9 @@ function ColorModeToggle({
32
32
  return (
33
33
  <div
34
34
  className={clsx(styles.toggle, className, {
35
- [styles.toggleChecked]: checked,
36
- [styles.toggleFocused]: focused,
37
- [styles.toggleDisabled]: !isBrowser,
35
+ [styles.toggleChecked!]: checked,
36
+ [styles.toggleFocused!]: focused,
37
+ [styles.toggleDisabled!]: !isBrowser,
38
38
  })}>
39
39
  {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
40
40
  <div
@@ -54,7 +54,7 @@ export default function DocItem(props: Props): JSX.Element {
54
54
  <div className="row">
55
55
  <div
56
56
  className={clsx('col', {
57
- [styles.docItemCol]: !hideTableOfContents,
57
+ [styles.docItemCol!]: !hideTableOfContents,
58
58
  })}>
59
59
  <DocVersionBanner />
60
60
  <div className={styles.docItemContainer}>
@@ -74,12 +74,12 @@ function DocPageContent({
74
74
  ThemeClassNames.docs.docSidebarContainer,
75
75
  styles.docSidebarContainer,
76
76
  {
77
- [styles.docSidebarContainerHidden]: hiddenSidebarContainer,
77
+ [styles.docSidebarContainerHidden!]: hiddenSidebarContainer,
78
78
  },
79
79
  )}
80
80
  onTransitionEnd={(e) => {
81
81
  if (
82
- !e.currentTarget.classList.contains(styles.docSidebarContainer)
82
+ !e.currentTarget.classList.contains(styles.docSidebarContainer!)
83
83
  ) {
84
84
  return;
85
85
  }
@@ -126,7 +126,7 @@ function DocPageContent({
126
126
  )}
127
127
  <main
128
128
  className={clsx(styles.docMainContainer, {
129
- [styles.docMainContainerEnhanced]:
129
+ [styles.docMainContainerEnhanced!]:
130
130
  hiddenSidebarContainer || !sidebar,
131
131
  })}>
132
132
  <div
@@ -134,7 +134,7 @@ function DocPageContent({
134
134
  'container padding-top--md padding-bottom--lg',
135
135
  styles.docItemWrapper,
136
136
  {
137
- [styles.docItemWrapperEnhanced]: hiddenSidebarContainer,
137
+ [styles.docItemWrapperEnhanced!]: hiddenSidebarContainer,
138
138
  },
139
139
  )}>
140
140
  <MDXProvider components={MDXComponents}>{children}</MDXProvider>
@@ -172,7 +172,7 @@ export default function DocPage(props: Props): JSX.Element {
172
172
  <html className={versionMetadata.className} />
173
173
  </Head>
174
174
  <DocsVersionProvider version={versionMetadata}>
175
- <DocsSidebarProvider sidebar={sidebar}>
175
+ <DocsSidebarProvider sidebar={sidebar ?? null}>
176
176
  <DocPageContent
177
177
  currentDocRoute={currentDocRoute}
178
178
  versionMetadata={versionMetadata}
@@ -73,13 +73,13 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
73
73
  return (
74
74
  <div
75
75
  className={clsx(styles.sidebar, {
76
- [styles.sidebarWithHideableNavbar]: hideOnScroll,
77
- [styles.sidebarHidden]: isHidden,
76
+ [styles.sidebarWithHideableNavbar!]: hideOnScroll,
77
+ [styles.sidebarHidden!]: isHidden,
78
78
  })}>
79
79
  {hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
80
80
  <nav
81
81
  className={clsx('menu thin-scrollbar', styles.menu, {
82
- [styles.menuWithAnnouncementBar]: showAnnouncementBar,
82
+ [styles.menuWithAnnouncementBar!]: showAnnouncementBar,
83
83
  })}>
84
84
  <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
85
85
  <DocSidebarItems items={sidebar} activePath={path} level={1} />
@@ -131,7 +131,7 @@ function SimpleLinks({links}: {links: SimpleFooter['links']}) {
131
131
  function isMultiColumnFooterLinks(
132
132
  links: MultiColumnFooter['links'] | SimpleFooter['links'],
133
133
  ): links is MultiColumnFooter['links'] {
134
- return 'title' in links[0];
134
+ return 'title' in links[0]!;
135
135
  }
136
136
 
137
137
  function Footer(): JSX.Element | null {
@@ -26,8 +26,8 @@ function AnchorHeading({as: As, id, ...props}: Props) {
26
26
  <As
27
27
  {...props}
28
28
  className={clsx('anchor', {
29
- [styles.anchorWithHideOnScrollNavbar]: hideOnScroll,
30
- [styles.anchorWithStickyNavbar]: !hideOnScroll,
29
+ [styles.anchorWithHideOnScrollNavbar!]: hideOnScroll,
30
+ [styles.anchorWithStickyNavbar!]: !hideOnScroll,
31
31
  })}
32
32
  id={id}>
33
33
  {props.children}
@@ -92,7 +92,7 @@ export default function LayoutHead(props: Props): JSX.Element {
92
92
  const {title, description, image, keywords, searchMetadata} = props;
93
93
  const faviconUrl = useBaseUrl(favicon);
94
94
  const pageTitle = useTitleFormatter(title);
95
- const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
95
+ const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale]!;
96
96
 
97
97
  return (
98
98
  <>
@@ -241,8 +241,8 @@ export default function Navbar(): JSX.Element {
241
241
  'navbar--dark': style === 'dark',
242
242
  'navbar--primary': style === 'primary',
243
243
  'navbar-sidebar--show': mobileSidebar.shown,
244
- [styles.navbarHideable]: hideOnScroll,
245
- [styles.navbarHidden]: hideOnScroll && !isNavbarVisible,
244
+ [styles.navbarHideable!]: hideOnScroll,
245
+ [styles.navbarHidden!]: hideOnScroll && !isNavbarVisible,
246
246
  })}>
247
247
  <div className="navbar__inner">
248
248
  <div className="navbar__items">
@@ -28,7 +28,7 @@ export default function LocaleDropdownNavbarItem({
28
28
  const alternatePageUtils = useAlternatePageUtils();
29
29
 
30
30
  function getLocaleLabel(locale: string) {
31
- return localeConfigs[locale].label;
31
+ return localeConfigs[locale]!.label;
32
32
  }
33
33
 
34
34
  const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
@@ -28,7 +28,7 @@ export default function TOCCollapsible({
28
28
  className={clsx(
29
29
  styles.tocCollapsible,
30
30
  {
31
- [styles.tocCollapsibleExpanded]: !collapsed,
31
+ [styles.tocCollapsibleExpanded!]: !collapsed,
32
32
  },
33
33
  className,
34
34
  )}>
@@ -108,7 +108,7 @@ function TabsComponent(props: Props): JSX.Element {
108
108
  ) => {
109
109
  const newTab = event.currentTarget;
110
110
  const newTabIndex = tabRefs.indexOf(newTab);
111
- const newTabValue = values[newTabIndex].value;
111
+ const newTabValue = values[newTabIndex]!.value;
112
112
 
113
113
  if (newTabValue !== selectedValue) {
114
114
  blockElementScrollPositionUntilNextRender(newTab);
@@ -126,12 +126,12 @@ function TabsComponent(props: Props): JSX.Element {
126
126
  switch (event.key) {
127
127
  case 'ArrowRight': {
128
128
  const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
129
- focusElement = tabRefs[nextTab] || tabRefs[0];
129
+ focusElement = tabRefs[nextTab] || tabRefs[0]!;
130
130
  break;
131
131
  }
132
132
  case 'ArrowLeft': {
133
133
  const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
134
- focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1];
134
+ focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1]!;
135
135
  break;
136
136
  }
137
137
  default:
@@ -181,7 +181,7 @@ function TabsComponent(props: Props): JSX.Element {
181
181
  cloneElement(
182
182
  children.filter(
183
183
  (tabItem) => tabItem.props.value === selectedValue,
184
- )[0],
184
+ )[0]!,
185
185
  {className: 'margin-vert--md'},
186
186
  )
187
187
  ) : (
@@ -19,8 +19,8 @@ export default function Tag(props: Props): JSX.Element {
19
19
  <Link
20
20
  href={permalink}
21
21
  className={clsx(styles.tag, {
22
- [styles.tagRegular]: !count,
23
- [styles.tagWithCount]: count,
22
+ [styles.tagRegular!]: !count,
23
+ [styles.tagWithCount!]: count,
24
24
  })}>
25
25
  {name}
26
26
  {count && <span>{count}</span>}
@@ -50,8 +50,11 @@ function getNavbarTranslationFile(navbar: Navbar): TranslationFileContent {
50
50
  }
51
51
  function translateNavbar(
52
52
  navbar: Navbar,
53
- navbarTranslations: TranslationFileContent,
53
+ navbarTranslations: TranslationFileContent | undefined,
54
54
  ): Navbar {
55
+ if (!navbarTranslations) {
56
+ return navbar;
57
+ }
55
58
  return {
56
59
  ...navbar,
57
60
  title: navbarTranslations.title?.message ?? navbar.title,
@@ -76,7 +79,7 @@ function translateNavbar(
76
79
  function isMultiColumnFooterLinks(
77
80
  links: MultiColumnFooter['links'] | SimpleFooter['links'],
78
81
  ): links is MultiColumnFooter['links'] {
79
- return links.length > 0 && 'title' in links[0];
82
+ return links.length > 0 && 'title' in links[0]!;
80
83
  }
81
84
 
82
85
  function getFooterTranslationFile(footer: Footer): TranslationFileContent {
@@ -121,8 +124,11 @@ function getFooterTranslationFile(footer: Footer): TranslationFileContent {
121
124
  }
122
125
  function translateFooter(
123
126
  footer: Footer,
124
- footerTranslations: TranslationFileContent,
127
+ footerTranslations: TranslationFileContent | undefined,
125
128
  ): Footer {
129
+ if (!footerTranslations) {
130
+ return footer;
131
+ }
126
132
  const links = isMultiColumnFooterLinks(footer.links)
127
133
  ? footer.links.map((link) => ({
128
134
  ...link,
@@ -187,10 +193,10 @@ export function translateThemeConfig({
187
193
  ...themeConfig,
188
194
  navbar: translateNavbar(
189
195
  themeConfig.navbar,
190
- translationFilesMap.navbar.content,
196
+ translationFilesMap.navbar?.content,
191
197
  ),
192
198
  footer: themeConfig.footer
193
- ? translateFooter(themeConfig.footer, translationFilesMap.footer.content)
199
+ ? translateFooter(themeConfig.footer, translationFilesMap.footer?.content)
194
200
  : undefined,
195
201
  };
196
202
  }