aboutsummaryrefslogtreecommitdiff
path: root/src/routes/index.js
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-11-05 22:44:56 +0000
committerAkshay <[email protected]>2024-11-05 22:44:56 +0000
commit47b4fd3b1233353e56c99c0b9a5a8633d8bc2617 (patch)
treee189fc34780bd67146bb6301dd28b4f803405b7f /src/routes/index.js
parentf1bf73b65a29cb733651b1c990e27f84769dc5c3 (diff)
subs as home page
Diffstat (limited to 'src/routes/index.js')
-rw-r--r--src/routes/index.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/routes/index.js b/src/routes/index.js
index f60fd96..7fe9e2a 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -6,12 +6,13 @@ const G = new geddit.Geddit();
6 6
7// GET / 7// GET /
8router.get("/", async (req, res) => { 8router.get("/", async (req, res) => {
9 res.redirect("/r/all"); 9 res.render("home");
10}); 10});
11 11
12// GET /r/:id 12// GET /r/:id
13router.get("/r/:subreddit", async (req, res) => { 13router.get("/r/:subreddit", async (req, res) => {
14 const subreddit = req.params.subreddit; 14 const subreddit = req.params.subreddit;
15 const isMulti = subreddit.includes("+");
15 const query = req.query ? req.query : {}; 16 const query = req.query ? req.query : {};
16 if (!query.sort) { 17 if (!query.sort) {
17 query.sort = "hot"; 18 query.sort = "hot";
@@ -22,7 +23,7 @@ router.get("/r/:subreddit", async (req, res) => {
22 23
23 const [posts, about] = await Promise.all([postsReq, aboutReq]); 24 const [posts, about] = await Promise.all([postsReq, aboutReq]);
24 25
25 res.render("index", { subreddit, posts, about, query }); 26 res.render("index", { subreddit, posts, about, query, isMulti });
26}); 27});
27 28
28// GET /comments/:id 29// GET /comments/:id