-
Notifications
You must be signed in to change notification settings - Fork 3
/
generateFeeds.js
44 lines (40 loc) · 1.4 KB
/
generateFeeds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import { Feed } from "feed";
import fs from 'fs'
import readData from "./readData";
import IncidentsRepo from './src/models/IncidentsRepo'
import UnresolvedIncidentBody from './src/components/UnresolvedIncidentBody';
export default async function() {
const feed = new Feed({
title: "DatoCMS Incident History",
id: "https://status.datocms.com/",
link: "https://status.datocms.com/history.atom",
updated: new Date(),
feedLinks: {
rss: "https://status.datocms.com/history.rss",
json: "https://status.datocms.com/history.json",
atom: "https://status.datocms.com/history.atom"
},
author: {
name: "DatoCMS",
link: "https://www.datocms.com/"
}
});
const { incidents: incidentsData } = readData();
const incidents = new IncidentsRepo(incidentsData);
incidents.all.forEach(incident => {
feed.addItem({
title: incident.name,
id: incident.slug,
link: `https://status.datocms.com/incidents/${incident.slug}/`,
content: ReactDOMServer.renderToStaticMarkup(
<UnresolvedIncidentBody incident={incident} />
),
date: incident.lastUpdate.date,
});
});
fs.writeFileSync('./dist/history.rss', feed.rss2(), 'utf8');
fs.writeFileSync('./dist/history.atom', feed.atom1(), 'utf8');
fs.writeFileSync('./dist/history.json', feed.json1(), 'utf8');
}