Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 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
8e2b743
Merge remote-tracking branch 'origin/main' into rss
Kiwow Sep 21, 2026
05b96e8
Move feeds under /blog, remove JSON feed
Kiwow Sep 21, 2026
2785ff6
Assert feed body is nonempty
Kiwow Sep 22, 2026
251ddaa
Merge remote-tracking branch 'origin/main' into rss
Kiwow Sep 22, 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
17 changes: 17 additions & 0 deletions app/pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ useSeoMeta({
ogDescription: () => $t('blog.meta_description'),
twitterDescription: () => $t('blog.meta_description'),
})

useHead({
link: [
{
rel: 'alternate',
title: 'Blog - npmx',
type: 'application/rss+xml',
href: 'https://npmx.dev/blog/rss.xml',
},
{
rel: 'alternate',
title: 'Blog - npmx',
type: 'application/atom+xml',
href: 'https://npmx.dev/blog/atom.xml',
},
],
})
</script>

<template>
Expand Down
10 changes: 10 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ export default defineNuxtConfig({
'/recharging': { prerender: true },
'/pds': { isr: 86400 }, // revalidate daily
'/blog/**': { prerender: true },
'/blog/rss.xml': {
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/rss+xml' },
},
'/blog/atom.xml': {
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/atom+xml' },
},
'/noodles/**': { prerender: true },
'/sponsors': { prerender: true },
'/tools': { prerender: true },
Expand Down Expand Up @@ -276,6 +282,10 @@ export default defineNuxtConfig({
esbuild: {
options: {
target: 'es2024',
// HACK: Excluding node_modules is the default. Here, we exempt
// .cache/nuxt/.nuxt/blog/posts.ts from that so that #blog/posts can be
// imported, parsed and executed as TS in server/utils/feeds.ts by esbuild
exclude: /node_modules\/(?!\.cache\/nuxt\/\.nuxt\/blog\/posts\.ts)/,
},
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
rollupConfig: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"devalue": "6.0.0",
"eslint-plugin-regexp": "3.3.1",
"fast-check": "4.9.0",
"feed": "6.0.0",
"h3": "1.15.11",
"h3-next": "npm:h3@2.0.1-rc.26",
"knip": "6.37.0",
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions server/routes/blog/atom.xml.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getFeed } from '../../utils/feeds'

export default defineEventHandler(() => {
return getFeed().atom1()
})
5 changes: 5 additions & 0 deletions server/routes/blog/rss.xml.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getFeed } from '../../utils/feeds'

export default defineEventHandler(() => {
return getFeed().rss2()
})
40 changes: 40 additions & 0 deletions server/utils/feeds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Feed } from 'feed'
import { posts } from '#blog/posts'

const makeUrlAbsolute = (url: string) => new URL(url, 'https://npmx.dev').toString()

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

for (const post of posts.filter(p => !p.draft)) {
feed.addItem({
title: post.title,
id: makeUrlAbsolute(post.path),
link: makeUrlAbsolute(post.path),
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 ? makeUrlAbsolute(author.avatar) : undefined,
})),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
date: new Date(post.date),
image: post.image ? makeUrlAbsolute(post.image) : undefined,
})
}

return feed
}
52 changes: 52 additions & 0 deletions test/e2e/feeds.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect, test } from './test-utils'

test.describe('Blog feeds', () => {
test.describe('have alternate links and matching content types', () => {
const feeds = [
{
name: 'RSS',
contentType: 'application/rss+xml',
},
{
name: 'Atom',
contentType: 'application/atom+xml',
},
]

for (const feed of feeds) {
test(feed.name, async ({ page, goto }) => {
await goto('/blog', { waitUntil: 'domcontentloaded' })

const locator = page.locator(`link[rel='alternate'][type='${feed.contentType}']`).first()
await expect(locator).toHaveAttribute('href')

const href = await locator.getAttribute('href')
expect(href).not.toBeNull()

if (typeof href !== 'string') {
return
}

// href is an absolute link
expect(href.slice(0, 16)).toBe('https://npmx.dev')

const { contentType, corsHeader, body } = await page.evaluate(async feedHref => {
// Fetch the same path as in the alternate link
const url = feedHref.slice(16)
const response = await fetch(url)
return {
contentType: response.headers.get('Content-Type'),
corsHeader: response.headers.get('Access-Control-Allow-Origin'),
body: await response.text(),
}
}, href)

expect(contentType).toBe(feed.contentType)
expect(body.length).toBeGreaterThan(0)
// Make sure feeds are available to browser-based readers, see
// https://www.blogsareback.com/guides/enable-cors
expect(corsHeader).toBe('*')
Comment thread
coderabbitai[bot] marked this conversation as resolved.
})
}
})
})
Loading