Next.js Markdown Blog with React Server Components

Render a Markdown blog with the Next.js App Router, static export, and React Server Components.
comark-syntax.md
---
title: Comark Syntax Guide
description: A quick tour of what you can do with Comark's component syntax.
pubDate: 2025-12-15
tags: [comark, syntax, components]
---

Comark is **Components in Markdown** — it extends standard Markdown with a powerful component syntax.

## Inline formatting

You can use all the usual Markdown formatting: **bold**, *italic*, `code`, and [links](https://comark.dev).

## Components

Components use the `::` syntax. They can have attributes and children:

::alert{type="warning"}
Pay attention to the double-colon syntax — it's how Comark identifies components.
::

## Component slots

React components receive default content as `children`, and named slots as props like `slotHeader` and `slotFooter`:

::feature-card
#header
Slot-aware React component

#default
This body is the default slot. It can contain **Markdown**, links, lists, or any nested Comark content.

#footer
Rendered through the `slotFooter` prop in `FeatureCard.tsx`.
::

## Lists

Comark handles lists, of course:

- First item
- Second item with **bold** text
- Third item with `inline code`

1. Numbered items work too
2. With full Markdown support inside

## Code blocks

Syntax highlighting works out of the box:

```js
function greet(name) {
  return `Hello, ${name}!`
}
```

## Block quotes

> Comark makes Markdown more powerful without sacrificing simplicity.

::alert{type="danger"}
Don't forget to close your components with `::` — otherwise `autoClose` will handle it for you!
::
https://comark-nextjs.vercel.app/blog/comark-syntax

This example renders a static Markdown blog with the Next.js App Router and React Server Components. Posts live in content/posts/ as .md files with YAML frontmatter, parse on the server with parseMarkdown(), and render through MarkdownDocument from @comark/react.

How it works

  • File-based content: .md files in content/posts/ store post bodies alongside YAML frontmatter (title, description, pubDate, and tags).
  • Comark parsing: lib/posts.ts reads each file and calls parseMarkdown() with shiki() to extract frontmatter and build the MarkdownDocument in one pass, instead of chaining gray-matter, remark, and rehype.
  • Static generation: generateStaticParams pre-renders every post at build time with output: 'export'.
  • Server Components: MarkdownDocument renders custom components such as Alert and slot-aware FeatureCard on the server.
© 2026 Vercel, Inc.