Making the latest topic as homepage?
-
Hello everyone,
I am a new user of NodeBB and I'm loving it so far! I have one request regarding the home page of my NodeBB forum. Is it possible to have the last created topic as the home page of my forum instead of the default categories or recent topics?
I have searched for a plugin that could do this, but I haven't found any. I would be grateful if someone could suggest a plugin that can make this happen.
Best!
-
Ha, that's a tricky one... there's no way to do this quickly. You'd need to create a plugin that would expose a new route (e.g.
/newest-topic
, or similar)... then in that route, you'd find the newest topic and callhelpers.redirect
to go to that actual topic. -
Yeah not sure if there is enough demand to put this in core, but fairly simple to do in a plugin. Create a new route like @julian suggested and then rewrite the url to the latest topic.
routeHelpers.setupPageRoute(router, '/latest', async (req, res, next) => { const db = require.main.require('./src/database'); const tid = await db.getSortedSetRevRange('topics:tid', 0, 0); req.url = res.locals.isAPI ? `/api/topic/${tid}` : `/topic/${tid}`; next(); });
Then you can set your homepage to latest and it will show the latest topic as homepage.