Skip to content

Commit

Permalink
Add RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Apr 11, 2024
1 parent abbf3ec commit 79392ec
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/website/docs/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineConfig } from 'vitepress';
import { createSidebar } from './sidebar_creator';
import { rss } from './rss';

export default defineConfig({
lang: 'en-US',
async buildEnd(config) {
await rss.onBuildEnd(config);
},
lang: 'en',
title: 'With Ease',
description:
'A set of libraries and recipes to make frontend development easier thanks to Effector',
Expand All @@ -19,7 +23,7 @@ export default defineConfig({
logo: '/logo.svg',
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2023-present Igor Kamyşev',
copyright: 'Copyright © 2023-present, Igor Kamyşev',
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/igorkamyshev/withease' },
Expand Down
45 changes: 45 additions & 0 deletions apps/website/docs/.vitepress/rss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import path from 'node:path';
import { writeFile } from 'node:fs/promises';
import { Feed } from 'feed';
import { createContentLoader } from 'vitepress';

export const rss = {
async onBuildEnd(config) {
const hostname = 'https://withease.pages.dev';

const feed = new Feed({
title: 'With Ease Magazine',
description:
'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.',
id: hostname,
link: hostname,
language: 'en',
favicon: `${hostname}/favicon.ico`,
copyright: 'Copyright (c) 2023-present, Igor Kamyşev',
});

const posts = await createContentLoader('/magazine/*.md', {
excerpt: true,
render: true,
}).load();

posts.sort(
(a, b) => +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date)
);

for (const { url, excerpt, frontmatter, html } of posts) {
console.log(rest);
feed.addItem({
title: frontmatter.title,
id: `${hostname}${url}`,
link: `${hostname}${url}`,
description: excerpt,
content: html,
author: [],
date: frontmatter.date,
});
}

await writeFile(path.join(config.outDir, 'feed.rss'), feed.rss2());
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"effector": "23.0.0",
"effector-vue": "23.0.0",
"eslint": "8.46.0",
"feed": "^4.2.2",
"glob": "^8.0.3",
"i18next": "23.0.0",
"nx": "16.5.x",
Expand Down
20 changes: 20 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 79392ec

Please sign in to comment.