Skip to main content

Metadata Command

Fetches meta tags from your live documentation pages and writes them into the frontmatter of the corresponding MDX source files. Existing frontmatter keys are updated (overwritten); missing keys are appended.

Usage

writechoice metadata [baseUrl] [options]

Arguments

ArgumentDescription
baseUrlBase URL of the live documentation site (optional if set in config.json as source)

Options

OptionAliasDescriptionDefault
--file <path>-fProcess a single MDX file-
--dir <path>-dProcess MDX files in a specific directory-
--concurrency <number>-cNumber of parallel HTTP requests15
--dry-run-Preview changes without writing filesfalse
--quiet-Suppress terminal outputfalse

How It Works

For each MDX file, the command:

  1. Constructs a URL by appending the file's path (relative to the scan directory, without .mdx) to the base URL
  2. Fetches the live page using an HTTP request
  3. Extracts meta tags from the HTML (og:*, twitter:*)
  4. Updates the frontmatter — existing keys are overwritten, new keys are appended

URL Mapping

Base URL : https://docs.example.com
File : docs/api/reference.mdx
→ URL : https://docs.example.com/api/reference

Meta Tags Fetched

TagFrontmatter key
og:titleog:title
og:descriptionog:description
og:imageog:image
og:urlog:url
twitter:titletwitter:title
twitter:descriptiontwitter:description
twitter:imagetwitter:image

Customize this list with tags in config.json (see below).

Examples

# Use source from config.json
writechoice metadata

# Specify base URL directly
writechoice metadata https://docs.example.com

# Process a single file
writechoice metadata https://docs.example.com -f docs/api/reference.mdx

# Preview without writing
writechoice metadata --dry-run

# Process with lower concurrency
writechoice metadata https://docs.example.com -c 5

Config File

{
"source": "https://docs.example.com",
"metadata": {
"concurrency": 15,
"tags": [
"og:title",
"og:description",
"og:image",
"og:url",
"twitter:title",
"twitter:description",
"twitter:image"
],
"dry-run": false,
"quiet": false
}
}