From 8bf1fe07ba1c176438453b8f18c399d4a56f5b14 Mon Sep 17 00:00:00 2001 From: len0rd Date: Fri, 27 Jul 2018 13:32:34 -0400 Subject: [PATCH] added basic contact page, fixed server and nav to handle it --- server.js | 17 +++++++++++------ views/pages/contact.ejs | 21 +++++++++++++++++++++ views/partials/nav.ejs | 4 ++-- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 views/pages/contact.ejs diff --git a/server.js b/server.js index a0c7817..f133c81 100644 --- a/server.js +++ b/server.js @@ -6,13 +6,18 @@ console.log('Hello'); // set the view engine to ejs app.set('view engine', 'ejs'); -// use res.render to load an ejs view file - -app.get('/', function(req, res) { - res.render('pages/index'); -}); - // add folder for static content: app.use(express.static(__dirname + '/assets')); +app.get(/\/.*/, function(req, res) { + console.log(req.path); + let pathname = 'pages' + req.path; + + if ((pathname)[pathname.length - 1] === '/') { + pathname += 'index'; + } + + res.render(pathname); +}); + app.listen(8090); \ No newline at end of file diff --git a/views/pages/contact.ejs b/views/pages/contact.ejs new file mode 100644 index 0000000..90bf7a3 --- /dev/null +++ b/views/pages/contact.ejs @@ -0,0 +1,21 @@ + + + + + <% include ../partials/include %> + + + + <% include ../partials/nav %> +
+
+
+

Contact me

+

As a lonly explorer of the interwebs, I welcome the warm embrace of human contact. Please email me with the below address:

+

contact@lenord.me

+
+
+
+ + + \ No newline at end of file diff --git a/views/partials/nav.ejs b/views/partials/nav.ejs index 5485aee..16284e0 100644 --- a/views/partials/nav.ejs +++ b/views/partials/nav.ejs @@ -1,7 +1,7 @@ \ No newline at end of file