Fix yaml metadata title should pass to generateWebTitle

This commit is contained in:
Wu Cheng-Han 2016-07-30 11:01:07 +08:00
parent 246c9da574
commit 0f4f270193

View file

@ -108,7 +108,7 @@ function responseHackMD(res, note) {
//na
}
var title = models.Note.decodeTitle(note.title);
title = models.Note.generateWebTitle(title);
title = models.Note.generateWebTitle(meta.title || title);
var template = config.hackmdpath;
var options = {
cache: !config.debug,
@ -117,7 +117,7 @@ function responseHackMD(res, note) {
var compiled = ejs.compile(fs.readFileSync(template, 'utf8'), options);
var html = compiled({
url: config.serverurl,
title: meta.title || title,
title: title,
useCDN: config.usecdn,
facebook: config.facebook,
twitter: config.twitter,
@ -225,10 +225,10 @@ function showPublishNote(req, res, next) {
var updatetime = note.lastchangeAt;
var text = S(body).escapeHTML().s;
var title = models.Note.decodeTitle(note.title);
title = models.Note.generateWebTitle(title);
title = models.Note.generateWebTitle(meta.title || title);
var origin = config.serverurl;
var data = {
title: meta.title || title,
title: title,
description: meta.description,
viewcount: note.viewcount,
createtime: createtime,
@ -537,6 +537,7 @@ function showPublishSlide(req, res, next) {
return response.errorNotFound(res);
}
var body = LZString.decompressFromBase64(note.content);
var meta = null;
try {
var obj = metaMarked(body);
body = obj.markdown;
@ -546,12 +547,12 @@ function showPublishSlide(req, res, next) {
}
var text = S(body).escapeHTML().s;
var title = models.Note.decodeTitle(note.title);
title = models.Note.generateWebTitle(title);
title = models.Note.generateWebTitle(meta.title || title);
var slides = md.slidify(text, slideOptions);
var origin = config.serverurl;
var data = {
url: origin,
title: meta.title || title,
title: title,
description: meta.description,
slides: slides,
GA: meta.GA,