feat: Implement series navigation box and integrate into article and page templates

This commit is contained in:
2026-03-18 23:57:34 +03:00
parent 972b9ab426
commit fd1d5682b3
7 changed files with 283 additions and 145 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
## Features & Content
- [ ] **Post Series Support** — Add a `series` front-matter field to automatically group related tutorials (e.g., "Buffer Overflows Part 1, 2, 3") and render a "Part N of X" navigation box.
- [x] **Post Series Support** — Add a `series` front-matter field to automatically group related tutorials (e.g., "Buffer Overflows Part 1, 2, 3") and render a "Part N of X" navigation box.
+45 -17
View File
@@ -1,4 +1,31 @@
// 404 Terminal Page
// Scoped custom properties switch with html.dark
.term-window {
// Dark mode values (default — site defaults to dark)
--tw-bg: #0d0d0d;
--tw-bar: #1c1c1c;
--tw-border: #2a2a2a;
--tw-text: #cdd6f4;
--tw-prompt: #10b981;
--tw-error: #f38ba8;
--tw-muted: #6c7086;
--tw-link: #89b4fa;
--tw-cursor: #10b981;
}
html:not(.dark) .term-window {
// Light mode: Catppuccin Latte palette
--tw-bg: #eff1f5;
--tw-bar: #e6e9ef;
--tw-border: #ccd0da;
--tw-text: #4c4f69;
--tw-prompt: #40a02b;
--tw-error: #d20f39;
--tw-muted: #7c7f93;
--tw-link: #1e66f5;
--tw-cursor: #40a02b;
}
.notfound-wrap {
min-height: 70dvh;
@@ -11,22 +38,23 @@
.term-window {
width: 100%;
max-width: 680px;
background: #0d0d0d;
background: var(--tw-bg);
border-radius: 10px;
border: 1px solid #2a2a2a;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
border: 1px solid var(--tw-border);
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
overflow: hidden;
font-family: var(--font-mono);
font-size: clamp(0.78rem, 1.5vw, 0.9rem);
transition: background-color 0.3s ease, border-color 0.3s ease;
}
.term-titlebar {
background: #1c1c1c;
background: var(--tw-bar);
padding: 0.7rem 1rem;
display: flex;
align-items: center;
gap: 0.75rem;
border-bottom: 1px solid #2a2a2a;
border-bottom: 1px solid var(--tw-border);
user-select: none;
}
@@ -50,48 +78,48 @@
flex: 1;
text-align: center;
font-size: 0.72rem;
color: #555;
color: var(--tw-muted);
letter-spacing: 0.03em;
}
.term-body {
padding: 1.5rem;
line-height: 1.65;
color: #cdd6f4;
color: var(--tw-text);
min-height: 260px;
}
.term-row {
display: flex;
align-items: baseline;
gap: 0.6ch;
gap: 0;
white-space: nowrap;
overflow: hidden;
}
.term-ps1 {
color: #10b981;
color: var(--tw-prompt);
flex-shrink: 0;
white-space: nowrap;
pointer-events: none;
}
.term-input {
color: #cdd6f4;
color: var(--tw-text);
overflow: hidden;
}
.term-out {
padding-left: 0;
margin-bottom: 0.9rem;
}
.term-out-error {
color: #f38ba8;
color: var(--tw-error);
}
.term-out-muted {
color: #6c7086;
color: var(--tw-muted);
margin-bottom: 0.9rem;
}
.term-out-ls {
@@ -101,17 +129,17 @@
margin-bottom: 0.9rem;
a {
color: #89b4fa;
color: var(--tw-link);
text-decoration: none;
font-weight: 500;
&::before {
content: '→ ';
color: #10b981;
color: var(--tw-prompt);
}
&:hover {
color: #10b981;
color: var(--tw-prompt);
text-decoration: underline;
}
}
@@ -121,7 +149,7 @@
display: inline-block;
width: 0.55em;
height: 1.1em;
background: #10b981;
background: var(--tw-cursor);
vertical-align: text-bottom;
animation: blink-cursor 1s step-end infinite;
margin-left: 0.15ch;
+92
View File
@@ -95,6 +95,98 @@
}
}
// ──────────────────────────────────────────
// Series Navigation Box
// ──────────────────────────────────────────
.series-nav {
background: var(--surface-color);
border: 1px solid var(--border-color);
border-left: 3px solid var(--accent-color);
border-radius: 12px;
padding: 1.25rem 1.5rem;
margin-bottom: 2rem;
}
.series-nav-header {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0.4rem 0.75rem;
margin-bottom: 1rem;
}
.series-nav-eyebrow {
font-family: var(--font-mono);
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--accent-color);
opacity: 0.8;
}
.series-nav-title {
font-weight: 600;
font-size: 0.95rem;
color: var(--heading-color, var(--text-color));
flex: 1;
}
.series-nav-badge {
font-family: var(--font-mono);
font-size: 0.75rem;
color: var(--text-muted);
background: var(--bg-color);
border: 1px solid var(--border-color);
border-radius: 99px;
padding: 0.1em 0.6em;
white-space: nowrap;
}
.series-nav-list {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.series-nav-item {
display: flex;
align-items: baseline;
gap: 0.75rem;
&.is-current {
.series-nav-index {
color: var(--accent-color);
}
.series-nav-label {
color: var(--text-color);
font-weight: 600;
}
}
}
.series-nav-index {
font-family: var(--font-mono);
font-size: 0.7rem;
color: var(--text-muted);
opacity: 0.6;
flex-shrink: 0;
width: 1.5ch;
text-align: right;
}
.series-nav-label {
font-size: 0.9rem;
color: var(--text-muted);
text-decoration: none;
&:hover {
color: var(--accent-color);
}
}
.post-toc {
background: var(--surface-color);
border: 1px solid var(--border-color);
+103
View File
@@ -0,0 +1,103 @@
(function () {
'use strict';
var body = document.getElementById('term-body');
if (!body) return;
var path = window.location.pathname;
var links = [
{ href: body.dataset.linkHome, label: '~/home' },
{ href: body.dataset.linkPosts, label: '~/posts' },
{ href: body.dataset.linkTags, label: '~/tags' }
];
var steps = [
{ type: 'cmd', text: 'cd ' + path },
{ type: 'out-error', text: 'bash: cd: ' + path + ': No such file or directory' },
{ type: 'cmd', text: 'whoami' },
{ type: 'out', text: 'l0st_r3ader' },
{ type: 'cmd', text: 'ls ~/recovery/' },
{ type: 'ls' }
];
var CHAR_DELAY = 28;
var LINE_DELAY = 180;
function ps1() {
var s = document.createElement('span');
s.className = 'term-ps1';
s.textContent = 'user@blackout:~$ ';
return s;
}
function appendCmdLine(text, callback) {
var row = document.createElement('div');
row.className = 'term-row';
row.appendChild(ps1());
var input = document.createElement('span');
input.className = 'term-input';
row.appendChild(input);
body.appendChild(row);
var i = 0;
function tick() {
if (i < text.length) {
input.textContent += text[i++];
setTimeout(tick, CHAR_DELAY);
} else {
setTimeout(callback, LINE_DELAY);
}
}
tick();
}
function appendOut(text, extraClass, callback) {
var div = document.createElement('div');
div.className = 'term-out' + (extraClass ? ' ' + extraClass : '');
div.textContent = text;
body.appendChild(div);
setTimeout(callback, LINE_DELAY);
}
function appendLs(callback) {
var div = document.createElement('div');
div.className = 'term-out-ls';
links.forEach(function (l) {
var a = document.createElement('a');
a.href = l.href;
a.textContent = l.label;
div.appendChild(a);
});
body.appendChild(div);
setTimeout(callback, LINE_DELAY);
}
function appendCursor() {
var row = document.createElement('div');
row.className = 'term-row';
row.appendChild(ps1());
var cur = document.createElement('span');
cur.className = 'term-cursor';
cur.setAttribute('aria-hidden', 'true');
row.appendChild(cur);
body.appendChild(row);
}
function runSteps(i) {
if (i >= steps.length) {
appendCursor();
return;
}
var step = steps[i];
var next = function () { runSteps(i + 1); };
if (step.type === 'cmd') appendCmdLine(step.text, next);
else if (step.type === 'out-error') appendOut(step.text, 'term-out-error', next);
else if (step.type === 'out') appendOut(step.text, 'term-out-muted', next);
else if (step.type === 'ls') appendLs(next);
else next();
}
runSteps(0);
})();
+9 -127
View File
@@ -16,135 +16,17 @@
<span class="term-titlebar-label">bash — pwnbox</span>
</div>
<div class="term-body" id="term-body">
<!-- lines injected by JS -->
<div class="term-body" id="term-body"
data-link-home="{{ get_url(path="") }}"
data-link-posts="{{ get_url(path="/posts") }}"
data-link-tags="{{ get_url(path="/tags") }}">
<!-- lines injected by 404.js -->
</div>
</div>
</div>
<script>
(function () {
var body = document.getElementById('term-body');
var path = window.location.pathname;
var steps = [
{
type: 'cmd',
text: 'cd ' + path
},
{
type: 'out-error',
text: 'bash: cd: ' + path + ': No such file or directory'
},
{
type: 'cmd',
text: 'whoami'
},
{
type: 'out',
text: 'l0st_r3ader'
},
{
type: 'cmd',
text: 'ls ~/recovery/'
},
{
type: 'ls'
}
];
var links = [
{ href: '{{ get_url(path="") }}', label: '~/home' },
{ href: '{{ get_url(path="/posts") }}', label: '~/posts' },
{ href: '{{ get_url(path="/tags") }}', label: '~/tags' }
];
var CHAR_DELAY = 28;
var LINE_DELAY = 180;
function ps1() {
var s = document.createElement('span');
s.className = 'term-ps1';
s.textContent = 'user@blackout:~$ ';
return s;
}
function appendCmdLine(text, callback) {
var row = document.createElement('div');
row.className = 'term-row';
row.appendChild(ps1());
var input = document.createElement('span');
input.className = 'term-input';
row.appendChild(input);
body.appendChild(row);
var i = 0;
function tick() {
if (i < text.length) {
input.textContent += text[i++];
setTimeout(tick, CHAR_DELAY);
} else {
setTimeout(callback, LINE_DELAY);
}
}
tick();
}
function appendOut(text, extraClass, callback) {
var div = document.createElement('div');
div.className = 'term-out' + (extraClass ? ' ' + extraClass : '');
div.textContent = text;
body.appendChild(div);
setTimeout(callback, LINE_DELAY);
}
function appendLs(callback) {
var div = document.createElement('div');
div.className = 'term-out-ls';
links.forEach(function (l) {
var a = document.createElement('a');
a.href = l.href;
a.textContent = l.label;
div.appendChild(a);
});
body.appendChild(div);
setTimeout(callback, LINE_DELAY);
}
function appendCursor() {
var row = document.createElement('div');
row.className = 'term-row';
row.appendChild(ps1());
var cur = document.createElement('span');
cur.className = 'term-cursor';
cur.setAttribute('aria-hidden', 'true');
row.appendChild(cur);
body.appendChild(row);
}
function runSteps(i) {
if (i >= steps.length) {
appendCursor();
return;
}
var step = steps[i];
var next = function () { runSteps(i + 1); };
if (step.type === 'cmd') {
appendCmdLine(step.text, next);
} else if (step.type === 'out-error') {
appendOut(step.text, 'term-out-error', next);
} else if (step.type === 'out') {
appendOut(step.text, 'term-out-muted', next);
} else if (step.type === 'ls') {
appendLs(next);
} else {
next();
}
}
runSteps(0);
})();
</script>
{% endblock content %}
{% block scripts %}
<script defer src="{{ get_url(path="js/404.js") }}"></script>
{% endblock scripts %}
+2
View File
@@ -128,6 +128,8 @@
</div>
</header>
{% include "partials/series-nav.html" %}
{% include "partials/toc.html" %}
<div class="post-body">
+31
View File
@@ -0,0 +1,31 @@
{% if page.extra.series %}
{% set section_data = get_section(path="posts/_index.md") %}
{% set_global series_pages = [] %}
{% for p in section_data.pages %}
{% if p.extra.series and p.extra.series == page.extra.series %}
{% set_global series_pages = series_pages | concat(with=p) %}
{% endif %}
{% endfor %}
{% set series_sorted = series_pages | sort(attribute="extra.series_index") %}
{% set series_total = series_sorted | length %}
<div class="series-nav" aria-label="Post series: {{ page.extra.series }}">
<div class="series-nav-header">
<span class="series-nav-eyebrow">Series</span>
<span class="series-nav-title">{{ page.extra.series }}</span>
<span class="series-nav-badge">{{ page.extra.series_index }} / {{ series_total }}</span>
</div>
<ol class="series-nav-list">
{% for p in series_sorted %}
<li class="series-nav-item{% if p.permalink == page.permalink %} is-current{% endif %}">
<span class="series-nav-index">{{ p.extra.series_index }}</span>
{% if p.permalink == page.permalink %}
<span class="series-nav-label" aria-current="page">{{ p.title }}</span>
{% else %}
<a class="series-nav-label" href="{{ p.permalink }}">{{ p.title }}</a>
{% endif %}
</li>
{% endfor %}
</ol>
</div>
{% endif %}