From c1615602c8a949893355bdda71d91e6d371b490a Mon Sep 17 00:00:00 2001 From: Ro Date: Thu, 11 Jun 2020 13:22:00 -0700 Subject: [PATCH] fixed page path bug, added path to nav ui and api payload, added navigation to render template methodology --- brain/data/Book.js | 2 +- brain/data/Render.js | 4 +++- brain/routes/dash/nav.js | 12 ++++++++---- brain/views/navigation.pug | 2 +- src/com/actions/NavActions.js | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/brain/data/Book.js b/brain/data/Book.js index 2479761..80496ac 100644 --- a/brain/data/Book.js +++ b/brain/data/Book.js @@ -102,7 +102,7 @@ export default class Book { 'path: ' + moment(body.created).format('YYYY') + '/' + - moment().format('MM') + + moment(body.created).format('MM') + '\n' + 'layout: ' + layout + diff --git a/brain/data/Render.js b/brain/data/Render.js index bfa1e2c..108cddd 100644 --- a/brain/data/Render.js +++ b/brain/data/Render.js @@ -2,6 +2,7 @@ import * as DataEvent from '../../src/com/events/DataEvent'; import StringUtils from '../../src/com/utils/StringUtils'; import fs from 'fs-extra'; import sanitize from 'sanitize-html'; +import Settings from './Settings'; const config = require('../../site/settings.json'); const tags_list = require('../../site/tags.json'); const pug = require('pug'); @@ -66,7 +67,8 @@ export default class Render { title: page.metadata.title, default_bg: page.metadata.feature, content: html, - tags: page.metadata.tags + tags: page.metadata.tags, + menu: config.menu }); fs.ensureDir(path).then(() => { diff --git a/brain/routes/dash/nav.js b/brain/routes/dash/nav.js index 76abaac..e6999a5 100644 --- a/brain/routes/dash/nav.js +++ b/brain/routes/dash/nav.js @@ -7,7 +7,7 @@ const book = new Book(); //-------------------------- // SETTINGS //-------------------------- -router.get('/', function(req, res) { +router.get('/', function (req, res) { if (req.session.user) { var nav = []; book.getPage() @@ -20,7 +20,8 @@ router.get('/', function(req, res) { id: item.id, uuid: item.uuid, title: item.title, - slug: item.slug + slug: item.slug, + path: item.path }); } } @@ -34,7 +35,8 @@ router.get('/', function(req, res) { id: item.id, uuid: item.uuid, title: item.title, - slug: item.slug + slug: item.slug, + path: item.path }); } for (let i = 0; i < newpages.length; i++) { @@ -45,7 +47,8 @@ router.get('/', function(req, res) { id: newpages[i].id, uuid: newpages[i].uuid, title: newpages[i].title, - slug: newpages[i].slug + slug: newpages[i].slug, + path: newpages[i].path }); } } @@ -59,6 +62,7 @@ router.get('/', function(req, res) { }) .catch(err => { //console.log('ERROR', err); + //render error pages }); } else { res.redirect('/@/dashboard'); diff --git a/brain/views/navigation.pug b/brain/views/navigation.pug index 3b5b19c..588510e 100644 --- a/brain/views/navigation.pug +++ b/brain/views/navigation.pug @@ -5,7 +5,7 @@ block main-content #nav-pages - var index = 0; - for ( index; index < menu.length; index++) - .nav-item(id=menu[index].id, data-slug=menu[index].slug, data-uuid=menu[index].uuid) + .nav-item(id=menu[index].id, data-slug=menu[index].slug, data-uuid=menu[index].uuid, data-path=menu[index].path) svg#item-arrows(viewBox="0 0 20 20" class="icons") use(xlink:href='/assets/images/global/sprite.svg#entypo-select-arrows') label diff --git a/src/com/actions/NavActions.js b/src/com/actions/NavActions.js index d9808d0..27dc62a 100644 --- a/src/com/actions/NavActions.js +++ b/src/com/actions/NavActions.js @@ -14,7 +14,8 @@ export default class NavActions { title: items[index].getElementsByTagName('label')[0].innerHTML, id: items[index].id, slug: items[index].getAttribute('data-slug'), - uuid: items[index].getAttribute('data-uuid') + uuid: items[index].getAttribute('data-uuid'), + path: items[index].getAttribute('data-path') }); } return new Promise(function (resolve) {