diff --git a/actaddmanual/index.js b/actaddmanual/index.js index b23feca..26da3b1 100644 --- a/actaddmanual/index.js +++ b/actaddmanual/index.js @@ -1,18 +1,18 @@ const replacements = new Map(); replacements.set(/([^<]*)/g, function (content) { - return `${content}` + return `${content}`; }); replacements.set(/([^<]*)/g, function (content) { - return `${content}` + return `${content}`; }); replacements.set(//g, function (_content) { - return "
" + return "
"; }); replacements.set(/([^<]*)/g, function (content) { - return `${content}` + return `${content}`; }); replacements.set(/([^<]*)/g, function (content) { - return `${content}` + return `${content}`; }); $.ajax({ @@ -47,7 +47,7 @@ function populateManual(lang) { } sidebar.append("
"); - sidebar.append(`Main Site`) + sidebar.append(`Main Site`); sidebar.append(`Impressum`); sidebar.append(`Privacy`); sidebar.append(`© Ellpeck`); @@ -58,8 +58,9 @@ function populateManual(lang) { function replaceFormatting(text) { for (let [k, v] of replacements.entries()) { + const finalV = v; text = text.replace(k, function (_substring, group) { - return v(group); + return finalV(group); }); } return text; diff --git a/node/blog.js b/node/blog.js index a5f83fc..e5c671e 100644 --- a/node/blog.js +++ b/node/blog.js @@ -4,7 +4,7 @@ const { const fs = require("fs"); const converter = require("./showdown")(2); -let folder = `${__dirname}/../`; +const folder = `${__dirname}/../`; console.log("Refreshing blog sub-sites..."); fs.readFile(`${folder}index.html`, function (_, html) { @@ -22,12 +22,15 @@ fs.readFile(`${folder}index.html`, function (_, html) { if (element.href && element.href.startsWith("./")) element.href = `../${element.href.substring(2)}`; } - let template = templateDom.serialize(); + const template = templateDom.serialize(); fs.readFile(`${folder}blog/src/posts.json`, function (_, data) { - let json = JSON.parse(data.toString()); + const json = JSON.parse(data.toString()); for (let i = 0; i < json.length; i++) { - let post = json[i]; + const post = json[i]; + const index = i; + const last = getAdjacentPost(json, index, -1); + const next = getAdjacentPost(json, index, 1); fs.readFile(`${folder}blog/src/${post.id}.md`, function (_, content) { let dom = new JSDOM(template); let document = dom.window.document; @@ -37,8 +40,6 @@ fs.readFile(`${folder}index.html`, function (_, html) { document.querySelector('meta[name="description"]').setAttribute("content", post.summary); document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary); - let last = getAdjacentPost(json, i, -1); - let next = getAdjacentPost(json, i, 1); document.getElementById("nav-items").innerHTML = /*html*/ ` Back to Main Page ${last ? /*html*/ `Previous ${post.cat} Post` : ""} diff --git a/node/rss.js b/node/rss.js index 1c9ebfc..4bb74bf 100644 --- a/node/rss.js +++ b/node/rss.js @@ -33,12 +33,13 @@ function createFeed(callback) { } }); + const finalCallback = callback; fs.readFile(`${__dirname}/../blog/src/posts.json`, function (_, data) { let json = JSON.parse(data); for (let i = json.length - 1; i >= 0; i--) { - let post = json[i]; - let date = new Date(post.date); - + 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()); feed.addItem({ @@ -55,8 +56,8 @@ function createFeed(callback) { if (feed.categories.indexOf(post.cat) < 0) feed.addCategory(post.cat); - if (i === 0) - callback(feed); + if (index === 0) + finalCallback(feed); }); } }); diff --git a/node/showdown.js b/node/showdown.js index e400bbd..07145b6 100644 --- a/node/showdown.js +++ b/node/showdown.js @@ -7,4 +7,4 @@ module.exports = function (headerLevel) { headerLevelStart: headerLevel, extensions: ["prettify", "footnotes"] }); -} \ No newline at end of file +}; \ No newline at end of file