Changeset 520e477 in Klonkt for src/routes/posts.js
- Timestamp:
- 07/20/2026 07:35:55 AM (7 weeks ago)
- Branches:
- main
- Children:
- 22d2f5a8
- Parents:
- 1485933
- git-author:
- Robin <roboburr@…> (07/20/2026 07:26:51 AM)
- git-committer:
- Robin <roboburr@…> (07/20/2026 07:35:55 AM)
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r1485933 r520e477 95 95 const router = express.Router(); 96 96 97 // Feed page size for "Load more" (Solo, News, Messages, Cirkel). 72 is divisible 98 // by 2/3/4 so every grid column count ends on a full row. 99 const FEED_PAGE = 72; 100 97 101 // ==================== UPLOAD IMAGE (cover or content) ==================== 98 102 // Returns JSON {url} so the editor can stick it into the cover field or … … 210 214 `).all(site.id); 211 215 212 // Regular posts: anything with pinned = 0 213 const posts = db.prepare(` 216 // Regular posts: anything with pinned = 0. Paged in blocks of 72 (Load more). 217 const append = req.query.append === '1'; 218 const offset = Math.max(0, parseInt(req.query.offset, 10) || 0); 219 const rows = db.prepare(` 214 220 SELECT p.*, u.username as author_username 215 221 FROM posts p JOIN users u ON p.author_id = u.id 216 222 WHERE p.site_id = ? AND p.status = 'published' AND p.pinned = 0 217 223 ORDER BY p.published_at DESC 218 LIMIT 30 219 `).all(site.id); 224 LIMIT ? OFFSET ? 225 `).all(site.id, FEED_PAGE + 1, offset); 226 const hasMore = rows.length > FEED_PAGE; 227 const posts = rows.slice(0, FEED_PAGE); 228 const moreBase = res.locals.siteUrlBase || ''; 229 230 if (append) { 231 return renderPage(req, res, 'partials/home-append', { posts, hasMore, nextOffset: offset + FEED_PAGE, moreBase }); 232 } 220 233 221 234 recordPageview(site.id, req); … … 224 237 pinnedPosts, 225 238 posts, 239 hasMore, nextOffset: offset + FEED_PAGE, moreBase, 226 240 pageTitle: site.title, 227 241 socialDescr: site.description || site.tagline || '', … … 893 907 } 894 908 895 const FEED_PAGE = 72; // divisible by 2/3/4 → every grid column count keeps full rows896 909 router.get('/news', requireSiteManager, (req, res) => { 897 910 const site = res.locals.site;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)