made non-blog content be removed by html class instead of by regex
All checks were successful
Web/pipeline/head This commit looks good
All checks were successful
Web/pipeline/head This commit looks good
This commit is contained in:
parent
73cc32dc62
commit
fb7c50f3e5
2 changed files with 115 additions and 111 deletions
|
@ -83,7 +83,7 @@
|
|||
<script src="scripts/cookieinfo.js"></script>
|
||||
|
||||
<div id="main">
|
||||
<!-- NOBLOG -->
|
||||
<div class="no-blog">
|
||||
<!-- Home -->
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
|
@ -168,7 +168,7 @@
|
|||
</div>
|
||||
<script src="scripts/blog.js"></script>
|
||||
</div>
|
||||
<!-- /NOBLOG -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -182,7 +182,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- NOBLOG -->
|
||||
<div class="no-blog">
|
||||
<!-- Commissions -->
|
||||
<div class="modal fade" id="commissions-modal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
@ -215,7 +215,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /NOBLOG -->
|
||||
</div>
|
||||
|
||||
<!-- Impressum -->
|
||||
<div class="modal fade" id="impressum-modal" tabindex="-1">
|
||||
|
|
20
node/blog.js
20
node/blog.js
|
@ -7,23 +7,27 @@ const converter = require("./showdown")(2);
|
|||
let folder = __dirname + "/../";
|
||||
console.log("Refreshing blog sub-sites...");
|
||||
|
||||
fs.readFile(folder + "index.html", function (_, data) {
|
||||
// this can probably be done a lot easier but regex is hard ok
|
||||
var template = data.toString().replace(/<!-- ?NOBLOG ?-->([^](?!<!-- ?NOBLOG ?-->))*<!-- ?\/NOBLOG ?-->/g, "");
|
||||
fs.readFile(folder + "index.html", function (_, html) {
|
||||
let templateDom = new JSDOM(html);
|
||||
let noBlog = templateDom.window.document.getElementsByClassName("no-blog");
|
||||
while (noBlog.length > 0)
|
||||
noBlog[0].parentNode.removeChild(noBlog[0]);
|
||||
let template = templateDom.serialize();
|
||||
|
||||
fs.readFile(folder + "blog/posts.json", function (_, data) {
|
||||
let json = JSON.parse(data);
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
let post = json[i];
|
||||
fs.readFile(folder + "blog/" + post.id + ".md", function (_, content) {
|
||||
let dom = new JSDOM(template);
|
||||
var document = dom.window.document;
|
||||
let document = dom.window.document;
|
||||
|
||||
document.title += " - " + post.name;
|
||||
document.querySelector('meta[property="og:title"]').setAttribute("content", post.name);
|
||||
document.querySelector('meta[name="description"]').setAttribute("content", post.summary);
|
||||
document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary);
|
||||
|
||||
var nav = "";
|
||||
let nav = "";
|
||||
nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>';
|
||||
let last = getAdjacentPost(json, i, -1);
|
||||
if (last)
|
||||
|
@ -33,7 +37,7 @@ fs.readFile(folder + "index.html", function (_, data) {
|
|||
nav += '<a class="nav-item nav-link" href="/blog-' + next.id + '">Next Post</a>';
|
||||
document.getElementById("nav-items").innerHTML = nav;
|
||||
|
||||
var c = "";
|
||||
let c = "";
|
||||
c += '<div class="list-display rounded">';
|
||||
c += '<div class="blog-isolated">'
|
||||
c += '<h1>' + post.name + '</h1>';
|
||||
|
@ -48,8 +52,8 @@ fs.readFile(folder + "index.html", function (_, data) {
|
|||
c += '</div></div>';
|
||||
document.getElementById("main").innerHTML = c;
|
||||
|
||||
let html = dom.serialize();
|
||||
fs.writeFile(folder + "blog-" + post.id + ".html", html, function (_, _) {});
|
||||
let ret = dom.serialize();
|
||||
fs.writeFile(folder + "blog-" + post.id + ".html", ret, function (_, _) {});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue