Design updates, adding 2027 posts

This commit is contained in:
Bashy 2026-10-05 23:12:01 +03:00
parent 2d50bec4cb
commit e51d53994a
30 changed files with 521 additions and 81 deletions

View file

@ -23,12 +23,25 @@ hexo.extend.filter.register('before_generate', function () {
});
hexo.locals.set('nextEvent', futureEvents[0] || false);
hexo.locals.set('lastEvent', pastEvents[pastEvents.length - 1] || false);
// Most recent past event that actually has a video (skips TBD / missing).
const pastWithVideo = pastEvents.filter(function (p) {
return p.event && p.event.video && p.event.video !== 'TBD';
});
hexo.locals.set('lastEvent', pastWithVideo[pastWithVideo.length - 1] || false);
// Far-future events (all future except the nearest one) are excluded from
// site.posts so they don't appear in archives or RSS.
const hiddenIds = new Set(futureEvents.slice(1).map(function (p) { return p._id; }));
// Every event (including hidden far-future ones) for the /events/ timeline.
// `hasPage` is false for hidden events, since no page is generated for them.
hexo.locals.set('allEvents', eventPosts.map(function (p) {
let state = 'upcoming';
if (p.date.valueOf() < today.getTime()) state = 'past';
else if (p === futureEvents[0]) state = 'next';
return { post: p, state: state, hasPage: !hiddenIds.has(p._id) };
}));
if (hiddenIds.size > 0) {
const filtered = hexo.locals.get('posts').filter(function (p) {
return !hiddenIds.has(p._id);

52
scripts/icon.js Normal file
View file

@ -0,0 +1,52 @@
'use strict';
// Inline SVG icons at build time.
// Templates: <%- icon('si:gitlab') %> / <%- icon('lucide:map-pin') %>
// Markdown: {% icon lucide:download %}
// si: Simple Icons (brand logos) https://simpleicons.org
// lucide: Lucide (general icons) https://lucide.dev
// custom: themes/openalt/icons/*.svg (logos missing from the above, e.g. LinkedIn)
const fs = require('fs');
const path = require('path');
const sets = {
si: path.join(hexo.base_dir, 'node_modules/simple-icons/icons'),
lucide: path.join(hexo.base_dir, 'node_modules/lucide-static/icons'),
custom: path.join(hexo.theme_dir, 'icons')
};
const cache = new Map();
function icon(name) {
if (!name) return '';
if (cache.has(name)) return cache.get(name);
const [set, id] = name.split(':');
const dir = sets[set];
const file = dir && id && path.join(dir, id + '.svg');
if (!file || !fs.existsSync(file)) {
hexo.log.warn('icon: unknown icon "%s"', name);
cache.set(name, '');
return '';
}
const svg = fs.readFileSync(file, 'utf8')
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/<title>[\s\S]*?<\/title>/, '')
.replace(/\s+/g, ' ')
.trim()
// Drop the root's own sizing/class/role; CSS sizes icons via .icon
.replace(/<svg([^>]*)>/, function (m, attrs) {
attrs = attrs.replace(/\s(width|height|class|role)="[^"]*"/g, '');
const fill = set === 'lucide' ? '' : ' fill="currentColor"';
return '<svg' + attrs + fill + ' class="icon icon-' + set + '" aria-hidden="true">';
});
cache.set(name, svg);
return svg;
}
hexo.extend.helper.register('icon', icon);
hexo.extend.tag.register('icon', function (args) { return icon(args[0]); });