1
Install the SDK
Install the Marble SDK in your Astro project:
2
Set up environment variables
Add your Marble API key to your environment variables. Create a
.env file in the root of your Astro project:.env
3
Configure your content collection
Define your content collection with a loader that uses the Marble SDK. Create a file named
src/content.config.ts:src/content.config.ts
4
Display a list of posts
Use
getCollection() to fetch all your posts and display them on a page. Create a file at src/pages/blog/index.astro:src/pages/blog/index.astro
5
Display a single post
Create a dynamic route at
src/pages/blog/[...slug].astro to display individual posts:src/pages/blog/[...slug].astro
Rendering HTML ContentWe use the
set:html directive to render the post content. Marble sanitizes all HTML content on the server, ensuring it’s safe to render directly in your application.