vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.33k stars 1.83k forks source link

Can I directly read the filename as title like docusaurus? Instead of needing to configure frontmatter or define Level1 Heading as title #3735

Closed hxhac closed 3 weeks ago

hxhac commented 3 weeks ago

Is your feature request related to a problem? Please describe.

noop

Describe the solution you'd like

Read filename as title.

Describe alternatives you've considered

No response

Additional context

No response

Validations

brc-dd commented 3 weeks ago

Try something like this in your config file:

import { defineConfig } from 'vitepress'

export default defineConfig({
  transformPageData(pageData) {
    pageData.title = pageData.filePath.split('/').pop()!.replace(/\.md$/, '')
  }
})
hxhac commented 3 weeks ago

THX, have nailed it.