Skip to content

idleberg/vite-plugin-nomatter

Repository files navigation

vite-plugin-nomatter

License Version: npm GitHub branch check runs

A Vite plugin that lets you write pure Markdown without frontmatter. It derives the title (and optional description) from the document's own content at build time.

Works great with Astro Starlight but is not tied to it.

Installation 💿

pnpm add -D vite-plugin-nomatter

Usage 🚀

// astro.config.mjs
import { defineConfig } from 'astro/config'
import starlight from '@astrojs/starlight'
import nomatter from 'vite-plugin-nomatter'

export default defineConfig({
	vite: {
		plugins: [
			nomatter({
				// default options
				extensions: ['.md', '.markdown'],
				contentDir: 'src/content/docs',
				descriptionLength: 150,
				stripHeading: true,
				meta: {
					draft: false,
				},
			})
		]
	},
	integrations: [
		starlight({ title: 'My Docs' })
	]
})

API ⚙️

nomatter(options?)

Options

Option Type Default Description
extensions string[] ['.md', '.markdown'] File extensions to process
contentDir string 'src/content/docs' Only files under this path segment are processed
descriptionLength number 160 Maximum character length for the extracted description
stripHeading boolean true Remove the h1 from the body after extracting the title
meta Record<string, unknown> {} Additional frontmatter fields to inject into every file

License ©️

This work is licensed under The MIT License.

About

Vite plugin that derives frontmatter from Markdown content, removing the need to write frontmatter

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors