Skip to content

Markdown examples

Common authoring snippets

Code#

export function greet(name: string) {
  return `Hello, ${name}!`
}

Highlight a single line with fence meta ({2}) or inline notation:

export function greet(name: string) {
  return `Hello, ${name}!`;
}

Inline code like themeConfig.outline uses the same theme tokens as code blocks.

Snippet import#

Reuse source files instead of duplicating code:

export function greet(name: string) {
  return `Hello, ${name}!`;
}

The @/ prefix resolves from the site content root (srcDir).

Home · External link

Tables#

Syntax Result
# Title Heading
--- frontmatter Page metadata

Quotes#

Use blockquotes for callouts, notes, or short contextual hints.

Containers#

TIP

::: tip, ::: warning, ::: danger, ::: info, and ::: details work like VitePress custom containers.

Optional title

You can pass a custom title after the container type.

Learn more

Details blocks render as native <details> elements.

GFM alerts#

GitHub-flavored alert syntax renders with the same styling as custom containers:

NOTE

Useful information that readers should know.

TIP

Optional advice for doing things more easily.

WARNING

Critical content that needs immediate attention.

Custom heading IDs#

Stable links#

Append {#id} to any heading to control its anchor.

Emoji#

PreactPress supports :tada: and :rocket: shortcodes out of the box.

Inline table of contents#

Second section#

Content below the inline TOC.

Sub section#

Nested heading for the outline.

Code groups#

export default { lang: "js" };
export default { lang: "ts" };

Markdown inclusion#

Included body#

Heading IDs#

Custom anchors#

Add {#your-id} to any heading to control the fragment URL.

Inline table of contents#

First section#

Content for the first section.

Second section#

Content for the second section.

Code groups#

npm install
pnpm install

Markdown includes#

Reuse shared fragments with HTML comments:

Shared fragment

This note is pulled in via <!-- include cycle detected: /tmp/preactpress-demo-hono-EN35Wl/partials/shared-note.md -->.

Emoji and math#

Enable in config: markdown: { emoji: true, math: true }.

:tada: becomes a party popper when emoji is on.

Inline math: $E = mc^2$

Updated Nov 2, 2026