Changeset d8c6a83 in Klonkt for src/routes/download.js


Ignore:
Timestamp:
06/20/2026 08:29:48 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d68bcf1
Parents:
cf0de0c
Message:

fix(downloads+posts): post nav on downloads page + post images full width

  • The pinned "Downloads!" is a real post with slug 'downloads'; the feature route /downloads intercepts it (no post nav). Now /downloads calculates the Newer/Older neighbours of that post and shows the post nav — download buttons remain.
  • Post images (.post-content img) always fill the container width with natural (uncropped) height. style.css?v=20.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/download.js

    rcf0de0c rd8c6a83  
    2020import { premiumUnlocked } from '../services/PatreonService.js';
    2121import { addSubscriber } from '../services/SubscriberService.js';
     22import { postNeighbors } from './posts.js';
    2223
    2324const router = express.Router();
     25
     26// Als er een echte (gepinde) post met slug 'downloads' bestaat, hangt de
     27// downloads-lijst feitelijk aan die post. Dan tonen we óók de Newer/Older-postnav,
     28// zodat de bezoeker net als bij een post verder kan bladeren.
     29function downloadsPostNav(req, res) {
     30  const site = res.locals.site;
     31  if (!site) return {};
     32  const post = db.prepare(
     33    "SELECT id, slug, pinned FROM posts WHERE site_id = ? AND slug = 'downloads' AND status = 'published'"
     34  ).get(site.id);
     35  if (!post) return {};
     36  try { return postNeighbors(site, post, res.locals.tenancy === 'hub'); } catch (e) { return {}; }
     37}
    2438const __dirname = path.dirname(fileURLToPath(import.meta.url));
    2539const AUDIO_DIR = path.resolve(process.env.AUDIO_PATH || path.join(__dirname, '..', '..', 'storage', 'audio'));
     
    5064      WHERE site_id = ? AND downloadable = 1 ORDER BY position ASC, created_at ASC`
    5165  ).all(site.id);
     66  const nav = downloadsPostNav(req, res);
    5267  renderPage(req, res, 'pages/downloads', {
    5368    pageTitle: 'Downloads — ' + (site.title || ''),
    5469    bodyClass: 'on-downloads',
    5570    dlTracks: tracks,
     71    newerPost: nav.newerPost || null,
     72    olderPost: nav.olderPost || null,
    5673  });
    5774});
Note: See TracChangeset for help on using the changeset viewer.