mirror of https://github.com/vuejs/vitepress
parent
930038923c
commit
eb2f47ae3d
@ -1,12 +1,4 @@
|
||||
import { useData as useData$ } from 'vitepress'
|
||||
import type { DefaultTheme } from 'vitepress/theme'
|
||||
|
||||
export function useData() {
|
||||
const data = useData$<DefaultTheme.Config>()
|
||||
|
||||
// Allow an arbitrary layout to be used as the home layout
|
||||
;(data.frontmatter as any).isHomeLayout ??=
|
||||
(data.frontmatter as any).layout === 'home'
|
||||
|
||||
return data
|
||||
}
|
||||
export const useData: typeof useData$<DefaultTheme.Config> = useData$
|
||||
|
@ -0,0 +1,14 @@
|
||||
import { computed } from 'vue'
|
||||
import { useData } from './data'
|
||||
|
||||
export function useDerived() {
|
||||
const { frontmatter } = useData()
|
||||
|
||||
const isHomeLayout = computed(() => {
|
||||
if (frontmatter.value.isHomeLayout !== undefined)
|
||||
return Boolean(frontmatter.value.isHomeLayout)
|
||||
else return frontmatter.value.layout === 'home'
|
||||
})
|
||||
|
||||
return { isHomeLayout }
|
||||
}
|
Loading…
Reference in new issue