post-newsletter
Post Newsletter Natively
Convert a Substack newsletter post into a native posthog.com markdown file under contents/newsletter/.
The user will provide a Substack URL: $ARGUMENTS
Step 1: Fetch and reference
Run these in parallel:
-
Fetch the newsletter content from Substack's API, not with WebFetch. WebFetch routes the page through a summarizing model that will usually refuse to reproduce a full article verbatim ("I can't reproduce the full text verbatim…") and hand back a summary instead — useless when the whole job is copying text exactly. Substack exposes the post as JSON with no auth:
curl -sL "https://newsletter.posthog.com/api/v1/posts/{substack-slug}" -o /tmp/post.jsonThe response includes
title,subtitle,post_date,cover_image, andbody_html— the article body as HTML. Writebody_htmlto a file and convert it to markdown with a script (unwrap Substack's<span>soup, turn<figure>blocks into image markers carrying both thesrcand the<figcaption>, and convert<a>to[text](href)). This gives you exact text, exact links, and image positions in one pass, and it doubles as the ground truth for Step 5.Keep the JSON and the converted markdown around — Step 3b and Step 5 both reuse them.