mirror of
https://github.com/He4eT/oddsquat.git
synced 2026-05-04 20:37:22 +00:00
rss: feed generator
This commit is contained in:
parent
344e433185
commit
1025d5e3f2
1 changed files with 34 additions and 0 deletions
34
rss.js
Normal file
34
rss.js
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
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.'
|
||||||
|
]]
|
||||||
|
|
||||||
|
const url = 'https://oddsquat.org'
|
||||||
|
const rssFeed = new (require('rss-generator'))({
|
||||||
|
title: 'oddsquat',
|
||||||
|
site_url: `${url}`,
|
||||||
|
feed_url: `${url}/rss.xml`,
|
||||||
|
image_url: `${url}/icon.svg'`,
|
||||||
|
description:
|
||||||
|
'Fanzine about experiments, code and other cyberpunk stuff'})
|
||||||
|
|
||||||
|
feed.forEach(([date, url, title, description]) =>
|
||||||
|
rssFeed.item({date, url, title, description}))
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const RSS_FILEPATH =
|
||||||
|
'./src/assets/rss.xml'
|
||||||
|
|
||||||
|
void fs.writeFile(
|
||||||
|
RSS_FILEPATH,
|
||||||
|
rssFeed.xml(),
|
||||||
|
err => err
|
||||||
|
? console.error(err)
|
||||||
|
: console.log(`Updated: ${RSS_FILEPATH}`))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue