tools: rss: extract feed

This commit is contained in:
He4eT 2023-12-09 09:38:48 +01:00
commit 734e6282e0
3 changed files with 17 additions and 14 deletions

View file

@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "site.config.js",
"type": "module",
"scripts": {
"build": "nanogen build",
"start": "nanogen start",

11
tools/rss-entries.js Normal file
View file

@ -0,0 +1,11 @@
export const feed = [[
'2021-10-02',
'https://oddsquat.org/1',
'Second Item Title',
'Use this for the content. It can include html.'
], [
'2021-10-01',
'https://oddsquat.org/2',
'First Item Title',
'Use this for the content. It can include html.'
]]

View file

@ -1,17 +1,8 @@
const feed = [[
'2021-10-02',
'http://example.com/article4?this&that',
'item title',
'use this for the content. It can include html.'
], [
'2021-10-01',
'http://example.com/arthat',
'another item title',
'another use this for the content. It can include html.'
]]
import rss from 'rss-generator'
import { feed } from './rss-entries.js'
const url = 'https://oddsquat.org'
const rssFeed = new (require('rss-generator'))({
const rssFeed = new rss({
title: 'oddsquat',
site_url: `${url}`,
feed_url: `${url}/rss.xml`,
@ -22,11 +13,11 @@ const rssFeed = new (require('rss-generator'))({
feed.forEach(([date, url, title, description]) =>
rssFeed.item({date, url, title, description}))
const fs = require('fs')
import { writeFile } from 'fs'
const RSS_FILEPATH =
'./src/assets/rss.xml'
void fs.writeFile(
void writeFile(
RSS_FILEPATH,
rssFeed.xml(),
err => err