feat(examples): add with-medium-rss-blog - #98485
Open
alifarooqi wants to merge 2 commits into
Open
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withremarkblog— Nextra (Markdown-focused)blog-with-comment— local Markdown with GiscusThis 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.tsfetcheshttps://medium.com/feed/@<username>viarss-parserand normalizes each entry (title, content, summary, image, slug from canonical URL).lib/medium-feed.jsonis an empty fallback snapshot, used whenMEDIUM_USERNAMEis unset or the network request fails, so the page never crashes on a fresh clone.lib/sanitize.tsruns the feed HTML throughisomorphic-dompurifywith an explicit tag + attribute allowlist before render — no<script>, no event handlers, no inline styles, nodata:URIs./blogand/blog/[slug]declarerevalidate = 43200(12h) so Vercel only re-fetches the feed twice a day.generateStaticParamspre-renders one page per post at build time.Diff stats
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_USERNAMEin.env.local(no@). Leave empty to render an empty blog list (uses the committed fallback snapshot).MEDIUM_USERNAME="your-handle"🤖 Generated with Claude Code