source: Klonkt/src/views/pages/archive.ejs@ ec2e358

main
Last change on this file since ec2e358 was d15b27f, checked in by roboburr <roboburr@…>, 3 months ago

Archive: Timeline/Grid greyed on archive + back button (+ English text)

(1) The active highlight on the view-switcher was bound to body[data-feed-view]
without a page check → kept lighting up on /archive. Now :not(.on-archive)
→ both buttons neutral/grey on the archive page.
(2) Back button at the top of /archive (htmx to the homepage).
(3) Archive→Archive, posts→posts, "No posts yet" text corrected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

  • Property mode set to 100644
File size: 3.7 KB
Line 
1<%
2// Archive — chronological feed of all posts.
3//
4// Renders both a timeline view (year/month grouped link list) AND a grid
5// view (flat tiles) — same toggle pattern as home.ejs. The view-switcher
6// at the top lets the user pick. Body class is `on-archive`; the inline
7// <style> below adds an `.on-archive` clause to the existing home-only
8// feed toggle in style.css (cleaner than editing the global CSS).
9//
10// Flatten posts for grid mode: skip the year/month grouping (it doesn't
11// translate well to a tile grid). Newest-first order is preserved by the
12// route's SQL ORDER BY.
13const _flatPosts = [];
14Object.keys(grouped).sort((a, b) => b - a).forEach(function(y) {
15 Object.keys(grouped[y]).forEach(function(m) {
16 grouped[y][m].forEach(function(p) { _flatPosts.push(p); });
17 });
18});
19%>
20
21<%# View switcher used to be rendered here; now lives in shell.ejs above
22 #pcms-main, visible on every non-admin page. %>
23
24<!-- ========== TIMELINE (year/month grouped) ========== -->
25<div class="container archive-page feed-timeline">
26 <% var _archBase = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : ''; %>
27 <p class="archive-back-row">
28 <a href="<%= _archBase %>/" class="btn archive-back"
29 hx-get="<%= _archBase %>/?partial=1" hx-target="#pcms-main"
30 hx-push-url="<%= _archBase %>/" hx-indicator="#pcms-loading">&larr; Terug</a>
31 </p>
32 <h1>Archief</h1>
33 <p class="archive-meta"><%= totalPosts %> bericht<%= totalPosts !== 1 ? 'en' : '' %></p>
34
35 <% if (totalPosts === 0) { %>
36 <p class="empty-state">Nog geen berichten.</p>
37 <% } %>
38
39 <% Object.keys(grouped).sort((a,b) => b - a).forEach(year => { %>
40 <section class="archive-year">
41 <h2><%= year %></h2>
42 <% Object.keys(grouped[year]).forEach(month => { %>
43 <div class="archive-month">
44 <h3><%= month %></h3>
45 <ul>
46 <% grouped[year][month].forEach(post => { %>
47 <li>
48 <a href="/<%= post.slug %>"
49 hx-get="/<%= post.slug %>?partial=1" hx-target="#pcms-main"
50 hx-push-url="/<%= post.slug %>" hx-indicator="#pcms-loading">
51 <%= post.title %>
52 </a>
53 <span class="archive-author">— <%= post.author_username %></span>
54 </li>
55 <% }); %>
56 </ul>
57 </div>
58 <% }); %>
59 </section>
60 <% }); %>
61</div>
62
63<!-- ========== GRID (only visible when body[data-feed-view="grid"]) ========== -->
64<% if (_flatPosts.length > 0) { %>
65<section class="feed-grid container" aria-label="Grid-weergave">
66 <div class="grid-tiles">
67 <% _flatPosts.forEach(function(post) { %>
68 <%- include('../partials/post-tile', { post: post }) %>
69 <% }); %>
70 </div>
71</section>
72<% } %>
73
74<style>
75.archive-page { max-width: 700px; margin: 2rem auto; padding: 0 1rem; }
76.archive-back-row { margin: 0 0 1rem; }
77.archive-page h1 { font-family: var(--font-display, serif); margin: 0 0 0.25rem; }
78.archive-meta { color: var(--ink-muted); margin-bottom: 2rem; }
79.archive-year { margin-bottom: 2.5rem; }
80.archive-year h2 { font-family: var(--font-display, serif); font-size: 1.8rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--accent); margin: 0 0 1rem; }
81.archive-month { margin: 1.5rem 0 1.5rem 1rem; }
82.archive-month h3 { font-size: 1.05rem; color: var(--ink-muted); text-transform: capitalize; margin: 0 0 0.5rem; font-weight: 500; }
83.archive-page ul { list-style: none; padding: 0 0 0 1rem; margin: 0; }
84.archive-page li { padding: 0.4rem 0; }
85.archive-page a { color: var(--ink); text-decoration: none; font-weight: 500; }
86.archive-page a:hover { color: var(--accent); }
87.archive-author { color: var(--ink-muted); font-size: 0.85rem; margin-left: 0.5rem; }
88</style>
Note: See TracBrowser for help on using the repository browser.