source: Klonkt/src/routes/types.js@ adb6291

main
Last change on this file since adb6291 was adb6291, checked in by roboburr <roboburr@…>, 2 months ago

feat(video-cover): render iOS video covers across grid, list, related + listing pages

  • post-tile.ejs / post-card.ejs / post.ejs(related): the cover <img> carries data-ios-mp4 when a loop MP4 exists; shell.ejs's iOS swap upgrades it everywhere covers render
  • cover_video_url threaded through the explicit listing SELECTs (tags/types/users/related); the home grid + main list already use SELECT p.*

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * GET /type/:type
3 *
4 * Lists published posts on the current site filtered by post.type.
5 * Mirrors the v9 /type/ pages (foto, video, audio, post).
6 */
7
8import express from 'express';
9import db from '../config/database.js';
10import { renderPage } from '../middleware/render.js';
11
12const router = express.Router();
13const VALID_TYPES = new Set(['post', 'foto', 'video', 'audio']);
14
15router.get('/:type', (req, res) => {
16 const site = res.locals.site;
17 if (!site) return res.status(404).send('No site');
18
19 const type = (req.params.type || '').toLowerCase().trim();
20 if (!VALID_TYPES.has(type)) return res.status(404).send('Unknown type');
21
22 const posts = db.prepare(`
23 SELECT p.id, p.slug, p.title, p.excerpt, p.cover_image_url, p.cover_video_url,
24 p.published_at, p.type, u.username AS author_username
25 FROM posts p JOIN users u ON u.id = p.author_id
26 WHERE p.site_id = ? AND p.status = 'published' AND p.type = ?
27 ORDER BY p.published_at DESC
28 LIMIT 100
29 `).all(site.id, type);
30
31 renderPage(req, res, 'pages/type', {
32 pageTitle: type[0].toUpperCase() + type.slice(1) + ' — ' + site.title,
33 bodyClass: 'on-special',
34 type,
35 posts,
36 });
37});
38
39export default router;
Note: See TracBrowser for help on using the repository browser.