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

View File

@ -18,12 +18,19 @@ app.engine('pag', (filePath: string, options: any, callback: any) => {
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)
})
})
@ -35,6 +42,10 @@ 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!')
})