diff --git a/web-server/src/app.js b/web-server/src/app.js index b9ec236..6d5adaf 100644 --- a/web-server/src/app.js +++ b/web-server/src/app.js @@ -1,22 +1,25 @@ const path = require('path') const express = require('express') +const hbs = require('hbs') const app = express() // Define paths for Express config const publicDirectoryPath = path.join(__dirname, '../public') -const viewsPath = path.join(__dirname, '../templates') +const viewsPath = path.join(__dirname, '../templates/views') +const partialsPath = path.join(__dirname, '../templates/partials') // Setup handlebars engine and views location app.set('view engine', 'hbs') app.set('views', viewsPath) +hbs.registerPartials(partialsPath) // Setup static directory to serve app.use(express.static(publicDirectoryPath)) app.get('', (req, res) => { res.render('index', { - title: 'Weather App', + title: 'Weather', name: 'Jason Williams' }) }) @@ -30,7 +33,9 @@ app.get('/about', (req, res) => { app.get('/help', (req, res) => { res.render('help', { - helpText: 'This is some helpful text.' + helpText: 'This is some helpful text.', + title: 'Help', + name: 'Jason Williams' }) }) diff --git a/web-server/templates/partials/footer.hbs b/web-server/templates/partials/footer.hbs new file mode 100644 index 0000000..78cd476 --- /dev/null +++ b/web-server/templates/partials/footer.hbs @@ -0,0 +1 @@ +
Created by {{name}}
diff --git a/web-server/templates/partials/header.hbs b/web-server/templates/partials/header.hbs new file mode 100644 index 0000000..2a7d7ad --- /dev/null +++ b/web-server/templates/partials/header.hbs @@ -0,0 +1,7 @@ +Created by {{name}}
+ {{>footer}}