Skip to content

Commit

Permalink
NEW: Placeholder Component Page
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Jun 6, 2024
1 parent f818368 commit 324b976
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion pages/Component/Component.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<main id=main class=component-page>

<h1>{{ language }}: <i class=inex>{{ component.form }}</i></h1>
{{#with component }}
<h1>{{ language }}: <i class=inex>{{ form }}</i></h1>
{{/with}}

<pre><code>{{ json }}</code></pre>

Expand Down
27 changes: 20 additions & 7 deletions pages/Component/Component.js
Original file line number Diff line number Diff line change
@@ -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 <code>${ componentID }</code> 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 }`,
})

}
2 changes: 0 additions & 2 deletions pages/Components/Components.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import db from '../../database/index.js'

export function Components(req, res) {

res.render(`Components/Components`, {
Expand Down

0 comments on commit 324b976

Please sign in to comment.