From a3a274ea61cbc27b8bf1296c69ae24c11188d003 Mon Sep 17 00:00:00 2001 From: Ro Date: Thu, 4 Jun 2020 19:50:08 -0700 Subject: [PATCH] made date pretty for dash index listing, quick style fix to compensate for long titles --- brain/routes/dash/index.js | 4 +++- brain/routes/dash/pages.js | 2 +- brain/views/partials/front.pug | 6 +++--- src/styles/main/_index.styl | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/brain/routes/dash/index.js b/brain/routes/dash/index.js index 5af8614..ce0b3f3 100644 --- a/brain/routes/dash/index.js +++ b/brain/routes/dash/index.js @@ -1,8 +1,10 @@ import Book from '../../data/Book'; const express = require('express'); +const moment = require('moment'); const router = express.Router(); const config = require('../../../site/settings.json'); const book = new Book(); + const indexLimit = 5; //-------------------------- @@ -16,7 +18,7 @@ router.get('/', function (req, res) { result.forEach(page => { if (typeof page.metadata.deleted === 'undefined' || page.metadata.deleted === false) { if (indexCount === indexLimit) return; - indexPages.push(page); + indexPages.push({ page: page, date: moment(page.metadata.created).fromNow() }); ++indexCount; } }); diff --git a/brain/routes/dash/pages.js b/brain/routes/dash/pages.js index d1c03ae..bcb0f26 100644 --- a/brain/routes/dash/pages.js +++ b/brain/routes/dash/pages.js @@ -126,7 +126,7 @@ router.get('/edit/:id', function (req, res) { title: 'Edit Page', welcome: 'Edit Page', page: page.metadata, - date: moment(page.metadata.created).format('YYYY MMM DD'), + date: moment(page.metadata.created).format('YYYY MMM DD HH:mm'), layout: page.metadata.layout, rawDate: page.metadata.created, content: page.content, diff --git a/brain/views/partials/front.pug b/brain/views/partials/front.pug index ee73e97..72ecf52 100644 --- a/brain/views/partials/front.pug +++ b/brain/views/partials/front.pug @@ -13,8 +13,8 @@ label this is empty else - for ( index; index < pages.length; index++) - a.post-link(href="/@/dashboard/page/edit/"+pages[index].metadata.uuid id=pages[index].metadata.uuid style="background:url("+pages[index].metadata.feature+") no-repeat center center / cover") + a.post-link(href="/@/dashboard/page/edit/"+pages[index].page.metadata.uuid id=pages[index].page.metadata.uuid style="background:url("+pages[index].page.metadata.feature+") no-repeat center center / cover") div - label= pages[index].metadata.title - span= pages[index].metadata.created + label= pages[index].page.metadata.title + span= pages[index].date diff --git a/src/styles/main/_index.styl b/src/styles/main/_index.styl index cc00271..123afc7 100644 --- a/src/styles/main/_index.styl +++ b/src/styles/main/_index.styl @@ -111,6 +111,7 @@ padding 5px vertical-align top display inline-block + word-wrap break-word width 60% span