@docusaurus/theme-classic 0.0.0-5496 → 0.0.0-5502

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 (3) hide show
  1. package/lib/index.js +12 -3
  2. package/package.json +14 -14
  3. package/src/index.ts +13 -3
package/lib/index.js CHANGED
@@ -18,6 +18,7 @@ const ContextReplacementPlugin = requireFromDocusaurusCore('webpack/lib/ContextR
18
18
  // Need to be inlined to prevent dark mode FOUC
19
19
  // Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
20
20
  const ThemeStorageKey = 'theme';
21
+ const ThemeQueryStringKey = 'docusaurus-theme';
21
22
  const noFlashColorMode = ({ defaultMode, respectPrefersColorScheme, }) =>
22
23
  /* language=js */
23
24
  `(function() {
@@ -28,6 +29,14 @@ const noFlashColorMode = ({ defaultMode, respectPrefersColorScheme, }) =>
28
29
  document.documentElement.setAttribute('data-theme', theme);
29
30
  }
30
31
 
32
+ function getQueryStringTheme() {
33
+ var theme = null;
34
+ try {
35
+ theme = new URLSearchParams(window.location.search).get('${ThemeQueryStringKey}')
36
+ } catch(e) {}
37
+ return theme;
38
+ }
39
+
31
40
  function getStoredTheme() {
32
41
  var theme = null;
33
42
  try {
@@ -36,9 +45,9 @@ const noFlashColorMode = ({ defaultMode, respectPrefersColorScheme, }) =>
36
45
  return theme;
37
46
  }
38
47
 
39
- var storedTheme = getStoredTheme();
40
- if (storedTheme !== null) {
41
- setDataThemeAttribute(storedTheme);
48
+ var initialTheme = getQueryStringTheme() || getStoredTheme();
49
+ if (initialTheme !== null) {
50
+ setDataThemeAttribute(initialTheme);
42
51
  } else {
43
52
  if (
44
53
  respectPrefersColorScheme &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5496",
3
+ "version": "0.0.0-5502",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,18 +20,18 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "0.0.0-5496",
24
- "@docusaurus/mdx-loader": "0.0.0-5496",
25
- "@docusaurus/module-type-aliases": "0.0.0-5496",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5496",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5496",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5496",
29
- "@docusaurus/theme-common": "0.0.0-5496",
30
- "@docusaurus/theme-translations": "0.0.0-5496",
31
- "@docusaurus/types": "0.0.0-5496",
32
- "@docusaurus/utils": "0.0.0-5496",
33
- "@docusaurus/utils-common": "0.0.0-5496",
34
- "@docusaurus/utils-validation": "0.0.0-5496",
23
+ "@docusaurus/core": "0.0.0-5502",
24
+ "@docusaurus/mdx-loader": "0.0.0-5502",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5502",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5502",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5502",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5502",
29
+ "@docusaurus/theme-common": "0.0.0-5502",
30
+ "@docusaurus/theme-translations": "0.0.0-5502",
31
+ "@docusaurus/types": "0.0.0-5502",
32
+ "@docusaurus/utils": "0.0.0-5502",
33
+ "@docusaurus/utils-common": "0.0.0-5502",
34
+ "@docusaurus/utils-validation": "0.0.0-5502",
35
35
  "@mdx-js/react": "^1.6.22",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.0.1",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=16.14"
64
64
  },
65
- "gitHead": "46debc3fc3c933c32ca95d9b67c16e19cd6d0d20"
65
+ "gitHead": "bb58b0fd3442b2ce9b251199c6d9982923d102ca"
66
66
  }
package/src/index.ts CHANGED
@@ -26,6 +26,8 @@ const ContextReplacementPlugin = requireFromDocusaurusCore(
26
26
  // Need to be inlined to prevent dark mode FOUC
27
27
  // Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
28
28
  const ThemeStorageKey = 'theme';
29
+ const ThemeQueryStringKey = 'docusaurus-theme';
30
+
29
31
  const noFlashColorMode = ({
30
32
  defaultMode,
31
33
  respectPrefersColorScheme,
@@ -39,6 +41,14 @@ const noFlashColorMode = ({
39
41
  document.documentElement.setAttribute('data-theme', theme);
40
42
  }
41
43
 
44
+ function getQueryStringTheme() {
45
+ var theme = null;
46
+ try {
47
+ theme = new URLSearchParams(window.location.search).get('${ThemeQueryStringKey}')
48
+ } catch(e) {}
49
+ return theme;
50
+ }
51
+
42
52
  function getStoredTheme() {
43
53
  var theme = null;
44
54
  try {
@@ -47,9 +57,9 @@ const noFlashColorMode = ({
47
57
  return theme;
48
58
  }
49
59
 
50
- var storedTheme = getStoredTheme();
51
- if (storedTheme !== null) {
52
- setDataThemeAttribute(storedTheme);
60
+ var initialTheme = getQueryStringTheme() || getStoredTheme();
61
+ if (initialTheme !== null) {
62
+ setDataThemeAttribute(initialTheme);
53
63
  } else {
54
64
  if (
55
65
  respectPrefersColorScheme &&