fixed rss feed generator
All checks were successful
Web/pipeline/head This commit looks good

This commit is contained in:
Ell 2021-03-31 19:36:32 +02:00
parent 9270cf8bed
commit 798e8cd8e3
2 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,9 @@
const { const {
Feed Feed
} = require("feed"); } = require("feed");
const {
JSDOM
} = require("jsdom");
const fs = require("fs"); const fs = require("fs");
const converter = require("./showdown")(1); const converter = require("./showdown")(1);
@ -40,13 +43,24 @@ function createFeed(callback) {
const post = json[i]; const post = json[i];
const date = new Date(post.date); const date = new Date(post.date);
const index = i; const index = i;
fs.readFile(`${__dirname}/../blog/src/${post.id}.md`, function (_, content) { let extension = post.book ? "html" : "md";
let html = converter.makeHtml(content.toString()); fs.readFile(`${__dirname}/../blog/src/${post.id}.${extension}`, function (_, file) {
let content;
if (post.book) {
let html = new JSDOM(file);
let page = html.window.document.getElementById("page");
let header = page.getElementsByTagName("header");
while (header.length > 0)
header[0].parentNode.removeChild(header[0]);
content = page.innerHTML;
} else {
content = converter.makeHtml(file.toString());
}
feed.addItem({ feed.addItem({
title: `${post.name}${post.archived ? " (Archived)" : ""}`, title: `${post.name}${post.archived ? " (Archived)" : ""}`,
link: `https://ellpeck.de/blog/${post.id}`, link: `https://ellpeck.de/blog/${post.id}`,
description: post.summary, description: post.summary,
content: html, content: content,
date: date, date: date,
published: date, published: date,
category: post.cat.map(c => ({ category: post.cat.map(c => ({

View file

@ -43,3 +43,9 @@ h6 {
margin-bottom: 1em; margin-bottom: 1em;
font-weight: bold; font-weight: bold;
} }
@media (max-width: 768px) {
.list-display {
max-width: 35.5em;
}
}