Skip to content

Commit 9b3fd46

Browse files
committed
First version of feed generation
1 parent e620cb1 commit 9b3fd46

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

modules/blog.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import MarkdownItAnchor from 'markdown-it-anchor'
66
import { defu } from 'defu'
77
import { read } from 'gray-matter'
88
import { array, safeParse } from 'valibot'
9+
import { Feed } from 'feed'
910
import {
1011
AuthorSchema,
1112
RawBlogPostSchema,
@@ -159,6 +160,7 @@ export default defineNuxtModule({
159160
const resolver = createResolver(import.meta.url)
160161
const blogDir = resolver.resolve('../app/pages/blog')
161162
const blogImagesDir = resolver.resolve('../public/blog/avatar')
163+
const publicDir = resolver.resolve('../public')
162164
const resolveAvatars = !nuxt.options._prepare
163165

164166
nuxt.options.extensions.push('.md')
@@ -221,5 +223,52 @@ export default defineNuxtModule({
221223
}
222224
}
223225
}
226+
227+
// Generate content for RSS, Atom and JSON feeds
228+
const feed = new Feed({
229+
title: 'Blog - npmx',
230+
description: 'a fast, modern browser for the npm registry',
231+
id: 'https://npmx.dev/',
232+
link: 'https://npmx.dev/',
233+
language: 'en',
234+
image: 'https://npmx.dev/logo.svg',
235+
favicon: 'https://npmx.dev/favicon.ico',
236+
feedLinks: {
237+
rss: 'https://npmx.dev/rss.xml',
238+
atom: 'https://npmx.dev/atom.xml',
239+
json: 'https://npmx.dev/feed.json',
240+
},
241+
})
242+
243+
allPosts
244+
.filter(post => !post.draft)
245+
.forEach(post => {
246+
feed.addItem({
247+
title: post.title,
248+
id: new URL(post.path, 'https://npmx.dev').toString(),
249+
link: new URL(post.path, 'https://npmx.dev').toString(),
250+
description: post.description,
251+
author: post.authors.map(author => ({
252+
name: author.name,
253+
link: author.profileUrl ?? undefined,
254+
// author.avatar is a relative URL - make it absolute to work in feed readers
255+
avatar: author.avatar
256+
? new URL(author.avatar, 'https://npmx.dev').toString()
257+
: undefined,
258+
})),
259+
date: new Date(post.date),
260+
image: post.image,
261+
})
262+
})
263+
264+
const rssPath = 'rss.xml'
265+
const atomPath = 'atom.xml'
266+
const jsonFeedPath = 'feed.json'
267+
268+
await Promise.all([
269+
writeFile(join(publicDir, rssPath), feed.rss2()),
270+
writeFile(join(publicDir, atomPath), feed.atom1()),
271+
writeFile(join(publicDir, jsonFeedPath), feed.json1()),
272+
])
224273
},
225274
})

public/atom.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<feed xmlns="http://www.w3.org/2005/Atom">
3+
<id>https://npmx.dev/</id>
4+
<title>Blog - npmx</title>
5+
<updated>2026-04-17T22:49:22.656Z</updated>
6+
<generator>https://github.com/jpmonette/feed</generator>
7+
<link rel="alternate" href="https://npmx.dev/"/>
8+
<link rel="self" href="https://npmx.dev/atom.xml"/>
9+
<subtitle>a fast, modern browser for the npm registry</subtitle>
10+
<logo>https://npmx.dev/logo.svg</logo>
11+
<icon>https://npmx.dev/favicon.ico</icon>
12+
<entry>
13+
<title type="html"><![CDATA[npmx 0.8: npm at your fingertips]]></title>
14+
<id>https://npmx.dev/blog/release/0.8</id>
15+
<link href="https://npmx.dev/blog/release/0.8"/>
16+
<link rel="enclosure" href="https://npmx.dev/blog/og/release-0_8.png" type="image/png"/>
17+
<updated>2026-04-08T00:00:00.000Z</updated>
18+
<summary type="html"><![CDATA[Today we're releasing npmx 0.8 – including a new command palette and a lot of other features.]]></summary>
19+
<author>
20+
<name>Alex Savelyev</name>
21+
<uri>https://bsky.app/profile/alexdln.com</uri>
22+
</author>
23+
<author>
24+
<name>Philippe Serhal</name>
25+
<uri>https://bsky.app/profile/philippeserhal.com</uri>
26+
</author>
27+
<author>
28+
<name>Matias Capeletto</name>
29+
<uri>https://bsky.app/profile/patak.cat</uri>
30+
</author>
31+
</entry>
32+
<entry>
33+
<title type="html"><![CDATA[Announcing npmx: a fast, modern browser for the npm registry]]></title>
34+
<id>https://npmx.dev/blog/alpha-release</id>
35+
<link href="https://npmx.dev/blog/alpha-release"/>
36+
<updated>2026-03-03T00:00:00.000Z</updated>
37+
<summary type="html"><![CDATA[Today we're releasing the alpha of npmx.dev – a fast, modern browser for the npm registry, built in the open by a growing community.]]></summary>
38+
<author>
39+
<name>Daniel Roe</name>
40+
<uri>https://bsky.app/profile/danielroe.dev</uri>
41+
</author>
42+
<author>
43+
<name>Salma Alam-Naylor</name>
44+
<uri>https://bsky.app/profile/whitep4nth3r.com</uri>
45+
</author>
46+
<author>
47+
<name>Matias Capeletto</name>
48+
<uri>https://bsky.app/profile/patak.cat</uri>
49+
</author>
50+
</entry>
51+
</feed>

public/feed.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "https://jsonfeed.org/version/1",
3+
"title": "Blog - npmx",
4+
"home_page_url": "https://npmx.dev/",
5+
"feed_url": "https://npmx.dev/feed.json",
6+
"description": "a fast, modern browser for the npm registry",
7+
"icon": "https://npmx.dev/logo.svg",
8+
"items": [
9+
{
10+
"id": "https://npmx.dev/blog/release/0.8",
11+
"content_html": "Today we're releasing npmx 0.8 – including a new command palette and a lot of other features.",
12+
"url": "https://npmx.dev/blog/release/0.8",
13+
"title": "npmx 0.8: npm at your fingertips",
14+
"image": "https://npmx.dev/blog/og/release-0_8.png",
15+
"date_modified": "2026-04-08T00:00:00.000Z",
16+
"author": {
17+
"name": "Alex Savelyev",
18+
"url": "https://bsky.app/profile/alexdln.com",
19+
"avatar": "https://npmx.dev/blog/avatar/fddf886ba49fb30b34a112b568bcde6ab69dcc98338f65078829f2669a16ab4d.png"
20+
}
21+
},
22+
{
23+
"id": "https://npmx.dev/blog/alpha-release",
24+
"content_html": "Today we're releasing the alpha of npmx.dev – a fast, modern browser for the npm registry, built in the open by a growing community.",
25+
"url": "https://npmx.dev/blog/alpha-release",
26+
"title": "Announcing npmx: a fast, modern browser for the npm registry",
27+
"date_modified": "2026-03-03T00:00:00.000Z",
28+
"author": {
29+
"name": "Daniel Roe",
30+
"url": "https://bsky.app/profile/danielroe.dev",
31+
"avatar": "https://npmx.dev/blog/avatar/0709998e7d231e3c275df3f594b0f66a3f860369e6d8de5cd09247295e939d66.png"
32+
}
33+
}
34+
]
35+
}

public/rss.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
3+
<channel>
4+
<title>Blog - npmx</title>
5+
<link>https://npmx.dev/</link>
6+
<description>a fast, modern browser for the npm registry</description>
7+
<lastBuildDate>Fri, 17 Apr 2026 22:49:22 GMT</lastBuildDate>
8+
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
9+
<generator>https://github.com/jpmonette/feed</generator>
10+
<language>en</language>
11+
<image>
12+
<title>Blog - npmx</title>
13+
<url>https://npmx.dev/logo.svg</url>
14+
<link>https://npmx.dev/</link>
15+
</image>
16+
<atom:link href="https://npmx.dev/rss.xml" rel="self" type="application/rss+xml"/>
17+
<item>
18+
<title><![CDATA[npmx 0.8: npm at your fingertips]]></title>
19+
<link>https://npmx.dev/blog/release/0.8</link>
20+
<guid isPermaLink="false">https://npmx.dev/blog/release/0.8</guid>
21+
<pubDate>Wed, 08 Apr 2026 00:00:00 GMT</pubDate>
22+
<description><![CDATA[Today we're releasing npmx 0.8 – including a new command palette and a lot of other features.]]></description>
23+
<author>Alex Savelyev</author>
24+
<author>Philippe Serhal</author>
25+
<author>Matias Capeletto</author>
26+
<enclosure url="https://npmx.dev/blog/og/release-0_8.png" length="0" type="image/png"/>
27+
</item>
28+
<item>
29+
<title><![CDATA[Announcing npmx: a fast, modern browser for the npm registry]]></title>
30+
<link>https://npmx.dev/blog/alpha-release</link>
31+
<guid isPermaLink="false">https://npmx.dev/blog/alpha-release</guid>
32+
<pubDate>Tue, 03 Mar 2026 00:00:00 GMT</pubDate>
33+
<description><![CDATA[Today we're releasing the alpha of npmx.dev – a fast, modern browser for the npm registry, built in the open by a growing community.]]></description>
34+
<author>Daniel Roe</author>
35+
<author>Salma Alam-Naylor</author>
36+
<author>Matias Capeletto</author>
37+
</item>
38+
</channel>
39+
</rss>

0 commit comments

Comments
 (0)