mirror of
https://github.com/waynesutton/markdown-site.git
synced 2026-01-12 12:19:18 +00:00
3.3 KiB
3.3 KiB
description
| description |
|---|
| How the content sync system works |
Sync System Reference
How the content sync system works in this markdown publishing framework.
Overview
Content flows from markdown files to Convex database via sync scripts. Changes appear instantly because Convex provides real-time updates.
content/blog/*.md --+
+--> npm run sync --> Convex DB --> Site
content/pages/*.md --+
Sync commands
| Command | Environment | What it syncs |
|---|---|---|
npm run sync |
Development | Posts + pages to dev Convex |
npm run sync:prod |
Production | Posts + pages to prod Convex |
npm run sync:discovery |
Development | AGENTS.md + llms.txt |
npm run sync:discovery:prod |
Production | AGENTS.md + llms.txt |
npm run sync:all |
Development | Everything |
npm run sync:all:prod |
Production | Everything |
How sync works
Content sync (sync-posts.ts)
- Reads all
.mdfiles fromcontent/blog/andcontent/pages/ - Parses frontmatter with
gray-matter - Validates required fields (title, slug, etc.)
- Calculates reading time if not provided
- Calls Convex mutations to upsert content
- Generates raw markdown files in
public/raw/
Discovery sync (sync-discovery-files.ts)
- Reads site configuration from
src/config/siteConfig.ts - Queries Convex for post/page counts
- Updates
AGENTS.mdwith current status - Generates
public/llms.txtwith API info
File locations
| Script | Purpose |
|---|---|
scripts/sync-posts.ts |
Syncs markdown content |
scripts/sync-discovery-files.ts |
Updates discovery files |
scripts/import-url.ts |
Imports external URLs |
Environment variables
| File | Used by |
|---|---|
.env.local |
Development sync (default) |
.env.production.local |
Production sync |
Both files contain VITE_CONVEX_URL pointing to the Convex deployment.
What gets synced
Posts (content/blog/)
- Frontmatter fields (title, description, date, tags, etc.)
- Full markdown content
- Calculated reading time
Pages (content/pages/)
- Frontmatter fields (title, slug, order, etc.)
- Full markdown content
Generated files (public/raw/)
For each published post/page, a static markdown file is generated at public/raw/{slug}.md. Also generates public/raw/index.md listing all content.
Sync mutations
The sync scripts call these Convex mutations:
// Posts
api.posts.syncPostsPublic({ posts: ParsedPost[] })
// Pages
api.pages.syncPagesPublic({ pages: ParsedPage[] })
Adding a new frontmatter field
- Add to interface in
scripts/sync-posts.ts - Add to Convex schema in
convex/schema.ts - Add to sync mutation in
convex/posts.tsorconvex/pages.ts - Add to return validators in queries
- Run
npm run syncto apply
Import from URL
npm run import https://example.com/article
Requires FIRECRAWL_API_KEY. After import, run sync.
Troubleshooting
"VITE_CONVEX_URL not set"
Run npx convex dev first to create .env.local.
Posts not appearing
- Check
published: truein frontmatter - Verify required fields are present
- Check Convex dashboard for errors
- Run
npm run syncagain
Sync to wrong environment
npm run sync= developmentnpm run sync:prod= production