Reference › APIs

On this page

@clarusjs/content

Markdown pages as a page source. For the how-to, see Markdown pages.

ts
import markdown, { slugify } from '@clarusjs/content'

markdown() #

ts
markdown(options?: MarkdownOptions): Source

Turns src/pages/**/*.md into pages, rendered in your layout. They get:

It runs at build time only: nothing of it reaches the browser.

Parameters #

Returns #

A page source (see Page sources), for the plugin's sources option.

Caveats #

Usage #

ts
// vite.config.ts
import { defineConfig } from 'vite'
import clarusjs from 'clarusjs/vite'
import markdown from '@clarusjs/content'

export default defineConfig({
  plugins: [clarusjs({ sources: [markdown({ layout: '/src/layouts/docs.tscl' })] })],
})

slugify() #

ts
slugify(text: string): string

A heading's anchor: lowercase, accents and punctuation removed, words joined by -. It's what headings' ids are made of, so a link to a section can be built from its title.

ts
slugify('Getting started!') // 'getting-started'