feat: Add RSS 2.0 Feed
This commit is contained in:
31
package-lock.json
generated
31
package-lock.json
generated
@@ -27,6 +27,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cobe": "^0.6.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"feed": "^4.2.2",
|
||||
"framer-motion": "^11.3.24",
|
||||
"lucide-react": "^0.400.0",
|
||||
"next": "14.2.4",
|
||||
@@ -7780,6 +7781,18 @@
|
||||
"bser": "2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/feed": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/feed/-/feed-4.2.2.tgz",
|
||||
"integrity": "sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xml-js": "^1.6.11"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
@@ -13396,6 +13409,12 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz",
|
||||
"integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/scheduler": {
|
||||
"version": "0.23.2",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
|
||||
@@ -15453,6 +15472,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xml-js": {
|
||||
"version": "1.6.11",
|
||||
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sax": "^1.2.4"
|
||||
},
|
||||
"bin": {
|
||||
"xml-js": "bin/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cobe": "^0.6.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"feed": "^4.2.2",
|
||||
"framer-motion": "^11.3.24",
|
||||
"lucide-react": "^0.400.0",
|
||||
"next": "14.2.4",
|
||||
|
||||
81
src/app/feed.xml/route.ts
Normal file
81
src/app/feed.xml/route.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Feed } from "feed";
|
||||
import { releaseNoteIsAlpha, releaseNotes } from "@/lib/release-notes";
|
||||
import type { ReleaseNote } from "@/lib/release-notes";
|
||||
|
||||
export async function GET() {
|
||||
releaseNotes[0].date
|
||||
|
||||
const feed = new Feed({
|
||||
id: "https://www.zen-browser.app/release-notes",
|
||||
link: "https://www.zen-browser.app/release-notes",
|
||||
title: "Zen Browser Release Notes",
|
||||
description: "Release Notes for the Zen Browser",
|
||||
language: "en",
|
||||
favicon: "https://www.zen-browser.app/favicon.ico",
|
||||
copyright: `Zen Browser © ${new Date().getFullYear()} - Made with ❤️ by the Zen team.`,
|
||||
updated: formatRssDate(releaseNotes[0].date),
|
||||
});
|
||||
|
||||
for (const releaseNote of releaseNotes) {
|
||||
feed.addItem({
|
||||
title: `Release notes for version ${releaseNote.version}`,
|
||||
id: `https://www.zen-browser.app/release-notes/${releaseNote.version}`,
|
||||
link: `https://www.zen-browser.app/release-notes/${releaseNote.version}`,
|
||||
date: formatRssDate(releaseNote.date),
|
||||
description: releaseNote.extra,
|
||||
content: formatReleaseNote(releaseNote),
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(feed.rss2(), {
|
||||
headers: {
|
||||
'Content-Type': 'application/xml; charset=utf-8',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function formatRssDate(date: string) {
|
||||
// NOTE: This is assuming the format day/month/year. If release notes change to ISO format, this will need to be updated.
|
||||
const splitDate = date.split("/");
|
||||
const year = Number(splitDate[2]);
|
||||
const month = Number(splitDate[1]) - 1;
|
||||
const day = Number(splitDate[0]);
|
||||
return new Date(year, month, day);
|
||||
}
|
||||
|
||||
function formatReleaseNote(releaseNote: ReleaseNote) {
|
||||
let content = "<p>If you encounter any issues, please report them on <a href=\"https://github.com/zen-browser/desktop/issues/\">the issues page</a>. Thanks everyone for your feedback! ❤️</p>";
|
||||
|
||||
if(releaseNote.extra) {
|
||||
content += `<p>${releaseNote.extra.replace(/(\n)/g, "<br />")}</p>`
|
||||
}
|
||||
|
||||
if(releaseNote.breakingChanges) {
|
||||
content += `<h2>⚠️ Breaking changes</h2>`
|
||||
content += `<ul>`
|
||||
for (const breakingChange of releaseNote.breakingChanges) {
|
||||
content += `<li>${breakingChange}</li>`
|
||||
}
|
||||
content += `</ul>`
|
||||
}
|
||||
|
||||
if(releaseNote.features) {
|
||||
content += `<h2>⭐ Features</h2>`
|
||||
content += `<ul>`
|
||||
for (const feature of releaseNote.features) {
|
||||
content += `<li>${feature}</li>`
|
||||
}
|
||||
content += `</ul>`
|
||||
}
|
||||
|
||||
if(releaseNote.fixes) {
|
||||
content += `<h2>✓ Fixes</h2>`
|
||||
content += `<ul>`
|
||||
for (const fix of releaseNote.fixes) {
|
||||
content += `<li>${fix.description}</li>`
|
||||
}
|
||||
content += `</ul>`
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ export default function RootLayout({
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<head>
|
||||
<link rel="me" href="https://fosstodon.org/@zenbrowser"></link>
|
||||
<link rel="alternate" type="application/rss+xml" title="Zen Browser Release Notes" href="https://www.zen-browser.app/feed.xml" />
|
||||
</head>
|
||||
<body className={inter.className}>
|
||||
<ThemeProvider
|
||||
|
||||
Reference in New Issue
Block a user