AI Agent Authoring
AI Agent Authoring
Yamblog is designed for AI agents as a first-class authoring workflow. A post is just a markdown file with a YAML frontmatter block — trivial to generate, validate, and update programmatically.
What an agent can do
- Create a
.mdfile incontent/posts/with valid frontmatter - Populate required and optional metadata fields
- Write the body in markdown with correct heading hierarchy
- Validate the post by calling
blog.getPostBySlug(slug)— any parse error throws - Update an existing post by editing frontmatter or body
- Set
draft: falseto publish,draft: trueto unpublish
Authoring steps
-
Choose a slug — derive a stable, URL-safe slug from the title. Rules: lowercase, hyphens, ASCII only. Example:
"How I Built X"→how-i-built-x. -
Write frontmatter — populate all required fields, plus optional ones as relevant:
---title: "How I Built X"date: "2026-05-08"author: "Agent Name"tags: ["tutorial", "typescript"]excerpt: "A one-sentence summary used in listings and OpenGraph."draft: false---Do not include
slugin frontmatter — it is derived from the filename automatically. -
Write the body — compose markdown. Start with
##headings (not#, which duplicates the title). Keep paragraphs focused. -
Validate — call the API to confirm parsing succeeds:
import { defineBlog } from '@yamblog/core';const blog = defineBlog('content/posts');const post = await blog.getPostBySlug('how-i-built-x');console.log(post.id, post.readingTime);If the frontmatter is invalid (wrong type, missing required field) this throws — fix the file and retry.
-
Publish — set
draft: false(already set in step 2 if publishing immediately).
Agent setup prompt
For a repo integration prompt that detects the framework, confirms platform support, creates a sample post, and self-heals on bad first attempts, use Prompt for LLMs.
Copy-paste this into any AI coding agent to bootstrap Yamblog authoring inside an already-configured project:
Install and configure Yamblog:
1. Install packages npm install @yamblog/core @yamblog/next # Next.js npm install @yamblog/core @yamblog/astro # Astro npm install @yamblog/core @yamblog/react # Vite React
2. Create the content directory mkdir -p content/posts Create content/posts/hello-world.md with frontmatter: title, slug, date, author, tags, excerpt, draft: false
3. Create the blog instance (lib/blog.ts) import { defineBlog } from "@yamblog/core"; export const blog = defineBlog("content/posts"); // siteUrl auto-detected from NEXT_PUBLIC_BASE_URL / SITE / VERCEL_URL
4. Wire routes (Next.js App Router example) app/blog/page.tsx → blog.getPosts() app/blog/[slug]/page.tsx → blog.getPostBySlug(slug) app/feed.xml/route.ts → createRssHandler(blog, { title, description }) app/sitemap.ts → createSitemapExport(blog)
5. Verify npm run dev → open /blog npm run build → no type errors
6. Optional enhancements - OG image: createOgImageHandler in app/blog/[slug]/opengraph-image/route.ts - Breadcrumb JSON-LD: generateBreadcrumbJsonLd in post page - Static params: createStaticParams in generateStaticParams - Search index: blog.generateSearchIndex() → public/search-index.json - Wire post.id into comments / analytics serviceFrontmatter field reference
| Field | Required | Type | Notes |
|---|---|---|---|
title | yes | string | Post title, used in metadata and listings |
date | yes | ISO 8601 string | Publication date |
author | no | string | Defaults to 'Anonymous' |
tags | no | string[] | Defaults to [] |
excerpt | no | string | Used in listings and OpenGraph description |
draft | no | boolean | true hides the post; defaults to false |
featured | no | boolean | Returned by getFeaturedPosts(); defaults to false |
category | no | string | Used by getPostsByCategory() |
coverImage | no | string | URL or path to cover image |
Computed fields (do not add to frontmatter)
| Field | Value |
|---|---|
id | "blog-{slug}" — stable foreign key |
slug | Derived from filename — do not add to frontmatter |
readingTime | Minutes at 200 WPM |
content | Raw markdown body |
Validation errors
Common mistakes and how to fix them:
| Error | Fix |
|---|---|
date is not a valid date | Use ISO 8601 format: "2026-01-15" |
tags is not an array | Use YAML array: tags: ["a", "b"] |
Post not found | Check the slug matches the filename (minus .md) |
Schema validation failed | Check all required fields are present and typed correctly |