From 0f4f270193261bf9d0e8fd8729b2d863a35ee5f0 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 30 Jul 2016 11:01:07 +0800 Subject: [PATCH] Fix yaml metadata title should pass to generateWebTitle --- lib/response.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/response.js b/lib/response.js index 2fc5d58d..1a6d1137 100644 --- a/lib/response.js +++ b/lib/response.js @@ -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,