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 {
Feed
} = require("feed");
const {
JSDOM
} = require("jsdom");
const fs = require("fs");
const converter = require("./showdown")(1);
@ -40,13 +43,24 @@ function createFeed(callback) {
const post = json[i];
const date = new Date(post.date);
const index = i;
fs.readFile(`${__dirname}/../blog/src/${post.id}.md`, function (_, content) {
let html = converter.makeHtml(content.toString());
let extension = post.book ? "html" : "md";
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({
title: `${post.name}${post.archived ? " (Archived)" : ""}`,
link: `https://ellpeck.de/blog/${post.id}`,
description: post.summary,
content: html,
content: content,
date: date,
published: date,
category: post.cat.map(c => ({

View file

@ -42,4 +42,10 @@ h6 {
margin-top: 1em;
margin-bottom: 1em;
font-weight: bold;
}
@media (max-width: 768px) {
.list-display {
max-width: 35.5em;
}
}