Astro Markdown Blog with Comark

Render a Markdown blog with Astro content collections, Zod frontmatter validation, and React 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.
::

## 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 Markdown blog posts with Astro content collections and React components. Posts live as .md files with Zod-validated frontmatter, load through Astro's glob() loader, and render with MarkdownDocument from @comark/react and custom components such as Alert.

How it works

  • Content collections: src/content.config.ts defines the posts collection with glob() and a Zod schema for title, description, pubDate, and tags.
  • Comark parsing: src/pages/posts/[...id].astro passes post.body to parseMarkdown() with the shiki() plugin to produce a MarkdownDocument.
  • Server rendering: MarkdownDocument from @comark/react renders the document with React components on the server at build time, without shipping client-side JavaScript.
© 2026 Vercel, Inc.