feat: add RSS feed
This commit is contained in:
parent
06fa0502ae
commit
80b6656e38
9 changed files with 84 additions and 4 deletions
|
@ -18,6 +18,7 @@
|
|||
"@types/markdown-it": "^14.0.1",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/read-time-estimate": "^0.0.2",
|
||||
"@types/rss": "^0.0.32",
|
||||
"@types/tinycolor2": "^1.4.6",
|
||||
"elasticlunr": "^0.9.5",
|
||||
"eslint": "^8.56.0",
|
||||
|
@ -41,6 +42,7 @@
|
|||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.1.0",
|
||||
"remark-supersub": "^1.0.0",
|
||||
"rss": "^1.2.2",
|
||||
"simple-icons": "^11.13.0",
|
||||
"tinycolor2": "^1.6.0",
|
||||
"tsup": "^8.0.2",
|
||||
|
|
|
@ -3,4 +3,5 @@ export const outPath = "./dist" // path to the json database
|
|||
|
||||
export const contentDirectoryPath = `${outPath}/content`
|
||||
export const mapFilePath = `${outPath}/map.json`
|
||||
export const rssFilePath = `${outPath}/rss.xml`
|
||||
export const searchIndexFilePath = `${outPath}/search.json`
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
|
||||
import fs from "fs"
|
||||
|
||||
import { mapFilePath, markdownPath, outPath } from "./config"
|
||||
import { mapFilePath, markdownPath, outPath, rssFilePath } from "./config"
|
||||
import { fillTags, parseSeries, sortDates } from "./postProcess"
|
||||
import { recursiveParse } from "./recursiveParse"
|
||||
import { buildFeed } from "./rss"
|
||||
import { saveIndex } from "./searchIndex"
|
||||
import type { ContentMap, SeriesMap } from "./types/types"
|
||||
import { ParseMode } from "./types/types"
|
||||
|
@ -66,6 +67,7 @@ async function main() {
|
|||
*/
|
||||
|
||||
fs.writeFileSync(mapFilePath, JSON.stringify(contentMap))
|
||||
fs.writeFileSync(rssFilePath, buildFeed(contentMap))
|
||||
saveIndex()
|
||||
}
|
||||
|
||||
|
|
26
packages/content/src/rss.ts
Normal file
26
packages/content/src/rss.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import RSS from "rss"
|
||||
|
||||
import type { ContentMap } from "./types/types"
|
||||
|
||||
export function buildFeed(contentMap: ContentMap): string {
|
||||
/* lets create an rss feed */
|
||||
const feed = new RSS({
|
||||
title: "pomp's blog",
|
||||
description: "developomp's blog",
|
||||
feed_url: "https://blog.developomp.com/rss.xml",
|
||||
site_url: "https://blog.developomp.com",
|
||||
image_url: "https://blog.developomp.com/favicon.svg",
|
||||
language: "en",
|
||||
pubDate: "May 20, 2012 04:00:00 GMT",
|
||||
})
|
||||
|
||||
for (const key in contentMap.posts)
|
||||
feed.item({
|
||||
title: contentMap.posts[key].title,
|
||||
description: contentMap.posts[key].title,
|
||||
url: `https://blog.developomp.com${key}`,
|
||||
date: contentMap.posts[key].date,
|
||||
})
|
||||
|
||||
return feed.xml()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue