GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Content

Turn Markdown files into pages you can read, list, and search, and let people edit and publish them.

Deploys on
  • Node
  • Docker
  • Cloudflare
  • Vercel
  • Netlify
  • Deno
server/content.ts
import sqlite from 'comark-content/database/sqlite-node'
import sqliteFullTextSearch
  from 'comark-content/plugins/sqlite-full-text-search'
import { defineContent } from 'vite-hub/content'
import { glob } from 'vite-hub/source'

export default defineContent({
  // Keep a search index in SQLite
  plugins: [
    sqliteFullTextSearch({ database: sqlite() }),
  ],
  // Every Markdown file in your docs folder
  sources: {
    docs: glob({ cwd: 'docs', include: '**/*.md' }),
  },
})
server/content.ts

Search uses optional comark-content plugins. Search configuration shows how to install them and where they store data. You need no Comark setup to read and render Markdown.

Write pages in Markdown

Point Content at a folder of Markdown files. It reads the headings and body of each page.

Read pages from a route

content.get() returns one page. content.navigation() builds a menu from all pages.

Search every page

Add the full-text search plugin. It keeps its index in SQLite.

URLs, head tags, and a sitemap

seo() fields, contentHead() for any framework, and generated /sitemap.xml and /robots.txt.

Publish reviewed drafts on a schedule

content.schedule() publishes the reviewed version later. A Schedule Definition runs it on every host.

One editor at a time, and everyone sees who

See who is editing. While one person holds the edit lease, writes from others fail with CONTENT_LEASE_HELD.

Edit, publish, and schedule from the terminal

vitehub content lists, edits, and diffs drafts in your running dev server, then publishes or schedules what you reviewed.

Read pages from the browser

createContentClient() reads the /api/content route that ViteHub adds for you.

Edit, then publish

People edit collection pages in your app. Each save is a draft. Visitors see only what you publish.

One preset stores the collections

extends: cms adds the Workspace, its history tables, and a Database when the app has none.

Let an Agent draft, publish, and schedule documents

content() gives an Agent typed tools for each collection and singleton. Your authorize policy decides what it may read and change. Publishing asks for approval.

Check every field

Give each front matter field a rule, such as "title is not empty". A save with a bad field fails.