Skip to content

Commit

Permalink
feat(templating): separate into layout and views
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyhm committed Sep 13, 2023
1 parent 7da65d1 commit 3c0163e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
13 changes: 10 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const express = require('express')
const handlebars = require('express-handlebars');

const path = require('path')
const app = express()
const port = 3000

app.get('/', (req, res) => {

const filePath = path.join(__dirname, 'index.html')

res.sendFile(filePath)
app.engine('handlebars', handlebars.engine());
app.set("view engine", "handlebars")
app.set('views', './views');

app.get('/', (req, res) => {
res.render("home", {
pageTitle: "MyRepoStats"
})
})

app.listen(port, () => {
Expand Down
18 changes: 0 additions & 18 deletions index.html

This file was deleted.

8 changes: 8 additions & 0 deletions views/home.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<header>
<h1>MyRepoStats</h1>
</header>
<h2>When are commits typically made during the day?</h2>
<h3>Morning: 10%</h3>
<h3>Afternoon: 60%</h3>
<h3>Evening: 20%</h3>
<h3>Night: 10%</h3>
11 changes: 11 additions & 0 deletions views/layouts/main.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
<head>
<title>{{pageTitle}}</title>
</head>
<body>
{{{body}}}
</body>
<footer>
<p>Source: <a href="https://github.com/freddyhm/myrepostats">https://github.com/freddyhm/myrepostats</a></p>
</footer>
</html>

0 comments on commit 3c0163e

Please sign in to comment.