diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-12-21 15:16:27 +0000 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-12-21 15:16:27 +0000 |
| commit | e70fd3594cfa8e0e29c3e9fb25991a9bad048469 (patch) | |
| tree | 6984c870820526bfc48ced41cbd5c0a1c580ad4f /app/middlewares | |
| parent | f4b697f0e4248ecbeb9606a113d602e28c740b38 (diff) | |
Seperate router modules from index.ts
Diffstat (limited to 'app/middlewares')
| -rw-r--r-- | app/middlewares/index.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/middlewares/index.ts b/app/middlewares/index.ts new file mode 100644 index 0000000..d0ba721 --- /dev/null +++ b/app/middlewares/index.ts @@ -0,0 +1,23 @@ +export const navbar = ((req, res, next) => { + let navbar = ''; + res.locals.directory.primaryPages.forEach(page => { + navbar += `<div class="navbar-element"><a href="/${page.standardName}"${(req.params.page ?? '' )== page.standardName ? ' class="highlight"' : ''}>${page.metadata.displayTitle}</a></div>`; + }) + res.locals.navbarHtml = navbar; + next(); +}); + +export const page = ((req, res, next) => { + let path = req.params.page ?? 'index'; + res.locals.path = path; + + let page = res.locals.directory.get(path); + + if (!page) { + next(); + return; + } + + res.locals.page = page; + next(); +}); |
