Skip to content

quocthinhvo/ghost-paper

Repository files navigation

Ghost Paper

Ghost Paper is an automated Node.js tool that converts your Ghost CMS articles into stunning, magazine-style A3 PDF reports. It elegantly aggregates your existing web content into professional, readable physical layouts perfect for monthly, quarterly, or yearly archiving—or simply distributing as a standalone premium publication.

Features

  • Automated Magazine Layout: Automatically generates a professional 4-column layout resembling traditional broadsheet newspapers and magazines.
  • Dynamic Date Ranges: Supports fetching posts by Month (2026-03), Quarter (2026-Q1), and Year (2026).
  • Dynamic Open-Rate Cover Art: Scans email analytics via the Ghost Admin API and automatically uses the thumbnail from your highest-performing post as the cover image.
  • Member-Gated Content Supported: Bypasses public restrictions to pull full HTML payloads for premium, member-only posts.
  • Automated Table of Contents: Generates a clean two-column index tracking every post included in the edition.
  • Intelligent Flow & Styling: Implements continuous article flow to eliminate blank pages, automatic drop-caps, responsive media constraints, and Vietnamese Google Typography (Lora, Playfair Display, Inter).
  • Outro Subscription Call-to-Action: Appends a professional "Thank You" biography page to the end of your PDF encouraging readers to subscribe.

Prerequisites

  • Request Node.js v18+
  • Ghost CMS instance (Works with self-hosted or Ghost Pro)
  • A Ghost Admin API key.

Setup

  1. Clone this repository.
  2. Install dependencies:
    npm install
  3. Copy .env.example to .env:
    cp .env.example .env
  4. Fill in your Ghost API credentials in .env:
    GHOST_API_URL="https://your-site.ghost.io"
    GHOST_ADMIN_API_KEY="your_admin_api_key_here"  

Note: If no valid keys are provided, the script will automatically fallback to fetching placeholder data from the official demo.ghost.io sandbox.

Usage

Generate PDFs by passing your target time period as an argument. The generated PDF will be saved securely within the same directory.

Monthly Report

Fetches all articles for a specific month (Format: YYYY-MM).

node index.js 2026-03

Output: tong-hop-bai-viet-thang-3-2026.pdf

Quarterly Report

Fetches all articles for a specific quarter (Format: YYYY-QX).

node index.js 2026-Q1

Output: tong-hop-bai-viet-quy-1-2026.pdf

Yearly Compilation

Fetches all articles for an entire year (Format: YYYY).

node index.js 2025

Output: tong-hop-bai-viet-nam-2025.pdf

Built With

  • @tryghost/admin-api - Ghost CMS integration.
  • Puppeteer - Headless Chromium instance for generating flawless print PDFs.
  • EJS - Embedded JavaScript templating for the HTML blueprint.
  • date-fns - Robust modern date manipulation.

About

Converts your Ghost CMS articles into stunning, magazine-style A3 PDF reports

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors