npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wp2astro/convert

v0.0.2

Published

Convert WordPress sites to Astro projects via the WP REST API

Readme

@wp2astro/convert

CLI that converts a WordPress site into an Astro 6 project. Fetches content via the WP REST API, transforms HTML to Markdown, downloads images, and scaffolds a complete Astro project with Tailwind v4.

Install

# Run directly with bun
bun packages/cli/src/cli.ts convert --url https://myblog.com

# Or build a binary
cd packages/cli && bun run build
./dist/wp2astro convert --url https://myblog.com

Usage

wp2astro convert --url <wordpress-url> [options]

Options

| Flag | Description | |------|-------------| | -u, --url <url> | WordPress site URL (required) | | -o, --output <dir> | Output directory (default: ./output) | | --no-images | Skip downloading images | | --scaffold | Scrape site design, print styling prompt for /elite-style | | -h, --help | Show help | | -v, --version | Show version |

Examples

# Basic conversion
wp2astro convert --url https://myblog.com

# Custom output directory
wp2astro convert --url https://myblog.com --output ./my-astro-site

# Skip images
wp2astro convert --url https://myblog.com --no-images

# Convert + generate styling prompt
wp2astro convert --url https://myblog.com --scaffold

What it does

Convert pipeline

  1. Probe — checks the site has a WP REST API (/wp-json)
  2. Fetch — pulls posts, pages, and custom post types via REST API. Falls back to scraping the live page if API content is empty
  3. Media — resolves gallery shortcodes, fetches post attachments, downloads images to public/images/
  4. Transform — processes shortcodes, converts HTML to Markdown, rewrites links, builds frontmatter with categories/tags/hero images
  5. Generate — scaffolds Astro 6 project with Tailwind v4, content collections, layouts, and _redirects

--scaffold flag

Scrapes the live WordPress site to extract design data, then prints a markdown prompt to stdout. The prompt includes:

  • Color palette — CSS custom properties and declarations from :root/body, including WP preset vars (--wp--preset--color--primary)
  • Typography — Google Fonts links, @font-face declarations, body/heading font families. Fonts are mapped to Fontsource packages where possible, with CDN fallback
  • Navigation — tries WP REST API menu endpoints first (/wp/v2/menu-items), falls back to scraping <nav> elements from HTML
  • Layout — sidebar detection and position, hero section detection
  • Page types — classifies homepage (landing vs blog listing), posts, pages

Using with Claude Code

The recommended workflow for a full WordPress-to-Astro migration:

Step 1: Convert content

Ask Claude Code to run the CLI:

Convert my WordPress site at https://myblog.com to Astro.
Run: bun packages/cli/src/cli.ts convert --url https://myblog.com --scaffold --output ./my-site

This produces:

  • A working Astro project at ./my-site with all content as Markdown files
  • A scaffold prompt printed to stdout with the site's design data

Step 2: Style with /elite-style

Copy the scaffold prompt output, paste it into Claude Code, and run /elite-style. The prompt contains everything the AI needs:

  • Color palette with hex values
  • Font families with pnpm add @fontsource/... install commands
  • Full nav menu structure
  • Layout type (full-width, sidebar-left, sidebar-right)
  • Page types with hero/sidebar indicators
  • File paths to modify

Claude Code generates styled Astro components:

  • src/components/Header.astro — site header with navigation
  • src/components/Footer.astro — site footer
  • src/layouts/BaseLayout.astro — base layout
  • src/layouts/PostLayout.astro — single post layout
  • src/pages/index.astro — landing page
  • src/styles/global.css — Tailwind @theme tokens

Step 3: Review and deploy

cd my-site
pnpm install
pnpm dev        # Preview at localhost:4321
pnpm build      # Build for production

Deploy to Cloudflare Pages, Vercel, Netlify, or any static host. Redirects from old WordPress URLs are generated in _redirects.

Architecture

packages/cli/src/
  cli.ts                    # Entry point
  types.ts                  # Shared interfaces
  commands/
    convert.ts              # Main conversion orchestration
    help.ts                 # Help text
  sources/
    rest-api.ts             # WP REST API client + scrape fallback
  transform/
    pipeline.ts             # Transform orchestrator
    shortcodes.ts           # WordPress shortcode processing
    images.ts               # Image download + URL rewriting
    html-to-markdown.ts     # Turndown config
    links.ts                # URL mapping + redirects
    frontmatter.ts          # YAML frontmatter serializer
  generate/
    project.ts              # Astro project scaffolding
    content.ts              # Write .md content files
    redirects.ts            # _redirects file
    comments.ts             # Comments JSON export
    templates.ts            # Astro template strings
  scrape/
    index.ts                # Scrape orchestrator
    fetcher.ts              # Page fetcher with timeout
    extract-colors.ts       # CSS color extraction
    extract-fonts.ts        # Font detection + Fontsource mapping
    extract-nav.ts          # Nav extraction (API + HTML)
    extract-layout.ts       # Sidebar + hero detection
    analyze-pages.ts        # Page type classification
    prompt.ts               # Scaffold prompt generator
  utils/
    args.ts                 # CLI argument parser
    spinner.ts              # Terminal spinner
    progress.ts             # Progress bar
    colors.ts               # ANSI colors

Development

# Run tests
bun test

# Run CLI in dev
bun run dev -- convert --url https://example.com

# Build binary
bun run build

Dependencies

  • node-html-parser — HTML parsing for scraping fallback and design extraction
  • turndown — HTML to Markdown conversion
  • Bun — runtime, test runner, and bundler