Added basic search functionality (no frontend for it yet)

This commit is contained in:
2025-09-30 23:15:33 +01:00
parent d27330a3db
commit 8ad8f01043
3 changed files with 78 additions and 1 deletions

View File

@@ -200,4 +200,21 @@ router.post("/submit_edit_post", (req,res) => {
}
}); // /submit_edit
router.get('/search', (req, res) => {
const search_term = req.query.q; // 'q' is the parameter name
let search_type = req.query.type; // eg 'any', 'post', 'user' etc...
if (typeof search_type == 'undefined') { // Default to 'any'
search_type = 'any';
}
console.log('searching for: ', search_term);
const search_results = data.searchdata(search_term, search_type); // data.searchdata returns an array of search results
res.render('partials/search', {
config,
locale,
search_results,
})
}); // /search
module.exports = router;