mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-23 07:19:28 -07:00
Gracefully handle fetching non-existing guides
This commit is contained in:
parent
a0fbbb698b
commit
2cfe8a7244
1 changed files with 14 additions and 5 deletions
|
@ -69,12 +69,21 @@ router.get('/guides', (req, res) => {
|
||||||
|
|
||||||
router.get('/guides/:guideId', (req, res) => {
|
router.get('/guides/:guideId', (req, res) => {
|
||||||
let env = {};
|
let env = {};
|
||||||
let rawContent = fs.readFileSync(`./content/guides/${req.params.guideId}.md`, "utf8", (err, data) => {
|
fs.readFile(`./content/guides/${req.params.guideId}.md`, "utf8", (err, data) => {
|
||||||
if (err) throw err;
|
if (err) {
|
||||||
return data;
|
res.render(`404`);
|
||||||
});
|
return
|
||||||
const content = md.render(rawContent, env);
|
}
|
||||||
|
|
||||||
|
const content = md.render(data, env);
|
||||||
res.render(`basic`, { title: `${env.title} - Keyoxide`, content: content });
|
res.render(`basic`, { title: `${env.title} - Keyoxide`, content: content });
|
||||||
|
});
|
||||||
|
// let rawContent = fs.readFileSync(`./content/guides/${req.params.guideId}.md`, "utf8", (err, data) => {
|
||||||
|
// if (err) throw err;
|
||||||
|
// return data;
|
||||||
|
// });
|
||||||
|
// const content = md.render(rawContent, env);
|
||||||
|
// res.render(`basic`, { title: `${env.title} - Keyoxide`, content: content });
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
Loading…
Reference in a new issue