Skip to content

Commit 07a7da0

Browse files
committed
Revert "Migrate RSS to public plugin"
This reverts commit b27a7ad.
1 parent b511c58 commit 07a7da0

File tree

4 files changed

+3289
-3960
lines changed

4 files changed

+3289
-3960
lines changed

apps/website/docs/.vitepress/config.mjs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { defineConfig } from 'vitepress';
2-
import { RssPlugin } from 'vitepress-plugin-rss';
3-
42
import { createSidebar } from './sidebar_creator.mjs';
3+
import { rss } from './rss.mjs';
54

65
const HOSTNAME = 'https://withease.effector.dev';
76

87
export default defineConfig({
8+
async buildEnd(config) {
9+
await rss.onBuildEnd(config, { hostname: HOSTNAME });
10+
},
911
ignoreDeadLinks: ['/feed.rss'],
1012
sitemap: {
1113
hostname: HOSTNAME,
@@ -228,21 +230,4 @@ export default defineConfig({
228230
],
229231
},
230232
},
231-
vite: {
232-
plugins: [
233-
RssPlugin({
234-
title: 'With Ease Magazine',
235-
description:
236-
'The collection of articles about Effector and related topics. It is not a replacement for the official documentation, but it can help you to understand some concepts better.',
237-
baseUrl: HOSTNAME,
238-
link: HOSTNAME,
239-
language: 'en',
240-
favicon: `${HOSTNAME}/favicon.ico`,
241-
copyright: 'Copyright (c) 2023-present, Igor Kamyşev',
242-
filter: (page) =>
243-
page.filepath.includes('/magazine/') &&
244-
page.frontmatter.rss !== false,
245-
}),
246-
],
247-
},
248233
});

apps/website/docs/.vitepress/rss.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import path from 'node:path';
2+
import { writeFile } from 'node:fs/promises';
3+
import { Feed } from 'feed';
4+
import { createContentLoader } from 'vitepress';
5+
import { compareAsc } from 'date-fns';
6+
7+
export const rss = {
8+
async onBuildEnd(config, { hostname }) {
9+
const feed = new Feed({
10+
title: 'With Ease Magazine',
11+
description:
12+
'The collection of articles about Effector and related topics. It is not a replacement for the official documentation, but it can help you to understand some concepts better.',
13+
id: hostname,
14+
link: hostname,
15+
language: 'en',
16+
favicon: `${hostname}/favicon.ico`,
17+
copyright: 'Copyright (c) 2023-present, Igor Kamyşev',
18+
});
19+
20+
const pages = await createContentLoader('/magazine/*.md', {
21+
excerpt: true,
22+
render: true,
23+
}).load();
24+
25+
const posts = pages.filter((page) => page.frontmatter.rss ?? true);
26+
27+
posts.sort((a, b) => compareAsc(b.frontmatter.date, a.frontmatter.date));
28+
29+
for (const { url, excerpt, frontmatter, html } of posts) {
30+
feed.addItem({
31+
title: frontmatter.title,
32+
id: `${hostname}${url}`,
33+
link: `${hostname}${url}`,
34+
description: excerpt,
35+
content: html,
36+
author: [],
37+
date: frontmatter.date,
38+
});
39+
}
40+
41+
await writeFile(path.join(config.outDir, 'feed.rss'), feed.rss2());
42+
},
43+
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"comment-parser": "^1.4.1",
2424
"effector": "23.0.0",
2525
"effector-vue": "23.0.0",
26-
"estree-walker": "^3.0.3",
26+
"feed": "^4.2.2",
2727
"glob": "^8.0.3",
2828
"i18next": "23.0.0",
2929
"markdown": "^0.5.0",
@@ -40,7 +40,6 @@
4040
"vite-plugin-dts": "^3.8.3",
4141
"vite-tsconfig-paths": "4.2.1",
4242
"vitepress": "1.3.1",
43-
"vitepress-plugin-rss": "^0.2.8",
4443
"vitest": "~1.5.0",
4544
"vue": "3.4.27",
4645
"vue-chartjs": "^5.3.1"
@@ -50,6 +49,7 @@
5049
"bytes": "^3.1.2",
5150
"lodash-es": "^4.17.21",
5251
"pretty-bytes": "^6.1.1",
52+
"date-fns": "^3.6.0",
5353
"sandpack-vue3": "^3.1.7"
5454
}
5555
}

0 commit comments

Comments
 (0)