Sample 16: Mixed Content (Blog Post)
A realistic blog post mixing various Notion block types.
In this post, we'll explore how to build a static blog using Astro 5 and Notion as a CMS.
Why Notion as a CMS?
Notion offers a clean writing experience with a rich block editor. Using the Notion Public API, we can fetch page content as Markdown and render it in Astro.
π‘ Tip: You need a Notion Internal Integration Token to use the API. Create one at notion.so/profile/integrations.
Setting Up the Project
npm create astro@latest my-blog
cd my-blog
npm install notro
Configuring the Content Loader
Add the following to your content.config.ts:
import { defineCollection } from "astro:content";
import { loader, pageWithMarkdownSchema } from "notro";
const posts = defineCollection({
loader: loader({
queryParameters: { data_source_id: import.meta.env.NOTION_DATASOURCE_ID },
clientOptions: { auth: import.meta.env.NOTION_TOKEN },
}),
schema: pageWithMarkdownSchema,
});
export const collections = { posts };
Key Features
| Feature | Supported |
|---|---|
| Headings | β |
| Code blocks | β |
| Callouts | β |
| Tables | β |
| Math (KaTeX) | β |
| Toggles | β |
Conclusion
With NotroTail, you get a fast, SEO-optimized blog powered by Notion. Happy writing!