Skip to content

Instantly share code, notes, and snippets.

@LuisOsta
Created January 26, 2019 04:12
Show Gist options
  • Save LuisOsta/4baa0bc8d9ed0e8ac4c57223cc393001 to your computer and use it in GitHub Desktop.
Save LuisOsta/4baa0bc8d9ed0e8ac4c57223cc393001 to your computer and use it in GitHub Desktop.
updated header.hbs
<header>
{{!-- Here's where the site navigation will go --}}
<nav class="nav-container">
<ul class="nav-list">
<li class="nav-logo">Logo</li>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/more">More</a></li>
</ul>
</nav>
</header>
const express = require("express");
const path = require("path");
const hbs = require("hbs");
const app = express();
let PORT = 8080;
const publicPath = path.join(__dirname, "../../public");
app.use(express.static(publicPath));
// setups hbs view path, where express will look for files
const partialPath = path.join(__dirname, "../views/partials");
const viewPath = path.join(__dirname, "../views");
// configures express to use hbs
hbs.registerPartials(partialPath);
app.set("view engine", "hbs");
app.set("views", viewPath);
// base url for homepage
app.get("/", (req, res) => {
console.log("RENDERING THE HOME PAGE");
res.render("home.hbs"); // express looks for a file in the views directory,
//then compiles and renders them to the client
});
app.get('/about', (req, res) => {
console.log("RENDERING THE ABOUT PAGE")
res.render("about.hbs")
})
app.get('/more', (req, res) => {
console.log("RENDERING THE MORE PAGE")
res.render("more.hbs")
})
app.listen(PORT, () => {
console.log(`Server is up on port ${PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment