2016-08-17 03:56:08 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
|
2016-08-27 05:04:08 +00:00
|
|
|
router.get('/edit/*', (req, res, next) => {
|
|
|
|
res.send('EDIT MODE');
|
|
|
|
});
|
|
|
|
|
|
|
|
router.get('/new/*', (req, res, next) => {
|
|
|
|
res.send('CREATE MODE');
|
|
|
|
});
|
|
|
|
|
2016-08-17 03:56:08 +00:00
|
|
|
/**
|
|
|
|
* Home
|
|
|
|
*/
|
2016-08-27 05:04:08 +00:00
|
|
|
router.get('/*', (req, res, next) => {
|
2016-08-20 04:50:29 +00:00
|
|
|
|
2016-08-27 05:04:08 +00:00
|
|
|
let safePath = entries.parsePath(req.path);
|
2016-08-20 21:20:53 +00:00
|
|
|
|
2016-08-27 05:04:08 +00:00
|
|
|
entries.fetch(safePath).then((pageData) => {
|
|
|
|
console.log(pageData);
|
|
|
|
if(pageData) {
|
|
|
|
res.render('pages/view', { pageData });
|
|
|
|
} else {
|
|
|
|
next();
|
2016-08-20 21:20:53 +00:00
|
|
|
}
|
2016-08-27 05:04:08 +00:00
|
|
|
}).catch((err) => {
|
|
|
|
next();
|
|
|
|
});
|
2016-08-20 04:50:29 +00:00
|
|
|
|
2016-08-17 03:56:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|