mirror of
https://github.com/len0rd/personal-website.git
synced 2025-03-01 03:51:57 -05:00
modified server code and added project template. partially tested and appears to work so far
This commit is contained in:
parent
74588d1c60
commit
d77ca583ea
20
server.js
20
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;
|
||||
let page = pathname.substr(pathname.lastIndexOf('/') + 1);
|
||||
|
||||
if ((pathname)[pathname.length - 1] === '/') {
|
||||
pathname += 'index';
|
||||
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);
|
|
@ -21,5 +21,4 @@
|
|||
<% include ../partials/footer %>
|
||||
<% include ../partials/post_html_include %>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -17,7 +17,7 @@
|
|||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<h1 class="display-1">welcome to lenordsNet</h1>
|
||||
<h3 class="text-white">fake it til you make it</h3>
|
||||
<h3 class="text-white">i dont know what im doing</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
20
views/pages/projects/project_template.ejs
Normal file
20
views/pages/projects/project_template.ejs
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<% include ../../partials/include %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<% include ../../partials/nav %>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<% include(page) %>
|
||||
</div>
|
||||
|
||||
<% include ../../partials/footer %>
|
||||
<% include ../../partials/post_html_include %>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue