Add pagination to article categories and video pages, and enhance home page with more content and ads
Implement paginated API endpoints for articles and videos, add pagination UI to category and video pages, and inject additional ads and content widgets into the home page. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: c201f10b-bbd3-4402-9212-e0b79bfa670f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/EtK2Sno Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -86,6 +86,19 @@ export async function registerRoutes(
|
||||
});
|
||||
|
||||
app.get("/api/articles/category/:category", async (req, res) => {
|
||||
const page = parseInt(req.query.page as string);
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
if (page && page > 0) {
|
||||
const result = await storage.getArticlesByCategoryPaginated(req.params.category, page, limit);
|
||||
const totalPages = Math.ceil(result.total / limit);
|
||||
return res.json({
|
||||
articles: result.articles,
|
||||
total: result.total,
|
||||
page,
|
||||
totalPages,
|
||||
hasMore: page < totalPages,
|
||||
});
|
||||
}
|
||||
const articles = await storage.getArticlesByCategory(req.params.category);
|
||||
res.json(articles);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user