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!
::
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:
.mdfiles incontent/posts/store post bodies alongside YAML frontmatter (title,description,pubDate, andtags). - Comark parsing:
lib/posts.tsreads each file and callsparseMarkdown()withshiki()to extract frontmatter and build theMarkdownDocumentin one pass, instead of chaininggray-matter,remark, andrehype. - Static generation:
generateStaticParamspre-renders every post at build time withoutput: 'export'. - Server Components:
MarkdownDocumentrenders custom components such asAlertand slot-awareFeatureCardon the server.