Pagewrite CLI

Pagewrite Content CLI

pagewrite-content fetches Pagewrite CMS content without running an Astro build. Use it in CI, predeploy steps, or local checks when you want MDX files written into an Astro content directory ahead of time.

Installation

The CLI is included with @lakshmanshankar/pagwrite-astro:

pnpm add @lakshmanshankar/pagwrite-astro

After installation, run it through your package manager:

pnpm pagewrite-content --help

Authentication

Pass the build token directly using the --token option:

pagewrite-content fetch --site-id your-site-id --token rmx_live_xxxxxxxxxxxx

Usage

pagewrite-content fetch --site-id <siteId> [options]

The fetch command stages the site content by fetching the static file tree and paginated file documents, adding title and slug frontmatter, and writing .mdx files to the output directory.

pagewrite-content fetch --site-id your-site-id --out src/content/docs

Options

OptionDefaultDescription
--site-id <id>requiredPagewrite site id to fetch.
--out <dir>src/content/docsOutput directory for generated MDX files.
--output-dir <dir>src/content/docsAlias for --out.
--token <token>requiredBuild token value.
--cleanfalseRemove the output directory before writing files.
--dry-runfalseFetch and validate content, then remove temporary output.
--page-size <number>100File document page size.
--timeout-ms <number>30000Request timeout in milliseconds.
-h--helpnoneShow CLI help.

Examples

Fetch content into the default Astro content directory:

pagewrite-content fetch --site-id your-site-id

Fetch into a custom collection directory:

pagewrite-content fetch --site-id your-site-id --out src/content/blog

Clean the target directory before writing fresh content:

pagewrite-content fetch --site-id your-site-id --out src/content/docs --clean

Validate remote content without keeping files on disk:

pagewrite-content fetch --site-id your-site-id --dry-run

CI Integration

Run the CLI before your framework build:

{
  "scripts": {
    "content:fetch": "pagewrite-content fetch --site-id $PAGEWRITE_SITE_ID --token $PAGEWRITE_BUILD_TOKEN --out src/content/docs --clean",
    "prebuild": "pnpm content:fetch",
    "build": "astro build"
  }
}

Make sure PAGEWRITE_BUILD_TOKEN and PAGEWRITE_SITE_ID are configured as CI secrets or environment variables.

Notes

  • Build tokens should be read-only and scoped to fetch site content.
  • --clean is ignored during --dry-run; dry runs write to a temporary directory and remove it afterward.
  • Unsafe absolute paths and path traversal entries from the remote file tree are rejected before files are written.