mirror of
https://github.com/He4eT/oddsquat.git
synced 2026-05-04 20:37:22 +00:00
tools: rss: extract feed
This commit is contained in:
parent
956b06356b
commit
734e6282e0
3 changed files with 17 additions and 14 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "site.config.js",
|
"main": "site.config.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nanogen build",
|
"build": "nanogen build",
|
||||||
"start": "nanogen start",
|
"start": "nanogen start",
|
||||||
|
|
|
||||||
11
tools/rss-entries.js
Normal file
11
tools/rss-entries.js
Normal 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.'
|
||||||
|
]]
|
||||||
19
tools/rss.js
19
tools/rss.js
|
|
@ -1,17 +1,8 @@
|
||||||
const feed = [[
|
import rss from 'rss-generator'
|
||||||
'2021-10-02',
|
import { feed } from './rss-entries.js'
|
||||||
'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 url = 'https://oddsquat.org'
|
||||||
const rssFeed = new (require('rss-generator'))({
|
const rssFeed = new rss({
|
||||||
title: 'oddsquat',
|
title: 'oddsquat',
|
||||||
site_url: `${url}`,
|
site_url: `${url}`,
|
||||||
feed_url: `${url}/rss.xml`,
|
feed_url: `${url}/rss.xml`,
|
||||||
|
|
@ -22,11 +13,11 @@ const rssFeed = new (require('rss-generator'))({
|
||||||
feed.forEach(([date, url, title, description]) =>
|
feed.forEach(([date, url, title, description]) =>
|
||||||
rssFeed.item({date, url, title, description}))
|
rssFeed.item({date, url, title, description}))
|
||||||
|
|
||||||
const fs = require('fs')
|
import { writeFile } from 'fs'
|
||||||
const RSS_FILEPATH =
|
const RSS_FILEPATH =
|
||||||
'./src/assets/rss.xml'
|
'./src/assets/rss.xml'
|
||||||
|
|
||||||
void fs.writeFile(
|
void writeFile(
|
||||||
RSS_FILEPATH,
|
RSS_FILEPATH,
|
||||||
rssFeed.xml(),
|
rssFeed.xml(),
|
||||||
err => err
|
err => err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue