@docusaurus/theme-classic 0.0.0-4435 → 0.0.0-4440

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.
package/lib/index.js CHANGED
@@ -101,8 +101,7 @@ function getInfimaCSSFile(direction) {
101
101
  return `infima/dist/css/default/default${direction === 'rtl' ? '-rtl' : ''}.css`;
102
102
  }
103
103
 
104
- function docusaurusThemeClassic(context, // TODO: LoadContext is missing some of properties
105
- options) {
104
+ function docusaurusThemeClassic(context, options) {
106
105
  const {
107
106
  siteConfig: {
108
107
  themeConfig: roughlyTypedThemeConfig
@@ -37,9 +37,9 @@ export default function CodeBlock({
37
37
 
38
38
  useEffect(() => {
39
39
  setMounted(true);
40
- }, []); // TODO: the title is provided by MDX as props automatically
41
- // so we probably don't need to parse the metastring
42
- // (note: title="xyz" => title prop still has the quotes)
40
+ }, []); // We still parse the metastring in case we want to support more syntax in the
41
+ // future. Note that MDX doesn't strip quotes when parsing metastring:
42
+ // "title=\"xyz\"" => title: "\"xyz\""
43
43
 
44
44
  const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
45
45
  const prismTheme = usePrismTheme(); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
@@ -22,14 +22,14 @@ import {useLocation} from '@docusaurus/router'; // Useful for SEO
22
22
 
23
23
  function AlternateLangHeaders() {
24
24
  const {
25
- i18n: {defaultLocale, locales},
25
+ i18n: {defaultLocale, localeConfigs},
26
26
  } = useDocusaurusContext();
27
27
  const alternatePageUtils = useAlternatePageUtils(); // Note: it is fine to use both "x-default" and "en" to target the same url
28
28
  // See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
29
29
 
30
30
  return (
31
31
  <Head>
32
- {locales.map((locale) => (
32
+ {Object.entries(localeConfigs).map(([locale, {htmlLang}]) => (
33
33
  <link
34
34
  key={locale}
35
35
  rel="alternate"
@@ -37,7 +37,7 @@ function AlternateLangHeaders() {
37
37
  locale,
38
38
  fullyQualified: true,
39
39
  })}
40
- hrefLang={locale}
40
+ hrefLang={htmlLang}
41
41
  />
42
42
  ))}
43
43
  <link
@@ -84,12 +84,8 @@ export default function LayoutHead(props) {
84
84
  const {metadata, image: defaultImage} = useThemeConfig();
85
85
  const {title, description, image, keywords, searchMetadata} = props;
86
86
  const faviconUrl = useBaseUrl(favicon);
87
- const pageTitle = useTitleFormatter(title); // See https://github.com/facebook/docusaurus/issues/3317#issuecomment-754661855
88
- // const htmlLang = currentLocale.split('-')[0];
89
-
90
- const htmlLang = currentLocale; // should we allow the user to override htmlLang with localeConfig?
91
-
92
- const htmlDir = localeConfigs[currentLocale].direction;
87
+ const pageTitle = useTitleFormatter(title);
88
+ const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
93
89
  return (
94
90
  <>
95
91
  <Head>
@@ -9,3 +9,7 @@ ul.contains-task-list {
9
9
  padding-left: 0;
10
10
  list-style: none;
11
11
  }
12
+
13
+ img {
14
+ height: auto;
15
+ }
@@ -16,17 +16,10 @@ import styles from './styles.module.css';
16
16
  function MDXPage(props) {
17
17
  const {content: MDXPageContent} = props;
18
18
  const {
19
- // TODO this frontmatter is not validated/normalized, it's the raw user-provided one. We should expose normalized one too!
20
- frontMatter,
21
- metadata,
19
+ metadata: {title, description, permalink, frontMatter},
22
20
  } = MDXPageContent;
23
- const {
24
- title,
25
- description,
26
- wrapperClassName,
27
- hide_table_of_contents: hideTableOfContents,
28
- } = frontMatter;
29
- const {permalink} = metadata;
21
+ const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
22
+ frontMatter;
30
23
  return (
31
24
  <Layout
32
25
  title={title}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4435",
3
+ "version": "0.0.0-4440",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -23,14 +23,14 @@
23
23
  "update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
24
24
  },
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4435",
27
- "@docusaurus/plugin-content-blog": "0.0.0-4435",
28
- "@docusaurus/plugin-content-docs": "0.0.0-4435",
29
- "@docusaurus/plugin-content-pages": "0.0.0-4435",
30
- "@docusaurus/theme-common": "0.0.0-4435",
31
- "@docusaurus/theme-translations": "0.0.0-4435",
32
- "@docusaurus/utils": "0.0.0-4435",
33
- "@docusaurus/utils-validation": "0.0.0-4435",
26
+ "@docusaurus/core": "0.0.0-4440",
27
+ "@docusaurus/plugin-content-blog": "0.0.0-4440",
28
+ "@docusaurus/plugin-content-docs": "0.0.0-4440",
29
+ "@docusaurus/plugin-content-pages": "0.0.0-4440",
30
+ "@docusaurus/theme-common": "0.0.0-4440",
31
+ "@docusaurus/theme-translations": "0.0.0-4440",
32
+ "@docusaurus/utils": "0.0.0-4440",
33
+ "@docusaurus/utils-validation": "0.0.0-4440",
34
34
  "@mdx-js/mdx": "^1.6.21",
35
35
  "@mdx-js/react": "^1.6.21",
36
36
  "clsx": "^1.1.1",
@@ -45,8 +45,8 @@
45
45
  "rtlcss": "^3.3.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@docusaurus/module-type-aliases": "0.0.0-4435",
49
- "@docusaurus/types": "0.0.0-4435",
48
+ "@docusaurus/module-type-aliases": "0.0.0-4440",
49
+ "@docusaurus/types": "0.0.0-4440",
50
50
  "@types/mdx-js__react": "^1.5.4",
51
51
  "@types/parse-numeric-range": "^0.0.1",
52
52
  "@types/rtlcss": "^3.1.1",
@@ -61,5 +61,5 @@
61
61
  "engines": {
62
62
  "node": ">=14"
63
63
  },
64
- "gitHead": "41656dfd8207e4a9d80de20fa5d9591f197a12b6"
64
+ "gitHead": "d13aa3d3a63285610086e000cfb556fa66073368"
65
65
  }
package/src/index.ts CHANGED
@@ -5,11 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {
9
- DocusaurusContext,
10
- Plugin,
11
- PostCssOptions,
12
- } from '@docusaurus/types';
8
+ import type {LoadContext, Plugin, PostCssOptions} from '@docusaurus/types';
13
9
  import type {ThemeConfig} from '@docusaurus/theme-common';
14
10
  import {getTranslationFiles, translateThemeConfig} from './translations';
15
11
  import path from 'path';
@@ -95,7 +91,7 @@ function getInfimaCSSFile(direction: string) {
95
91
  }
96
92
 
97
93
  export default function docusaurusThemeClassic(
98
- context: DocusaurusContext, // TODO: LoadContext is missing some of properties
94
+ context: LoadContext,
99
95
  options: Options,
100
96
  ): Plugin<void> {
101
97
  const {
@@ -44,9 +44,9 @@ export default function CodeBlock({
44
44
  setMounted(true);
45
45
  }, []);
46
46
 
47
- // TODO: the title is provided by MDX as props automatically
48
- // so we probably don't need to parse the metastring
49
- // (note: title="xyz" => title prop still has the quotes)
47
+ // We still parse the metastring in case we want to support more syntax in the
48
+ // future. Note that MDX doesn't strip quotes when parsing metastring:
49
+ // "title=\"xyz\"" => title: "\"xyz\""
50
50
  const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
51
51
  const prismTheme = usePrismTheme();
52
52
 
@@ -25,7 +25,7 @@ import {useLocation} from '@docusaurus/router';
25
25
  // See https://github.com/facebook/docusaurus/issues/3317
26
26
  function AlternateLangHeaders(): JSX.Element {
27
27
  const {
28
- i18n: {defaultLocale, locales},
28
+ i18n: {defaultLocale, localeConfigs},
29
29
  } = useDocusaurusContext();
30
30
  const alternatePageUtils = useAlternatePageUtils();
31
31
 
@@ -33,7 +33,7 @@ function AlternateLangHeaders(): JSX.Element {
33
33
  // See https://www.searchviu.com/en/multiple-hreflang-tags-one-url/
34
34
  return (
35
35
  <Head>
36
- {locales.map((locale) => (
36
+ {Object.entries(localeConfigs).map(([locale, {htmlLang}]) => (
37
37
  <link
38
38
  key={locale}
39
39
  rel="alternate"
@@ -41,7 +41,7 @@ function AlternateLangHeaders(): JSX.Element {
41
41
  locale,
42
42
  fullyQualified: true,
43
43
  })}
44
- hrefLang={locale}
44
+ hrefLang={htmlLang}
45
45
  />
46
46
  ))}
47
47
  <link
@@ -91,11 +91,7 @@ export default function LayoutHead(props: Props): JSX.Element {
91
91
  const {title, description, image, keywords, searchMetadata} = props;
92
92
  const faviconUrl = useBaseUrl(favicon);
93
93
  const pageTitle = useTitleFormatter(title);
94
-
95
- // See https://github.com/facebook/docusaurus/issues/3317#issuecomment-754661855
96
- // const htmlLang = currentLocale.split('-')[0];
97
- const htmlLang = currentLocale; // should we allow the user to override htmlLang with localeConfig?
98
- const htmlDir = localeConfigs[currentLocale].direction;
94
+ const {htmlLang, direction: htmlDir} = localeConfigs[currentLocale];
99
95
 
100
96
  return (
101
97
  <>
@@ -9,3 +9,7 @@ ul.contains-task-list {
9
9
  padding-left: 0;
10
10
  list-style: none;
11
11
  }
12
+
13
+ img {
14
+ height: auto;
15
+ }
@@ -19,18 +19,10 @@ import styles from './styles.module.css';
19
19
  function MDXPage(props: Props): JSX.Element {
20
20
  const {content: MDXPageContent} = props;
21
21
  const {
22
- // TODO this frontmatter is not validated/normalized, it's the raw user-provided one. We should expose normalized one too!
23
- frontMatter,
24
- metadata,
22
+ metadata: {title, description, permalink, frontMatter},
25
23
  } = MDXPageContent;
26
-
27
- const {
28
- title,
29
- description,
30
- wrapperClassName,
31
- hide_table_of_contents: hideTableOfContents,
32
- } = frontMatter;
33
- const {permalink} = metadata;
24
+ const {wrapperClassName, hide_table_of_contents: hideTableOfContents} =
25
+ frontMatter;
34
26
 
35
27
  return (
36
28
  <Layout
@@ -16,7 +16,7 @@ import type {Types, Props} from '@theme/NavbarItem';
16
16
 
17
17
  const NavbarItemComponents: Record<
18
18
  Exclude<Types, undefined>,
19
- // TODO: properly type this
19
+ // Not really worth typing, as we pass all props down immediately
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
21
  () => (props: any) => JSX.Element
22
22
  > = {