first posts

This commit is contained in:
2018-05-10 22:23:31 +02:00
parent 0686e02b75
commit 88b2cf4212
11 changed files with 234 additions and 62 deletions

12
dist/main.js vendored
View File

@ -12,11 +12,16 @@ app.engine('pag', (filePath, options, callback) => {
if (err) {
return callback(new Error(err.message));
}
let renderedPhase1 = content.toString()
let contentStr = content.toString();
let pageOptionsStr = contentStr.replace(/^\s+<!-- (\{.*\}) -->.*$/, "\$1");
logger.info(`contentStr: ${contentStr}`);
logger.info(`pageOptionsStr: ${pageOptionsStr}`);
let pageOptions = JSON.parse(pageOptionsStr);
let renderedPhase1 = contentStr
.replace('#bla#', 'blu');
let renderedPhase2 = masterTmpl
.replace('#maincontent#', renderedPhase1)
.replace('#title#', options.title);
.replace('#title#', pageOptions.title);
return callback(null, renderedPhase2);
});
});
@ -25,6 +30,9 @@ app.set('view engine', 'pag');
app.get('/index', (req, res) => {
res.render('index', { 'title': 'Projects - just for fun' });
});
app.get('/posts/:date', (req, res) => {
res.render(`posts/${req.params.date}/article`, {});
});
app.get('/', (req, res) => {
res.send('Hello world!');
});