From 3c0ebc7001f444a3471c5154c87ebd9d4ee96b29 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Tue, 1 Nov 2022 23:55:07 -0400 Subject: [PATCH] Initial express.js project structure --- assets/styles/gargoyle.scss | 24 +++++++++++++++++++++--- index.js | 22 ++++++++++++++++++++++ package.json | 1 + src/routes/home.js | 4 ++++ views/index.twig | 2 ++ 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 index.js create mode 100644 src/routes/home.js diff --git a/assets/styles/gargoyle.scss b/assets/styles/gargoyle.scss index 4de8b1b..eb8b85c 100644 --- a/assets/styles/gargoyle.scss +++ b/assets/styles/gargoyle.scss @@ -1,10 +1,17 @@ -$nav-bar-height: 50px; +$primary-color: orange; +$primary-color-highlight: darken($primary-color, 10%); + +$nav-bar-height: 60px; body{ padding: $nav-bar-height 0 0; background: lightgrey; } +.container.fluid{ + max-width: 100%; +} + #nav-bar{ position: fixed; top: 0; @@ -13,6 +20,7 @@ body{ height: $nav-bar-height; background: #212121; box-shadow: 0 2px 1px rgba(0, 0, 0, .25); + color: white; .nav-bar-left{ float: left; @@ -26,12 +34,22 @@ body{ } } + .site-logo, .nav-link a{ - color: teal; + padding: 9px 12px; + font-size: 2.5rem; + } + + .site-logo{ + font-weight: bold; + } + + .nav-link a{ + color: $primary-color; transition: all 230ms ease-in-out; &:hover{ - color: green; + color: $primary-color-highlight; } } } diff --git a/index.js b/index.js new file mode 100644 index 0000000..8de9e9b --- /dev/null +++ b/index.js @@ -0,0 +1,22 @@ +const express = require('express'); + +// instantiate new express.js app +const app = express(); +const port = 3000; + +// load the template engine +app.set('view engine', 'twig'); + +// enable static file serving +app.use(express.static('public')); + +// load route handlers +const homeRoutes = require('./src/routes/home'); + +// register route handlers +app.get('/', homeRoutes.getIndex); + +// start app +app.listen(port, () => { + console.log(`Example app listening on port ${port}`); +}); diff --git a/package.json b/package.json index d36b76c..353d69d 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Self-hosted inventory tracker", "main": "index.js", "scripts": { + "start": "node index.js", "gulp": "gulp", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/src/routes/home.js b/src/routes/home.js new file mode 100644 index 0000000..7ede400 --- /dev/null +++ b/src/routes/home.js @@ -0,0 +1,4 @@ +// GET - / +exports.getIndex = function (req, res) { + res.render('index.twig'); +}; diff --git a/views/index.twig b/views/index.twig index ad45fb7..d92a823 100644 --- a/views/index.twig +++ b/views/index.twig @@ -1,5 +1,7 @@ {% extends 'layout.twig' %} +{% block title %}Home{% endblock %} + {% block content %}