Added basic search functionality (no frontend for it yet)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user