| 1 | <%
|
|---|
| 2 | // Post list item — MOBILE-FIRST.
|
|---|
| 3 | //
|
|---|
| 4 | // <768px (default):
|
|---|
| 5 | // Vertical stack — full-bleed 16:9 cover on top, content below.
|
|---|
| 6 | // Whole card is tappable (one big <a> wrapping everything).
|
|---|
| 7 | // Active state: scale(0.985) + opacity dim.
|
|---|
| 8 | //
|
|---|
| 9 | // ≥768px (desktop):
|
|---|
| 10 | // v9 pattern — 120px square cover left, content right.
|
|---|
| 11 | // Hover state on cover. Tap-target stays large.
|
|---|
| 12 |
|
|---|
| 13 | const _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '';
|
|---|
| 14 | const _external = post.external_url || null;
|
|---|
| 15 | const _href = _external || (_base + '/' + post.slug);
|
|---|
| 16 | const _ext = !!_external;
|
|---|
| 17 | const _src = post.source_name || '';
|
|---|
| 18 | const _hasCover = !!post.cover_image_url;
|
|---|
| 19 | const _typeLabel = (post.type && post.type !== 'overig' && post.type !== 'post') ? post.type : '';
|
|---|
| 20 | const _isPinned = !!post.pinned;
|
|---|
| 21 | const _isBoost = !!post.isBoost;
|
|---|
| 22 | const _isDraft = post.status && post.status !== 'published';
|
|---|
| 23 |
|
|---|
| 24 | function _ddmmyyyy(iso) {
|
|---|
| 25 | if (!iso) return '';
|
|---|
| 26 | const d = new Date(iso);
|
|---|
| 27 | if (isNaN(d.getTime())) return '';
|
|---|
| 28 | const pad = n => String(n).padStart(2, '0');
|
|---|
| 29 | return pad(d.getDate()) + '-' + pad(d.getMonth() + 1) + '-' + d.getFullYear();
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | let _tags = [];
|
|---|
| 33 | if (post.tags) {
|
|---|
| 34 | if (Array.isArray(post.tags)) _tags = post.tags;
|
|---|
| 35 | else if (typeof post.tags === 'string') {
|
|---|
| 36 | try {
|
|---|
| 37 | const parsed = JSON.parse(post.tags);
|
|---|
| 38 | _tags = Array.isArray(parsed) ? parsed : post.tags.split(',').map(t => t.trim()).filter(Boolean);
|
|---|
| 39 | } catch (e) {
|
|---|
| 40 | _tags = post.tags.split(',').map(t => t.trim()).filter(Boolean);
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | %>
|
|---|
| 45 | <li class="post-list-item<%= (_hasCover || post.nsfw) ? ' has-cover' : '' %><%= (_isPinned || _isBoost) ? ' is-pinned' : '' %>">
|
|---|
| 46 |
|
|---|
| 47 | <% if (_hasCover) { %>
|
|---|
| 48 | <a class="post-list-cover<%= post.nsfw ? ' nsfw-media' : '' %>" href="<%= _href %>"
|
|---|
| 49 | <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %>
|
|---|
| 50 | aria-label="<%= post.title || '(zonder titel)' %>" tabindex="-1">
|
|---|
| 51 | <img src="<%= thumb(post.cover_image_url, 320) %>" alt="" loading="lazy" decoding="async">
|
|---|
| 52 | <% if (post.nsfw) { %><span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= post.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span><% } %>
|
|---|
| 53 | </a>
|
|---|
| 54 | <% } else if (post.nsfw) { %>
|
|---|
| 55 | <a class="post-list-cover nsfw-media" href="<%= _href %>"
|
|---|
| 56 | <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %>
|
|---|
| 57 | aria-label="<%= post.title || '(zonder titel)' %>" tabindex="-1">
|
|---|
| 58 | <span class="nsfw-veil"><span class="nsfw-veil-label">🔞 <%= post.content_warning || t('post.nsfw_warning') %></span><span class="nsfw-veil-btn"><%= t('post.nsfw_show') %></span></span>
|
|---|
| 59 | </a>
|
|---|
| 60 | <% } %>
|
|---|
| 61 |
|
|---|
| 62 | <div class="post-list-body">
|
|---|
| 63 | <div class="post-list-meta mono">
|
|---|
| 64 | <% if (_isBoost) { %><span class="post-list-pin post-list-boost" aria-label="Boost"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg></span><% } else if (_isPinned) { %><span class="post-list-pin" aria-label="Vastgepind"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24z"/></svg></span><% } %>
|
|---|
| 65 | <time datetime="<%= post.published_at || post.created_at %>"><%= _ddmmyyyy(post.published_at || post.created_at) %></time>
|
|---|
| 66 | <% if (_src) { %><span class="post-list-type">· via <%= _src %></span><% } %>
|
|---|
| 67 | <% if (_typeLabel) { %>
|
|---|
| 68 | <span class="post-list-type">· <%= _typeLabel.charAt(0).toUpperCase() + _typeLabel.slice(1) %></span>
|
|---|
| 69 | <% } %>
|
|---|
| 70 | <% if (_isDraft) { %>
|
|---|
| 71 | <span class="post-list-type post-list-draft">· concept</span>
|
|---|
| 72 | <% } %>
|
|---|
| 73 | </div>
|
|---|
| 74 |
|
|---|
| 75 | <h3 class="post-list-title">
|
|---|
| 76 | <a href="<%= _href %>"
|
|---|
| 77 | <% if (_ext) { %>target="_blank" rel="noopener"<% } else { %>hx-get="<%= _href %>?partial=1" hx-target="#pcms-main" hx-swap="innerHTML" hx-push-url="<%= _href %>" hx-indicator="#pcms-loading"<% } %>>
|
|---|
| 78 | <%= post.title || '(zonder titel)' %>
|
|---|
| 79 | </a>
|
|---|
| 80 | </h3>
|
|---|
| 81 |
|
|---|
| 82 | <% if (post.excerpt) { %>
|
|---|
| 83 | <p class="post-list-excerpt"><%= post.excerpt %></p>
|
|---|
| 84 | <% } %>
|
|---|
| 85 |
|
|---|
| 86 | <% if (_tags.length) { %>
|
|---|
| 87 | <div class="post-list-tags">
|
|---|
| 88 | <% _tags.forEach(function(t) { %>
|
|---|
| 89 | <a href="<%= _base %>/tag/<%= encodeURIComponent(t) %>" class="tag-chip"
|
|---|
| 90 | hx-get="<%= _base %>/tag/<%= encodeURIComponent(t) %>?partial=1" hx-target="#pcms-main"
|
|---|
| 91 | hx-swap="innerHTML" hx-push-url="<%= _base %>/tag/<%= encodeURIComponent(t) %>"
|
|---|
| 92 | hx-indicator="#pcms-loading">#<%= t %></a>
|
|---|
| 93 | <% }); %>
|
|---|
| 94 | </div>
|
|---|
| 95 | <% } %>
|
|---|
| 96 | </div>
|
|---|
| 97 | </li>
|
|---|
| 98 |
|
|---|
| 99 | <style>
|
|---|
| 100 | /* ============================================================
|
|---|
| 101 | POST-LIST-ITEM — MOBILE-FIRST OVERRIDE
|
|---|
| 102 | The base v9 styles in /assets/css/style.css use a desktop
|
|---|
| 103 | 120×120 grid by default. We flip that: stacked on mobile,
|
|---|
| 104 | side-by-side on ≥768px.
|
|---|
| 105 | ============================================================ */
|
|---|
| 106 |
|
|---|
| 107 | /* Reset v9's grid on mobile and stack vertically */
|
|---|
| 108 | @media (max-width: 767px) {
|
|---|
| 109 | .post-list {
|
|---|
| 110 | gap: 2rem;
|
|---|
| 111 | }
|
|---|
| 112 | .post-list-item {
|
|---|
| 113 | display: flex !important;
|
|---|
| 114 | flex-direction: column;
|
|---|
| 115 | grid-template-columns: none !important;
|
|---|
| 116 | gap: .85rem !important;
|
|---|
| 117 | padding-bottom: 2rem;
|
|---|
| 118 | /* Active feedback for the whole card row */
|
|---|
| 119 | transition: transform 120ms ease, opacity 120ms ease;
|
|---|
| 120 | }
|
|---|
| 121 | .post-list-item:active {
|
|---|
| 122 | transform: scale(0.985);
|
|---|
| 123 | opacity: 0.85;
|
|---|
| 124 | }
|
|---|
| 125 | .post-list-item:last-child {
|
|---|
| 126 | border-bottom: none;
|
|---|
| 127 | padding-bottom: 0;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | /* Cover: full-bleed of the container, 16:9 ratio, no border-radius
|
|---|
| 131 | on small phones (edge-to-edge feels app-native). 8px radius from 480px+. */
|
|---|
| 132 | .post-list-cover {
|
|---|
| 133 | aspect-ratio: 16 / 9 !important;
|
|---|
| 134 | width: 100% !important;
|
|---|
| 135 | border-radius: 0 !important;
|
|---|
| 136 | /* Negative margin to break out of .container's padding */
|
|---|
| 137 | margin-left: calc(-1 * clamp(1.25rem, 4vw, 2rem));
|
|---|
| 138 | margin-right: calc(-1 * clamp(1.25rem, 4vw, 2rem));
|
|---|
| 139 | width: calc(100% + 2 * clamp(1.25rem, 4vw, 2rem)) !important;
|
|---|
| 140 | background: var(--paper-2);
|
|---|
| 141 | }
|
|---|
| 142 | .post-list-cover img {
|
|---|
| 143 | width: 100%; height: 100%;
|
|---|
| 144 | object-fit: cover;
|
|---|
| 145 | display: block;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | /* Re-apply rounded corners on slightly larger phones */
|
|---|
| 149 | @media (min-width: 480px) {
|
|---|
| 150 | .post-list-cover {
|
|---|
| 151 | border-radius: var(--radius) !important;
|
|---|
| 152 | margin-left: 0 !important;
|
|---|
| 153 | margin-right: 0 !important;
|
|---|
| 154 | width: 100% !important;
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | /* Larger title for mobile readability */
|
|---|
| 159 | .post-list-title {
|
|---|
| 160 | font-size: 1.45rem !important;
|
|---|
| 161 | line-height: 1.2 !important;
|
|---|
| 162 | }
|
|---|
| 163 | .post-list-excerpt {
|
|---|
| 164 | font-size: 1rem !important;
|
|---|
| 165 | color: var(--ink-soft) !important;
|
|---|
| 166 | line-height: 1.55 !important;
|
|---|
| 167 | }
|
|---|
| 168 | .post-list-meta {
|
|---|
| 169 | font-size: .8rem !important;
|
|---|
| 170 | gap: .5rem !important;
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | /* Pinned indicator */
|
|---|
| 174 | .post-list-item.is-pinned .post-list-title a {
|
|---|
| 175 | /* No visual change on title — the ★ in meta is enough */
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | /* Tap targets for tags */
|
|---|
| 179 | .post-list-tags { gap: .4rem; }
|
|---|
| 180 | .tag-chip {
|
|---|
| 181 | min-height: 32px;
|
|---|
| 182 | display: inline-flex;
|
|---|
| 183 | align-items: center;
|
|---|
| 184 | padding: .2rem .65rem;
|
|---|
| 185 | }
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | /* ============================================================
|
|---|
| 189 | DESKTOP — keep v9's 120px-square pattern (style.css does this)
|
|---|
| 190 | We just enforce the layout here for clarity + override safety.
|
|---|
| 191 | ============================================================ */
|
|---|
| 192 | @media (min-width: 768px) {
|
|---|
| 193 | .post-list-item.has-cover {
|
|---|
| 194 | display: grid !important;
|
|---|
| 195 | grid-template-columns: 120px 1fr !important;
|
|---|
| 196 | gap: 1.25rem !important;
|
|---|
| 197 | }
|
|---|
| 198 | .post-list-item:not(.has-cover) {
|
|---|
| 199 | grid-template-columns: 1fr !important;
|
|---|
| 200 | }
|
|---|
| 201 | .post-list-cover {
|
|---|
| 202 | aspect-ratio: 1 !important;
|
|---|
| 203 | border-radius: var(--radius) !important;
|
|---|
| 204 | }
|
|---|
| 205 | /* Hover lift on desktop (touch devices use :active above) */
|
|---|
| 206 | @media (hover: hover) {
|
|---|
| 207 | .post-list-cover {
|
|---|
| 208 | transition: transform 200ms ease;
|
|---|
| 209 | }
|
|---|
| 210 | .post-list-item:hover .post-list-cover {
|
|---|
| 211 | transform: scale(1.02);
|
|---|
| 212 | }
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | /* ============================================================
|
|---|
| 217 | PIN + DRAFT INDICATORS (shared)
|
|---|
| 218 | ============================================================ */
|
|---|
| 219 | .post-list-pin {
|
|---|
| 220 | color: var(--accent);
|
|---|
| 221 | margin-right: .35rem;
|
|---|
| 222 | display: inline-flex;
|
|---|
| 223 | align-items: center;
|
|---|
| 224 | vertical-align: middle;
|
|---|
| 225 | }
|
|---|
| 226 | .post-list-pin svg { width: 13px; height: 13px; display: block; }
|
|---|
| 227 | .post-list-boost { color: #2fa85a; }
|
|---|
| 228 | .post-list-draft {
|
|---|
| 229 | color: var(--accent);
|
|---|
| 230 | font-style: italic;
|
|---|
| 231 | }
|
|---|
| 232 | </style>
|
|---|