Skip to content

feat(examples): add with-medium-rss-blog - #98485

Open
alifarooqi wants to merge 2 commits into
vercel:canaryfrom
alifarooqi:add-medium-rss-blog-example
Open

feat(examples): add with-medium-rss-blog#98485
alifarooqi wants to merge 2 commits into
vercel:canaryfrom
alifarooqi:add-medium-rss-blog-example

Conversation

@alifarooqi

Copy link
Copy Markdown

What

Adds examples/with-medium-rss-blog — a focused Next.js App Router example showing how to render a blog backed by a user's Medium RSS feed, sanitized for safe HTML rendering and cached with ISR.

Why

Existing blog examples in this repo use local Markdown or MDX files:

  • blog-starter — local Markdown with remark
  • blog — Nextra (Markdown-focused)
  • blog-with-comment — local Markdown with Giscus

This one is different: post content lives on Medium, so users don't have to maintain a duplicate copy. Useful when the author already publishes on Medium and wants their Next.js site to mirror it.

How

  • lib/medium.ts fetches https://medium.com/feed/@<username> via rss-parser and normalizes each entry (title, content, summary, image, slug from canonical URL).
  • lib/medium-feed.json is an empty fallback snapshot, used when MEDIUM_USERNAME is unset or the network request fails, so the page never crashes on a fresh clone.
  • lib/sanitize.ts runs the feed HTML through isomorphic-dompurify with an explicit tag + attribute allowlist before render — no <script>, no event handlers, no inline styles, no data: URIs.
  • /blog and /blog/[slug] declare revalidate = 43200 (12h) so Vercel only re-fetches the feed twice a day.
  • generateStaticParams pre-renders one page per post at build time.

Diff stats

17 files changed, +506 / -0

Live demo

The same pattern runs in production at https://portfolio-blog-starter-two.vercel.app/blog — that's the full template; this example is a stripped-down version focused on the Medium RSS handling.

Configuration

Set MEDIUM_USERNAME in .env.local (no @). Leave empty to render an empty blog list (uses the committed fallback snapshot).

MEDIUM_USERNAME="your-handle"

🤖 Generated with Claude Code

Adds a focused App Router example showing how to render a blog backed by
a Medium RSS feed. Complements the existing blog-starter (which uses
local Markdown) and blog (which uses Nextra) — post content lives on
Medium, so users don't need to maintain a separate Markdown copy.

- lib/medium.ts fetches https://medium.com/feed/@<username> via rss-parser
  and normalizes each entry (title, content, summary, image, slug from
  the canonical URL)
- lib/medium-feed.json is an empty fallback snapshot, used when
  MEDIUM_USERNAME is unset or the network request fails, so the page
  never crashes on a fresh clone
- lib/sanitize.ts runs the feed HTML through isomorphic-dompurify with
  an explicit tag + attribute allowlist before render
- /blog and /blog/[slug] declare revalidate = 43200 (12h) so Vercel only
  re-fetches the feed twice a day
- generateStaticParams pre-renders one page per post at build time

Co-Authored-By: Claude Code <noreply@anthropic.com>
Comment thread examples/with-medium-rss-blog/tailwind.config.mjs Outdated
The Vercel review bot flagged that the `prose` / `dark:prose-invert`
classes on the rendered article would have no effect without the
`@tailwindcss/typography` plugin registered.

- Add @tailwindcss/typography ^0.5.15 to devDependencies
- Register the plugin in tailwind.config.mjs

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant