diff --git a/api/universal-parameters/mode.md b/api/universal-parameters/mode.md index dc5543e0..92ba7f8b 100644 --- a/api/universal-parameters/mode.md +++ b/api/universal-parameters/mode.md @@ -51,7 +51,7 @@ Data freshness is not guaranteed. Symbols with higher usage across Market Data c * Bulk Candles: Unavailable * Other Endpoints: Unavailable -This makes cached mode particularly cost-effective for bulk quote retrieval using endpoints such as [Option Chain](/api/options/chain) and [Bulk Stock Quotes](/api/stocks/bulkquotes). +This makes cached mode particularly cost-effective for bulk quote retrieval using endpoints such as [Option Chain](/api/options/chain) and [Bulk Stock Quotes](/api/stocks/quotes). ### Requesting Cached Data diff --git a/docusaurus.config.js b/docusaurus.config.js index 0e822c4b..1ddaba91 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -64,7 +64,10 @@ const config = { ], ], + clientModules: ['./src/clientModules/themeCookieSync.js'], + plugins: [ + './plugins/theme-cookie-sync', [ "@docusaurus/plugin-client-redirects", { diff --git a/package.json b/package.json index ba603e8a..b87fb2a9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@docusaurus/plugin-client-redirects": "3.0.1", "@docusaurus/plugin-content-docs": "3.0.1", "@docusaurus/preset-classic": "3.0.1", + "@marketdataapp/ui": "github:MarketDataApp/ui", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "dotenv": "^16.0.2", diff --git a/plugins/theme-cookie-sync.js b/plugins/theme-cookie-sync.js new file mode 100644 index 00000000..726b3b9f --- /dev/null +++ b/plugins/theme-cookie-sync.js @@ -0,0 +1,15 @@ +module.exports = function themeCookieSyncPlugin() { + return { + name: 'theme-cookie-sync', + injectHtmlTags() { + return { + headTags: [ + { + tagName: 'script', + innerHTML: `(function(){var m=document.cookie.match(/(?:^|;\\s*)theme=(dark|light)/);if(m)try{localStorage.setItem('theme',m[1])}catch(e){}})();`, + }, + ], + }; + }, + }; +}; diff --git a/src/clientModules/themeCookieSync.js b/src/clientModules/themeCookieSync.js new file mode 100644 index 00000000..98787ce7 --- /dev/null +++ b/src/clientModules/themeCookieSync.js @@ -0,0 +1,20 @@ +import { setThemeCookie } from '@marketdataapp/ui/theme'; +import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; + +if (ExecutionEnvironment.canUseDOM) { + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.attributeName === 'data-theme') { + const theme = document.documentElement.getAttribute('data-theme'); + if (theme === 'dark' || theme === 'light') { + setThemeCookie(theme); + } + } + } + }); + + observer.observe(document.documentElement, { + attributes: true, + attributeFilter: ['data-theme'], + }); +} diff --git a/yarn.lock b/yarn.lock index f8cc670d..75d75845 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1581,6 +1581,10 @@ resolved "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz" integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A== +"@marketdataapp/ui@github:MarketDataApp/ui": + version "1.1.0" + resolved "https://codeload.github.com/MarketDataApp/ui/tar.gz/d83dfd362a12e3173f02eb2c31eb43f4a7379fed" + "@mdx-js/mdx@^3.0.0": version "3.0.0" resolved "https://registry.npmjs.org/@mdx-js/mdx/-/mdx-3.0.0.tgz"