| 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.
|
|---|
| 13 | const _flatPosts = [];
|
|---|
| 14 | Object.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 | <h1>Archive</h1>
|
|---|
| 27 | <p class="archive-meta"><%= totalPosts %> post<%= totalPosts !== 1 ? 's' : '' %></p>
|
|---|
| 28 |
|
|---|
| 29 | <% if (totalPosts === 0) { %>
|
|---|
| 30 | <p class="empty-state">No posts yet.</p>
|
|---|
| 31 | <% } %>
|
|---|
| 32 |
|
|---|
| 33 | <% Object.keys(grouped).sort((a,b) => b - a).forEach(year => { %>
|
|---|
| 34 | <section class="archive-year">
|
|---|
| 35 | <h2><%= year %></h2>
|
|---|
| 36 | <% Object.keys(grouped[year]).forEach(month => { %>
|
|---|
| 37 | <div class="archive-month">
|
|---|
| 38 | <h3><%= month %></h3>
|
|---|
| 39 | <ul>
|
|---|
| 40 | <% grouped[year][month].forEach(post => { %>
|
|---|
| 41 | <li>
|
|---|
| 42 | <a href="/<%= post.slug %>"
|
|---|
| 43 | hx-get="/<%= post.slug %>?partial=1" hx-target="#pcms-main"
|
|---|
| 44 | hx-push-url="/<%= post.slug %>" hx-indicator="#pcms-loading">
|
|---|
| 45 | <%= post.title %>
|
|---|
| 46 | </a>
|
|---|
| 47 | <span class="archive-author">— <%= post.author_username %></span>
|
|---|
| 48 | </li>
|
|---|
| 49 | <% }); %>
|
|---|
| 50 | </ul>
|
|---|
| 51 | </div>
|
|---|
| 52 | <% }); %>
|
|---|
| 53 | </section>
|
|---|
| 54 | <% }); %>
|
|---|
| 55 | </div>
|
|---|
| 56 |
|
|---|
| 57 | <!-- ========== GRID (only visible when body[data-feed-view="grid"]) ========== -->
|
|---|
| 58 | <% if (_flatPosts.length > 0) { %>
|
|---|
| 59 | <section class="feed-grid container" aria-label="Grid-weergave">
|
|---|
| 60 | <div class="grid-tiles">
|
|---|
| 61 | <% _flatPosts.forEach(function(post) { %>
|
|---|
| 62 | <%- include('../partials/post-tile', { post: post }) %>
|
|---|
| 63 | <% }); %>
|
|---|
| 64 | </div>
|
|---|
| 65 | </section>
|
|---|
| 66 | <% } %>
|
|---|
| 67 |
|
|---|
| 68 | <style>
|
|---|
| 69 | .archive-page { max-width: 700px; margin: 2rem auto; padding: 0 1rem; }
|
|---|
| 70 | .archive-page h1 { font-family: var(--font-display, serif); margin: 0 0 0.25rem; }
|
|---|
| 71 | .archive-meta { color: var(--ink-muted); margin-bottom: 2rem; }
|
|---|
| 72 | .archive-year { margin-bottom: 2.5rem; }
|
|---|
| 73 | .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; }
|
|---|
| 74 | .archive-month { margin: 1.5rem 0 1.5rem 1rem; }
|
|---|
| 75 | .archive-month h3 { font-size: 1.05rem; color: var(--ink-muted); text-transform: capitalize; margin: 0 0 0.5rem; font-weight: 500; }
|
|---|
| 76 | .archive-page ul { list-style: none; padding: 0 0 0 1rem; margin: 0; }
|
|---|
| 77 | .archive-page li { padding: 0.4rem 0; }
|
|---|
| 78 | .archive-page a { color: var(--ink); text-decoration: none; font-weight: 500; }
|
|---|
| 79 | .archive-page a:hover { color: var(--accent); }
|
|---|
| 80 | .archive-author { color: var(--ink-muted); font-size: 0.85rem; margin-left: 0.5rem; }
|
|---|
| 81 | </style>
|
|---|