Added in the 'latest' command and display latest post in terminal boot

This commit is contained in:
Dan 2025-12-08 14:52:34 +00:00
parent 99e89f7e84
commit e58896cc52
5 changed files with 40 additions and 2 deletions

View file

@ -46,6 +46,15 @@ window.terminal.registerCommand("reload", "Reload the current page", () => {
// PAGE NAVIGATION
window.terminal.registerCommand(
"latest",
"View the latest post, regardles of section",
() => {
let latestPostLink = document.getElementById("latest-post-link");
window.location.href = latestPostLink.textContent;
},
);
// About command
window.terminal.registerCommand("about", "About this site", () => {
window.location.href = "/about/";

View file

@ -46,12 +46,29 @@ class TerminalShell {
this.scrollToBottom();
}
this.printHTML(" ");
// Get latest post info
let latestPostTitle = document.getElementById("latest-post-title");
let latestPostDate = document.getElementById("latest-post-date");
this.printHTML(
"<span class='info'>Latest Post: </span>" +
latestPostTitle.innerText +
" (" +
latestPostDate.innerText +
")",
);
this.printHTML(
"<span class='info'>&nbsp;- Type \"latest\" to view it.</span>",
);
this.printHTML("&nbsp;");
this.printHTML(
'<span class="info">Type "help" for available commands.</span>',
);
this.printHTML(
'<span class="warning">This site is under contstruction. There\'s nothing of interest here yet.</span>',
'<span class="warning">This site is under construction. There\'s nothing of interest here yet.</span>',
);
this.inputContainer.classList.remove("hidden");

View file

@ -22,6 +22,7 @@
border-radius: 5px;
background-color: black;
opacity: 0;
transition: opacity 0.3s ease;
}
.music:hover .music-text {

View file

@ -23,6 +23,10 @@ body {
position: relative;
}
.latest-post {
display: none;
}
@keyframes flicker {
0% {
opacity: 0.27861;

View file

@ -420,4 +420,11 @@ unix 3 [ ] STREAM CONNECTED 50896 /run/user/1000/bus
</div>
</div>
</div>
{{ end }}
{{ range first 1 (where .Site.RegularPages "Type" "posts") }}
<div id="latest-post">
<div id="latest-post-link">{{ .Permalink }}</div>
<div id="latest-post-title">{{ .Title }}</div>
<div id="latest-post-date">{{ .Date.Format "Jan 2, 2006" }}</div>
</div>
{{ end }} {{ end }}