-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
423 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
# vidjot | ||
# vidjot | ||
|
||
### init git repository | ||
|
||
### project dependencies | ||
|
||
``` | ||
1. npm install -g nodemon (auto restart server) | ||
2. npm install --save express | ||
3. npm install --save express-handlebar (template engine) | ||
``` | ||
|
||
### Create Handlebar | ||
|
||
``` | ||
1. Create Middleware | ||
const exphbs = require("express-handlebars"); | ||
// express handlebar middleware | ||
app.engine("handlebars", exphbs({ defaultLayout: "main" })); | ||
app.set("view engine", "handlebars"); | ||
2. Create Views Folder | ||
- views/index.handlebars (Index Section View) | ||
- views/about.handlebars (About Section View) | ||
- views/layouts/main.handlebars (HTML Body View) | ||
- views/partials/_navbar.handlebars (Partial Body / Navgiation Bar) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const express = require("express"); | ||
const exphbs = require("express-handlebars"); | ||
const app = express(); | ||
|
||
// express handlebar middleware | ||
app.engine("handlebars", exphbs({ defaultLayout: "main" })); | ||
app.set("view engine", "handlebars"); | ||
|
||
// Index route | ||
app.get("/", (req, res) => { | ||
const title = "Vidjot Title"; | ||
res.render("index", { title }); | ||
}); | ||
|
||
// About route | ||
app.get("/about", (req, res) => { | ||
res.render("about"); | ||
}); | ||
|
||
const port = 5000; | ||
app.listen(port, () => console.log(`Server running on port ${port}`)); |
Oops, something went wrong.