A little headless CMS that stores models and content in your PDS sites.wisp.place/wilb.me/pds-cms
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051#!/usr/bin/env nodeimport { mkdir, writeFile } from 'node:fs/promises'import { dirname, join } from 'node:path'import { parseArgs } from 'node:util'import process from 'node:process'import { buildSite } from './site.js'
const HELP = `Usage: pds-cms-render <handle-or-did> [options]
Renders an account's pds-cms content into a static site.
Options: -o, --out <dir> Output directory (default: site) -t, --title <title> Site title (default: the account's handle) -d, --description <s> Site description -h, --help Show this help`
const { values, positionals } = parseArgs({ options: { out: { type: 'string', short: 'o', default: 'site' }, title: { type: 'string', short: 't' }, description: { type: 'string', short: 'd' }, help: { type: 'boolean', short: 'h' }, }, allowPositionals: true,})
if (values.help || positionals.length !== 1) { console.log(HELP) process.exit(values.help ? 0 : 1)}
const actor = positionals[0]console.log(`Fetching content for ${actor}...`)const files = await buildSite(actor, { title: values.title, description: values.description,})
if (files.length === 1) { console.log('Note: no content records found — the site is just an empty index page.')}for (const file of files) { const path = join(values.out, file.path) await mkdir(dirname(path), { recursive: true }) await writeFile(path, file.html) console.log(` wrote ${path}`)}console.log(`Done: ${files.length} page(s) in ${values.out}/`)