-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abbf3ec
commit 79392ec
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.