Skip to content

Instantly share code, notes, and snippets.

@DevloperHS
Last active November 14, 2025 10:17
Show Gist options
  • Select an option

  • Save DevloperHS/8003d766dd30185e76d5d0a5c0cbefbf to your computer and use it in GitHub Desktop.

Select an option

Save DevloperHS/8003d766dd30185e76d5d0a5c0cbefbf to your computer and use it in GitHub Desktop.
Hacker News Weekly Digest Automation

Fetch the top 10 latest news from Hacker News and create a professional HTML newsletter.

The newsletter should have:

  • A visually appealing design with Hacker News orange theme (#ff6600)
  • Full HTML structure with inline CSS styling
  • Each story formatted with:
    • Story title as H3 header
    • Timestamp showing when it was posted
    • Brief description/snippet from the article
    • Clickable link to the HN discussion thread
  • Professional styling with:
    • Clean typography (Arial/sans-serif)
    • Card-based layout for each story
    • Proper spacing and padding
    • Border accents using HN orange color
    • Mobile-friendly responsive design
  • Header section with newsletter title and date
  • Footer with branding

Send the HTML newsletter to my email address.

# Extract LLM output
text = items[0]["json"]["content"]["parts"][0]["text"]
# Remove escaped newlines
text = text.replace("\\n", "")
# Remove literal newlines
text = text.replace("\n", "")
# Clean whitespace
text = text.strip()
# Return ONLY one item but attach it to the first input
return [{
"json": {
"html": text
},
"pairedItem": {
"item": 0
}
}]
# extract specific fields
# store in dict & pair it with original - n8n specific
import json
output = []
for index, item in enumerate(items):
d = item.get("json", {})
cleaned = {
"title": d.get("title", ""),
"url": d.get("url", ""),
"author": d.get("author", ""),
"points": d.get("points", 0),
"comments": d.get("num_comments", 0),
"created_at": d.get("created_at", "")
}
output.append({
"json": cleaned,
"pairedItem": {
"item": index
}
})
return output
# parse the string into actua json dict
import json
stories = []
for item in items:
d = dict(item.get("json", {}))
stories.append({
"title": d.get("title", ""),
"url": d.get("url", ""),
"author": d.get("author", ""),
"points": d.get("points", 0),
"comments": d.get("comments", 0),
"created_at": d.get("created_at", "")
})
# Pretty-print for humans
pretty = json.dumps(stories, indent=2)
return [{
"json": {
"stories_raw": stories, # for eyes
"stories": pretty # for the LLM
}
}]

You will receive a JSON array called "stories".

Your job: Generate a clean, email-ready HTML digest.

Layout:

Hacker News Digest

Short intro sentence...

Then for each story:

TITLE

Author: AUTHOR

Points: POINTS  |  Comments: COMMENTS

Published: CREATED_AT

Read more

Rules:

  • Output ONLY HTML.
  • NO Markdown.
  • NO "\n".
  • NO "\".
  • Use actual HTML line breaks or paragraphs, not text newlines.
  • Every new line must be a real newline character, not "\n".
  • The output must be valid HTML.
  • After each story add a seperator using -----------

Published Field formatting rule:

When displaying the Published date/time, use this transformation:

  • Extract the date as the part before "T". Example: "2020-10-23".
  • Extract the time as the HH:MM portion only. Remove seconds and remove the trailing "Z". Example: "19:26:35Z" becomes "19:26".

Display it in this format:

Published: DATE at TIME

Here is the JSON array:

{{ $json.stories }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment