added meta data to html rendering

pull/20/head
Ro 5 years ago
parent cf08362a36
commit a92f624b75

@ -94,7 +94,11 @@ router.post('/publish-pages', (req, res) => {
getBookData()
.then(result => {
render
.publishAll(result.pages, result.settings.global.theme)
.publishAll(
result.pages,
result.settings.global.theme,
req.session.user.handle
)
.then(response => {
res.json({
type: response.type,

@ -24,7 +24,7 @@ export default class Render {
* @parameter pages: payload for site pages
* @parameter theme: current theme being used as defined in settings
*/
publishAll(pages, theme) {
publishAll(pages, theme, author) {
return new Promise((resolve, reject) => {
settings
.load(SETTINGS_FILE)
@ -68,15 +68,28 @@ export default class Render {
]
}
});
let bag = page.metadata.tags.split(',');
let tags = [];
for (let index = 0; index < bag.length; index++) {
let tag = bag[index].trim();
tags.push({
label: bag[index],
slug: new StringUtils().cleanString(tag)
});
}
buffed = new StringUtils().decodeHTML(buffed);
let html = md.render(buffed, { html: true, xhtmlOut: true });
let file = pug.renderFile(template, {
title: page.metadata.title,
default_bg: page.metadata.feature,
content: html,
tags: page.metadata.tags,
tags: tags,
menu: config.menu,
meta: {
who: author,
when: moment(page.metadata.created).fromNow(),
tags: tags
},
welcome_message: page.metadata.title
});
@ -119,7 +132,11 @@ export default class Render {
'/' +
page.metadata.slug +
'.html'
);
)
.then()
.catch(err => {
console.log('ERROR', err);
});
}
}
}

Loading…
Cancel
Save