social media pipeline

blog HTML to carousel images in 4 steps

1
parse blog HTML
parse-blog.mjs
cheerio loads the HTML file and extracts content by CSS selectors. handles title, subtitle, prose sections (h2/h3/p/ul), FAQs, references, and metadata.
input
blogs/*.html (file path)
output
BlogContent JSON
{ title, subtitle, sections[], faqs[], references[] }
deps
cheerio (local only, no API)
cost
$0.00
2
generate slide plan
plan-slides.mjs
claude API generates a 4-6 slide carousel plan. each slide gets a purpose (hook/key-point/stat/faq/cta), headline (max 8 words), body text (max 25 words), and a visual concept description.
input
BlogContent JSON + slideCount + style guide
output
SlidePlan JSON
{ carousel_title, slides[{ headline, body, visual_concept }] }
API
Claude Sonnet 4.5
~2K output tokens
cost
~$0.01
3
generate image prompts
generate-prompts.mjs
claude API converts each slide's visual concept into a detailed, replicate-ready image prompt. prompts describe scenes only (no text baked in). text overlay data preserved separately for compositing.
input
SlidePlan JSON + style guide
output
ImagePrompt[]
{ prompt, negative_prompt, text_overlay }
API
Claude Sonnet 4.5
~3K output tokens
cost
~$0.01
4
generate images
generate-images.mjs
replicate API generates one image per slide. supports ideogram v3 (better photorealism) or flux 1.1 pro. images downloaded as PNGs to output directory. failures are logged and skipped.
input
ImagePrompt[] + output dir + model choice
output
slide-1.png ... slide-N.png
metadata.json (full pipeline data)
API
Replicate
Ideogram v3 or Flux 1.1 Pro
cost
~$0.08-0.12 per image
~$0.40-0.60 per carousel
~$0.50
total cost per blog
2
claude API calls
5
replicate images
~30s
pipeline runtime
usage
# full pipeline
node scripts/social/pipeline.mjs --blog blogs/traveling-with-peptides.html
# steps 1-3 only (no image cost)
node scripts/social/pipeline.mjs --blog blogs/traveling-with-peptides.html --skip-images
# use flux model instead
node scripts/social/pipeline.mjs --blog blogs/traveling-with-peptides.html --model flux