From: Eduardo San Martin Morote Date: Fri, 9 Apr 2021 10:14:16 +0000 (+0200) Subject: docs: load theme X-Git-Tag: v2.0.0-alpha.11~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c449d6e52c2690afedd04ea9fa954be9b735233;p=thirdparty%2Fvuejs%2Fpinia.git docs: load theme Close #427 --- diff --git a/docs/.vitepress/theme/index.js b/docs/.vitepress/theme/index.js index 6c435a67..423cf24f 100644 --- a/docs/.vitepress/theme/index.js +++ b/docs/.vitepress/theme/index.js @@ -2,6 +2,25 @@ import Theme from 'vitepress/theme' import './custom.css' import './code-theme.css' -export default { +const { Layout } = Theme + +const existingMounted = Layout.mounted || (() => {}) + +Layout.mounted = function () { + existingMounted.call(this) + + const storedTheme = localStorage.getItem('pinia-color-scheme') + const mediaQuery = window.matchMedia('(prefers-color-scheme: light)') + + if (mediaQuery.matches || storedTheme === 'light') { + const htmlElement = document.body.parentElement + htmlElement.classList.add('light') + } +} + +/** @type {import('vitepress').Theme} */ +const config = { ...Theme, } + +export default config