2023-12-12 19:00:21 +01:00
|
|
|
///////////////////////////
|
|
|
|
// ADD THE CONTENT
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
let div = document.getElementById('main');
|
|
|
|
let divText = div.innerHTML;
|
|
|
|
|
|
|
|
console.log(divText);
|
|
|
|
|
2023-12-24 18:05:22 +01:00
|
|
|
let newPageHTML = `${pageTop}${divText}${pageBottom}`
|
2023-12-12 19:00:21 +01:00
|
|
|
document.body.innerHTML = newPageHTML //apply the template
|
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
// ADD THE LINKS
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
function escapeQuotes(value) {
|
|
|
|
return value.replace(/["'&<>]/g, function (char) {
|
|
|
|
switch (char) {
|
|
|
|
case '"':
|
|
|
|
return """;
|
|
|
|
case "'":
|
|
|
|
return "'";
|
|
|
|
case "&":
|
|
|
|
return "&";
|
|
|
|
case "<":
|
|
|
|
return "<";
|
|
|
|
case ">":
|
|
|
|
return ">";
|
|
|
|
default:
|
|
|
|
return char;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-12-22 00:11:45 +01:00
|
|
|
console.log(blogs)
|
2023-12-12 19:00:21 +01:00
|
|
|
let linksDiv = document.getElementById("links")
|
|
|
|
|
2023-12-24 03:45:02 +01:00
|
|
|
let linksText = "<li><a href='blogs/all.html'>ALL POSTS</a></li><br/>"
|
2023-12-12 19:00:21 +01:00
|
|
|
|
|
|
|
|
2023-12-24 03:45:02 +01:00
|
|
|
for (let page = blogs.length - 1; page >= 0; page--) {
|
2023-12-12 19:00:21 +01:00
|
|
|
console.log(length)
|
|
|
|
|
2023-12-24 03:45:02 +01:00
|
|
|
linksText += (`<li><a href='blogs/${page}.html'>${escapeQuotes(blogs[page][0])}</a></li>`)
|
2023-12-12 19:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("links").innerHTML = linksText;
|