-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
130 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
const localStorageKey = 'vitepress:tabsSharedState' | ||
const ls = typeof localStorage !== 'undefined' ? localStorage : null | ||
const localStorageKey = "vitepress:tabsSharedState"; | ||
const ls = typeof localStorage !== "undefined" ? localStorage : null; | ||
|
||
const getLocalStorageValue = (): Record<string, string> => { | ||
const rawValue = ls?.getItem(localStorageKey) | ||
const rawValue = ls?.getItem(localStorageKey); | ||
if (rawValue) { | ||
try { | ||
return JSON.parse(rawValue) | ||
return JSON.parse(rawValue); | ||
} catch {} | ||
} | ||
return {} | ||
} | ||
return {}; | ||
}; | ||
|
||
const setLocalStorageValue = (v: Record<string, string>) => { | ||
if (!ls) return | ||
ls.setItem(localStorageKey, JSON.stringify(v)) | ||
} | ||
if (!ls) return; | ||
ls.setItem(localStorageKey, JSON.stringify(v)); | ||
}; | ||
|
||
export const setupFrameworksTabs = () => { | ||
const v = getLocalStorageValue() | ||
const v = getLocalStorageValue(); | ||
if (!v.frameworks) { | ||
setLocalStorageValue({"frameworks":"React"}) | ||
setLocalStorageValue({ frameworks: "React" }); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// https://vitepress.dev/guide/custom-theme | ||
import { h } from 'vue' | ||
import type { Theme } from 'vitepress' | ||
import DefaultTheme from 'vitepress/theme' | ||
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client' | ||
import { setupFrameworksTabs } from './frameworksTabs' | ||
import './style.css' | ||
import { h } from "vue"; | ||
import type { Theme } from "vitepress"; | ||
import DefaultTheme from "vitepress/theme"; | ||
import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client"; | ||
import { setupFrameworksTabs } from "./frameworksTabs"; | ||
import "./style.css"; | ||
|
||
export default { | ||
extends: DefaultTheme, | ||
Layout: () => { | ||
return h(DefaultTheme.Layout, null, { | ||
// https://vitepress.dev/guide/extending-default-theme#layout-slots | ||
}) | ||
}); | ||
}, | ||
enhanceApp({ app, router, siteData }) { | ||
enhanceAppWithTabs(app) | ||
enhanceAppWithTabs(app); | ||
}, | ||
setup() { | ||
setupFrameworksTabs() | ||
} | ||
} satisfies Theme | ||
setupFrameworksTabs(); | ||
}, | ||
} satisfies Theme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters