diff --git a/server.js b/server.js index 4cee7bf..ee0e4cf 100644 --- a/server.js +++ b/server.js @@ -11,14 +11,26 @@ app.set('view engine', 'ejs'); app.use(express.static(__dirname + '/assets')); app.get(/\/.*/, function(req, res) { - console.log('Request for page: ' + req.path); let pathname = 'pages' + req.path; - - if ((pathname)[pathname.length - 1] === '/') { - pathname += 'index'; + let page = pathname.substr(pathname.lastIndexOf('/') + 1); + + if (pathname !== null && pathname !== undefined) { + if ((pathname)[pathname.length - 1] === '/') { + pathname += 'index'; + page = 'index'; + } + if (pathname.includes('projects') && page !== 'index') { + // projects has a custom template that is used for all projects + // so we need to change the pathname that the renderer is using + // to that template: + pathname = pathname.substr(0, pathname.lastIndexOf(page)); + pathname += 'project_template' + page = 'partials/md/' + page; + } } + console.log('request for path: ' + pathname + ', and page: ' + page); - res.render(pathname); + res.render(pathname, {"page": this.page}); }); app.listen(PORT); \ No newline at end of file diff --git a/views/pages/contact.ejs b/views/pages/contact.ejs index c9968b1..4a8271d 100644 --- a/views/pages/contact.ejs +++ b/views/pages/contact.ejs @@ -21,5 +21,4 @@ <% include ../partials/footer %> <% include ../partials/post_html_include %> - \ No newline at end of file diff --git a/views/pages/index.ejs b/views/pages/index.ejs index 156b535..64d66f7 100644 --- a/views/pages/index.ejs +++ b/views/pages/index.ejs @@ -17,7 +17,7 @@

welcome to lenordsNet

-

fake it til you make it

+

i dont know what im doing

diff --git a/views/pages/projects/project_template.ejs b/views/pages/projects/project_template.ejs new file mode 100644 index 0000000..bf4fb0a --- /dev/null +++ b/views/pages/projects/project_template.ejs @@ -0,0 +1,20 @@ + + + + + <% include ../../partials/include %> + + + +
+ <% include ../../partials/nav %> +
+ +
+ <% include(page) %> +
+ + <% include ../../partials/footer %> + <% include ../../partials/post_html_include %> + + \ No newline at end of file