added meta data to html rendering
This commit is contained in:
parent
cf08362a36
commit
a92f624b75
2 changed files with 26 additions and 5 deletions
|
@ -94,7 +94,11 @@ router.post('/publish-pages', (req, res) => {
|
||||||
getBookData()
|
getBookData()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
render
|
render
|
||||||
.publishAll(result.pages, result.settings.global.theme)
|
.publishAll(
|
||||||
|
result.pages,
|
||||||
|
result.settings.global.theme,
|
||||||
|
req.session.user.handle
|
||||||
|
)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
res.json({
|
res.json({
|
||||||
type: response.type,
|
type: response.type,
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default class Render {
|
||||||
* @parameter pages: payload for site pages
|
* @parameter pages: payload for site pages
|
||||||
* @parameter theme: current theme being used as defined in settings
|
* @parameter theme: current theme being used as defined in settings
|
||||||
*/
|
*/
|
||||||
publishAll(pages, theme) {
|
publishAll(pages, theme, author) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
settings
|
settings
|
||||||
.load(SETTINGS_FILE)
|
.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);
|
buffed = new StringUtils().decodeHTML(buffed);
|
||||||
let html = md.render(buffed, { html: true, xhtmlOut: true });
|
let html = md.render(buffed, { html: true, xhtmlOut: true });
|
||||||
let file = pug.renderFile(template, {
|
let file = pug.renderFile(template, {
|
||||||
title: page.metadata.title,
|
title: page.metadata.title,
|
||||||
default_bg: page.metadata.feature,
|
default_bg: page.metadata.feature,
|
||||||
content: html,
|
content: html,
|
||||||
tags: page.metadata.tags,
|
tags: tags,
|
||||||
menu: config.menu,
|
menu: config.menu,
|
||||||
|
meta: {
|
||||||
|
who: author,
|
||||||
|
when: moment(page.metadata.created).fromNow(),
|
||||||
|
tags: tags
|
||||||
|
},
|
||||||
welcome_message: page.metadata.title
|
welcome_message: page.metadata.title
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,7 +132,11 @@ export default class Render {
|
||||||
'/' +
|
'/' +
|
||||||
page.metadata.slug +
|
page.metadata.slug +
|
||||||
'.html'
|
'.html'
|
||||||
);
|
)
|
||||||
|
.then()
|
||||||
|
.catch(err => {
|
||||||
|
console.log('ERROR', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue