first posts
This commit is contained in:
15
src/main.ts
15
src/main.ts
@ -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!')
|
||||
})
|
||||
|
Reference in New Issue
Block a user