element-plus/docs/.vitepress/vitepress/composables/feature-flag.ts
三咲智子 3ab869b446
refactor(docs): improve style and fix typo (#7094)
* refactor(docs): improve style and fix typo

* fix(docs): dark
2022-04-12 20:14:08 +08:00

17 lines
506 B
TypeScript

import { computed, unref } from 'vue'
import { useData } from 'vitepress'
import { useBrowserLocation } from '@vueuse/core'
import type { MaybeRef } from '@vueuse/core'
const location = useBrowserLocation()
export const useFeatureFlag = (flag: MaybeRef<string>) => {
const { theme } = useData()
return computed(() => {
const _flag = unref(flag)
const params = new URLSearchParams(location.value.search)
return params.get(`feature:${_flag}`) || (theme.value.features || {})[_flag]
})
}