Skip to content

Function: useFrontmatter()

useFrontmatter<T>(): ComputedRef<Partial<PostFrontMatter & T>>

Get route.meta.frontmatter from your markdown file

Type Parameters

T extends Record<string, any> = PostFrontMatter

Returns

ComputedRef<Partial<PostFrontMatter & T>>

Example

md
---
title: Hello World
---
ts
const fm = useFrontmatter()
console.log(fm.value.title)

const fm = useFrontmatter<{ custom: string }>()
console.log(fm.value.custom)

Defined in

packages/valaxy/client/composables/common.ts:25