sub2mark-site
v1.0.0
Published
Generate a static site from a Substack publication using sub2mark-lib.
Maintainers
Readme
sub2mark-site
sub2mark-site generates a static site from a Substack publication using sub2mark-lib.
This tool pulls posts from the Substack RSS feed (falling back to the homepage if needed), converts each post to Markdown, and renders a lightweight static site with a homepage, per-post pages, and an About page. It also downloads the publication favicon and ships it along with some basic styling css and javascript in the generated assets/ folder.
Install
npm install sub2mark-siteLibrary Usage
import { buildSubstackSite } from 'sub2mark-site';
await buildSubstackSite('https://example.substack.com', {
outputDir: './site',
limit: 50,
update: false
});Options
outputDir(string): Output directory for the generated site (default:./site)limit(number): Limit the number of posts processedupdate(boolean): Only add new posts and leave existing posts/assets unchanged
CLI Usage
sub2mark-site https://example.substack.com --out ./site --limit 50Update mode (incremental):
sub2mark-site https://example.substack.com --out ./site --updateOutput
The generated folder is a static site with:
index.htmlhomepage listing postsabout/index.htmlbuilt from the Substack About pageposts/<slug>/index.htmlper-post pages with rendered Markdownposts/<slug>/post.mdthe original Markdownassets/shared CSS/JS (dark mode toggle + TOC) plusfavicon.*
The site/ folder can be hosted on GitHub Pages, Vercel, Cloudflare Pages, or any static host. It is, as said earlier, static and has no backend.
Note: Works only for free (i.e. non-paywalled) posts currently. For paywalled-posts, only the non-paywalled part is converted to markdown and to html, however small that part maybe.
Update Mode
When update/--update is enabled, the generator runs in incremental mode:
- It only adds brand-new posts that are not already present in
posts/. - It does not regenerate or modify existing post folders.
- It does not rewrite
index.htmlor theabout/page. - It does not overwrite
assets/(including the favicon). - If no new posts are found, it logs
No new posts found..
Requirements
- Node.js 18+
