diff --git a/index.js b/index.js index fc8137ef..98c461f0 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ app.get(`/grammar`, handlers.md(`Grammar`)) app.get(`/research`, handlers.md(`Research`)) app.get(`/research/:pub`, handlers.Research) app.get(`/components`, handlers.Components) -app.get(`/components/:component`, handlers.Component) +app.get(`/components/:componentID`, handlers.Component) app.use(handlers.PageNotFound) app.use(handlers.ServerError) diff --git a/pages/Component/Component.hbs b/pages/Component/Component.hbs index e6f4de93..283adff5 100644 --- a/pages/Component/Component.hbs +++ b/pages/Component/Component.hbs @@ -1,6 +1,8 @@
-

{{ language }}: {{ component.form }}

+ {{#with component }} +

{{ language }}: {{ form }}

+ {{/with}}
{{ json }}
diff --git a/pages/Component/Component.js b/pages/Component/Component.js index 0f94ccb8..c2c8f4db 100644 --- a/pages/Component/Component.js +++ b/pages/Component/Component.js @@ -1,20 +1,33 @@ +import db from '../../database/index.js' + export function Component(req, res) { - const component = { - form: `-a·mɛhk-`, - id: 1234, - } + const { componentID } = req.params + const component = db.index.get(componentID) + + if (!component) { + + const status = 404 - const language = `Menominee` + res.status = status + + return res.render(`Error/Error.md`, { + cssClass: `error`, + Error: true, + message: `A component with ID ${ componentID } does not exist.`, + status, + title: `Component Not Found`, + }) + + } res.render(`Component/Component`, { component, Component: true, construction: true, json: JSON.stringify(component, null, 2), - language, pageCSS: res.app.locals.styles.Component, - title: `${ language }: ${ component.form }`, + title: `${ component.language }: ${ component.form }`, }) } diff --git a/pages/Components/Components.js b/pages/Components/Components.js index 59e0c62e..24cf0314 100644 --- a/pages/Components/Components.js +++ b/pages/Components/Components.js @@ -1,5 +1,3 @@ -import db from '../../database/index.js' - export function Components(req, res) { res.render(`Components/Components`, {