Skip to content

Commit 2d7fd48

Browse files
committed
Added changlog RSS feed
1 parent 69e90ed commit 2d7fd48

File tree

5 files changed

+154
-1
lines changed

5 files changed

+154
-1
lines changed

content/changelog/CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# Change Log
22

3-
## [10.7.0] - 2024-xx-xx
3+
## [10.8.0] - 2025-02-xx
4+
5+
### ✨ New features
6+
7+
### 🎨 Enhancements
8+
9+
- [#915](https://github.com/estruyf/vscode-front-matter/issues/915): Added a new setting `frontMatter.panel.openOnSupportedFile` which allows you to open the panel view on supported files
10+
- [#921](https://github.com/estruyf/vscode-front-matter/issues/921): Improve the filename sanitization
11+
12+
### ⚡️ Optimizations
13+
14+
### 🐞 Fixes
15+
16+
- Fix for media folder parsing on Windows
17+
- Refresh button was not available on the media dashboard when having custom scripts defined
18+
- [#909](https://github.com/estruyf/vscode-front-matter/issues/909): Schema fix for the view modes
19+
- [#913](https://github.com/estruyf/vscode-front-matter/issues/913): Fix for relative media paths in page bundles
20+
- [#914](https://github.com/estruyf/vscode-front-matter/issues/914): Fix sanitizing of default filenames with an `_` in it
21+
22+
## [10.7.0] - 2024-12-31 - [Release notes](https://beta.frontmatter.codes/updates/v10.7.0)
423

524
### 🎨 Enhancements
625

package-lock.json

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"remark-heading-id": "1.0.0",
4747
"remark-parse": "^11.0.0",
4848
"remark-rehype": "^11.0.0",
49+
"rss": "^1.2.2",
4950
"scroll-out": "^2.2.12",
5051
"shiki": "^0.14.5",
5152
"unified": "^11.0.4",
@@ -59,6 +60,7 @@
5960
"@types/node-fetch": "^2.5.12",
6061
"@types/react": "^18.0.26",
6162
"@types/react-dom": "^18.0.9",
63+
"@types/rss": "^0.0.32",
6264
"autoprefixer": "^10.3.3",
6365
"eslint": "^7.32.0",
6466
"eslint-config-next": "^14.1.0",

pages/_document.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MyDocument extends Document {
1818
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
1919
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
2020
<link rel="manifest" href="/site.webmanifest" />
21+
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="/api/rss" />
2122

2223
<script async src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} />
2324
<script dangerouslySetInnerHTML={{

pages/api/rss.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { promises as fs } from 'fs';
2+
import { NextApiRequest, NextApiResponse } from 'next';
3+
import path from 'path';
4+
import RSS from 'rss';
5+
import { publicUrl } from '../../lib/publicUrl';
6+
import matter from 'gray-matter';
7+
8+
9+
const rssFeed = async function (_: NextApiRequest, res: NextApiResponse) {
10+
const feed = new RSS({
11+
title: 'Changelog RSS Feed',
12+
description: 'RSS feed for the changelog pages',
13+
feed_url: `${publicUrl()}/api/rss`,
14+
site_url: publicUrl(),
15+
language: 'en',
16+
});
17+
18+
const changelogDir = path.join(process.cwd(), 'content/changelog');
19+
const files = await fs.readdir(changelogDir);
20+
21+
const items: RSS.ItemOptions[] = [];
22+
for (const file of files) {
23+
const filePath = path.join(changelogDir, file);
24+
const content = await fs.readFile(filePath, 'utf8');
25+
const { data, content: markdownContent } = matter(content);
26+
27+
if (!data.title) {
28+
continue;
29+
}
30+
31+
items.push({
32+
title: data.title,
33+
description: markdownContent,
34+
url: `${publicUrl()}/changelog/${file.replace('.md', '')}`,
35+
date: data.date,
36+
});
37+
}
38+
39+
// Sort items by date
40+
items.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
41+
42+
items.forEach((item) => {
43+
feed.item(item);
44+
});
45+
46+
res.setHeader('Content-Type', 'application/rss+xml');
47+
res.status(200).send(feed.xml({ indent: true }));
48+
};
49+
50+
export default rssFeed;

0 commit comments

Comments
 (0)