UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

46 lines (45 loc) 1.27 kB
import { isClient } from "@scalar/api-client/v2/blocks/operation-code-sample"; import { useSeoMeta } from "@unhead/vue"; import { useFavicon } from "@vueuse/core"; import { watch, toValue, computed } from "vue"; const mapConfigToWorkspaceStore = ({ config, store, isDarkMode }) => { watch( () => toValue(config).defaultHttpClient, (newValue) => { if (newValue) { const { targetKey, clientKey } = newValue; const clientId = `${targetKey}/${clientKey}`; if (isClient(clientId)) { store.update("x-scalar-default-client", clientId); } } }, { immediate: true } ); watch( () => toValue(config).darkMode, (isDark) => store.update("x-scalar-color-mode", isDark ? "dark" : "light") ); watch( () => isDarkMode.value, (newIsDark) => store.update("x-scalar-color-mode", newIsDark ? "dark" : "light"), { immediate: true } ); if (toValue(config).metaData) { useSeoMeta(toValue(config).metaData); } watch( () => toValue(config).proxyUrl, (newProxyUrl) => store.update("x-scalar-active-proxy", newProxyUrl), { immediate: true } ); const favicon = computed(() => toValue(config).favicon); useFavicon(favicon); }; export { mapConfigToWorkspaceStore };