Blog in development

This commit is contained in:
bingus_violet 2024-07-07 23:33:16 -05:00
parent 2b724bc2db
commit 7e52727bf0
12 changed files with 389 additions and 10 deletions

View file

@ -89,7 +89,20 @@ function highlighter(json, full = true) {
var element = json[i]
if (element.type == "element") {
if (element.children.length > 0) {
element.children = highlighter(element.children, full)
if (element.attributes) {
var valid = true
for (var x in element.attributes) {
var attribute = element.attributes[x]
if (attribute.key == "class" && attribute.value == "value") {
valid = false
break
}
}
}
if (valid) {
element.children = highlighter(element.children, full)
}
}
} else if (element.type == "text") {
var index = 0
@ -291,6 +304,26 @@ function converter(html, dynamic = true) {
}
return html
},
"BLOG_POSTS": () => {
var addedHTML = ""
for (var i in api.blogPosts) {
var post = api.blogPosts[i]
addedHTML +=
`<div class="post">
<a style="text-decoration: none;" href="./${post.folder}">
<h2>${post.title}</h2>
<p style="color: white; font-size: 1rem;">${post.desc}</p>
<p style="color: darkgray; font-size: 1rem;">Path: <span class="noHighlight">/${post.folder}/</span></p>
</a>
</div>`
}
if (!api.blogConnected) {
addedHTML += "<p>Not connected to blog server :(</p>"
} else if (addedHTML.length < 10) {
addedHTML += "<p>No blog posts found... <br>wait <br> huh ??? <br>what???????<br> how ???????????????<br> WHY ?!<br> Violet must've fucked up like. REALLY bad. <br> We're so cooked</p>"
}
return addedHTML
}
}
var realtimeReplacers = {
@ -389,14 +422,13 @@ module.exports = {
}
res.send(data)
} else {
res.status(404).send(`
<link rel="stylesheet" href="/style.css">
<h1>404</h1>
<p>Uh oh... I think your lost? There's nothing here :P</p>
`)
}
else {
next()
}
}
},
converter: converter
}
async function updateCommits() {
@ -438,6 +470,8 @@ pregenerate()
api.events.on("lanyardConnect", pregenerate)
api.events.on("blogUpdate", pregenerate)
api.events.on("lanyardUpdate", async () => {
if (!api.lanyard.activityChanged) {
pregenerate()