Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e620cb1
Add feed package
Kiwow Apr 17, 2026
9b3fd46
First version of feed generation
Kiwow Apr 17, 2026
995a5bb
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 17, 2026
38fdefe
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Apr 17, 2026
764b2ac
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Apr 17, 2026
c8a0147
Remove generated files
Kiwow Apr 19, 2026
034ffd6
Don't generate files to /public
Kiwow Apr 19, 2026
021d241
Add prerendered endpoint for each feed type
Kiwow Apr 19, 2026
4ad82dc
Include link rel='alternate' on blog pages
Kiwow Apr 19, 2026
4f8a193
Get rid of unnecessary exports
Kiwow Apr 19, 2026
71390b1
Hack around the type error
Kiwow Apr 19, 2026
0feba05
Add e2e test that verifies links and file types
Kiwow Apr 19, 2026
cfdb1a5
Update locator usage
Kiwow Apr 19, 2026
74b2c73
Move header setting to nuxt config
Kiwow Apr 19, 2026
4d27065
Finish test
Kiwow Apr 19, 2026
453ceb5
Merge branch 'main' into rss
Kiwow Apr 19, 2026
1389051
Update comments
Kiwow Apr 19, 2026
9939025
Merge remote-tracking branch 'origin/main' into rss
Kiwow May 10, 2026
106d240
Simplify feed generation by not caching the object
Kiwow May 10, 2026
02dfcfa
Streamline absolute URLs
Kiwow May 10, 2026
aa540af
fix: Properly reinclude .nuxt/ route
Kiwow May 10, 2026
c5bfb69
Revert "fix: Properly reinclude .nuxt/ route"
Kiwow May 10, 2026
5a2c622
Fix comment
Kiwow May 10, 2026
f5e9f22
Capitalize A
Kiwow May 10, 2026
fca6411
fix: lint
Kiwow May 10, 2026
dfdfaef
Merge branch 'main' into rss
Kiwow May 10, 2026
607ee7c
Merge remote-tracking branch 'origin/main' into rss
Kiwow May 20, 2026
f9bf8c3
Merge remote-tracking branch 'origin/main' into rss
Kiwow May 31, 2026
28f7c03
Merge remote-tracking branch 'origin/main' into rss
Kiwow Jul 9, 2026
5ef6ebf
pnpm dedupe
Kiwow Jul 9, 2026
152028b
Update feed package
Kiwow Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions modules/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import MarkdownItAnchor from 'markdown-it-anchor'
import { defu } from 'defu'
import { read } from 'gray-matter'
import { array, safeParse } from 'valibot'
import { Feed } from 'feed'
import {
AuthorSchema,
RawBlogPostSchema,
Expand Down Expand Up @@ -159,6 +160,7 @@ export default defineNuxtModule({
const resolver = createResolver(import.meta.url)
const blogDir = resolver.resolve('../app/pages/blog')
const blogImagesDir = resolver.resolve('../public/blog/avatar')
const publicDir = resolver.resolve('../public')
const resolveAvatars = !nuxt.options._prepare

nuxt.options.extensions.push('.md')
Expand Down Expand Up @@ -221,5 +223,52 @@ export default defineNuxtModule({
}
}
}

// Generate content for RSS, Atom and JSON feeds
const feed = new Feed({
title: 'Blog - npmx',
description: 'a fast, modern browser for the npm registry',
id: 'https://npmx.dev/',
link: 'https://npmx.dev/',
language: 'en',
image: 'https://npmx.dev/logo.svg',
favicon: 'https://npmx.dev/favicon.ico',
feedLinks: {
rss: 'https://npmx.dev/rss.xml',
atom: 'https://npmx.dev/atom.xml',
json: 'https://npmx.dev/feed.json',
},
})

allPosts
.filter(post => !post.draft)
.forEach(post => {
feed.addItem({
title: post.title,
id: new URL(post.path, 'https://npmx.dev').toString(),
link: new URL(post.path, 'https://npmx.dev').toString(),
description: post.description,
author: post.authors.map(author => ({
name: author.name,
link: author.profileUrl ?? undefined,
// author.avatar is a relative URL - make it absolute to work in feed readers
avatar: author.avatar
? new URL(author.avatar, 'https://npmx.dev').toString()
: undefined,
})),
date: new Date(post.date),
image: post.image,
})
})

const rssPath = 'rss.xml'
const atomPath = 'atom.xml'
const jsonFeedPath = 'feed.json'

await Promise.all([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of saving these files to disk, creating pre-rendered server-side routes could be a cleaner approach 馃. Similar to server/routes/opensearch.xml.get.ts with https://nuxt.com/docs/4.x/getting-started/prerendering#selective-pre-rendering

@Kiwow Kiwow Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like exactly what I was looking for and didn't find. Thanks!

I'll add a mention of this to the PR description and look into it when I have time to work on this again.

writeFile(join(publicDir, rssPath), feed.rss2()),
writeFile(join(publicDir, atomPath), feed.atom1()),
writeFile(join(publicDir, jsonFeedPath), feed.json1()),
])
},
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"devalue": "5.6.4",
"eslint-plugin-regexp": "3.1.0",
"fast-check": "4.6.0",
"feed": "5.2.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

鈿狅笍 Potential issue | 馃煚 Major

馃З Analysis chain

馃弫 Script executed:

#!/bin/bash
# Confirm the feed package is only used behind prerendered routes and nowhere on a runtime path.
rg -nP "from ['\"]feed['\"]|require\(['\"]feed['\"]\)" --type=ts --type=js --type=vue
echo '---'
# Double-check no non-prerendered route imports getFeed
rg -nP -C2 "getFeed\s*\(" --type=ts

Repository: npmx-dev/npmx.dev

Length of output: 992


馃弫 Script executed:

# Check where feed is imported in feeds.ts
cat -n server/utils/feeds.ts | head -20

echo '=== Checking nuxt.config.ts for prerender settings ==='
# Search for prerender configurations for the feed routes
rg -nP "atom\.xml|rss\.xml|feed\.json" nuxt.config.ts

echo '=== Current package.json state for feed ==='
# Check where feed is currently placed in package.json
rg -nP -B2 -A2 '"feed":\s*"5\.2\.0"' package.json

echo '=== Searching for any other getFeed or feed imports ==='
# Broader search for any other getFeed invocations
rg -nP "getFeed" --type=ts

Repository: npmx-dev/npmx.dev

Length of output: 1513


馃弫 Script executed:

# View the prerender configuration for the feed routes in nuxt.config.ts
sed -n '193,210p' nuxt.config.ts

Repository: npmx-dev/npmx.dev

Length of output: 693


Move feed from devDependencies to dependencies for runtime safety.

feed is imported in server/utils/feeds.ts and used only by three routes (/rss.xml, /atom.xml, /feed.json), all of which have prerender: true in nuxt.config.ts. While this means the dependency is needed only at build time in a fully prerendered deploy, moving it to dependencies is recommended as a safer posture. If any of these routes ever fall back to runtime rendering鈥攕uch as an ISR fallback, dev preview in production mode, or a prerender failure served on-demand鈥擭itro's bundled output will reference feed at runtime and it will be missing in a --prod/--production install.

馃 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 136, Move the "feed" package from devDependencies to
dependencies in package.json so it is available at runtime; update package.json
by removing "feed": "5.2.0" from devDependencies and adding the same entry under
dependencies. This ensures imports in server/utils/feeds.ts (used by the
/rss.xml, /atom.xml and /feed.json routes with prerender: true) are present in
production builds and prevents runtime errors if those routes are ever rendered
on-demand.

"h3": "1.15.8",
"h3-next": "npm:h3@2.0.1-rc.16",
"knip": "6.0.5",
Expand Down
Loading
Loading