|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
import Book from '../../data/Book';
|
|
|
|
|
const express = require('express');
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
const hljs = require('highlight.js/lib/highlight');
|
|
|
|
|
const hljs_md = require('highlight.js/lib/languages/markdown');
|
|
|
|
|
const moment = require('moment');
|
|
|
|
|
const book = new Book();
|
|
|
|
|
const uuidv4 = require('uuid/v4');
|
|
|
|
|
const settings = require('../../../site/settings.json');
|
|
|
|
|
hljs.registerLanguage('markdown', hljs_md);
|
|
|
|
|
//--------------------------
|
|
|
|
|
// POSTS
|
|
|
|
|
//--------------------------
|
|
|
|
@ -15,7 +12,7 @@ router.get('/list/:filter?/:page?', function(req, res) {
|
|
|
|
|
var pageNum = req.params.page;
|
|
|
|
|
var filter = req.params.filter;
|
|
|
|
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
|
|
|
|
if (filter == '' || filter == null) filter = "all";
|
|
|
|
|
if (filter == '' || filter == null) filter = 'all';
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
book.getPage()
|
|
|
|
|
.then(pages => {
|
|
|
|
@ -118,7 +115,6 @@ router.get('/edit/:id', function(req, res) {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
book.getPage(id)
|
|
|
|
|
.then(page => {
|
|
|
|
|
let pretty = hljs.highlight('markdown', page.content).value;
|
|
|
|
|
res.render('page-edit', {
|
|
|
|
|
id: page.metadata.id,
|
|
|
|
|
uuid: page.metadata.uuid,
|
|
|
|
@ -127,7 +123,7 @@ router.get('/edit/:id', function(req, res) {
|
|
|
|
|
page: page.metadata,
|
|
|
|
|
date: moment(page.metadata.created).format('YYYY MMM DD'),
|
|
|
|
|
rawDate: page.metadata.created,
|
|
|
|
|
colored: pretty,
|
|
|
|
|
content: page.content,
|
|
|
|
|
feature: page.metadata.feature,
|
|
|
|
|
status: [
|
|
|
|
|
String(page.metadata.menu),
|
|
|
|
|