Fix meta might be null issue
This commit is contained in:
parent
3bcb36b46c
commit
9bf7b92707
2 changed files with 5 additions and 1 deletions
|
@ -208,7 +208,8 @@ module.exports = function (sequelize, DataTypes) {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
//na
|
//na
|
||||||
}
|
}
|
||||||
if (meta && meta.title && (typeof meta.title == "string" || typeof meta.title == "number")) {
|
if (!meta) meta = {};
|
||||||
|
if (meta.title && (typeof meta.title == "string" || typeof meta.title == "number")) {
|
||||||
title = meta.title;
|
title = meta.title;
|
||||||
} else {
|
} else {
|
||||||
var $ = cheerio.load(md.render(body));
|
var $ = cheerio.load(md.render(body));
|
||||||
|
|
|
@ -108,6 +108,7 @@ function responseHackMD(res, note) {
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
//na
|
//na
|
||||||
}
|
}
|
||||||
|
if (!meta) meta = {};
|
||||||
var title = models.Note.decodeTitle(note.title);
|
var title = models.Note.decodeTitle(note.title);
|
||||||
title = models.Note.generateWebTitle(meta.title || title);
|
title = models.Note.generateWebTitle(meta.title || title);
|
||||||
var template = config.hackmdpath;
|
var template = config.hackmdpath;
|
||||||
|
@ -222,6 +223,7 @@ function showPublishNote(req, res, next) {
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
//na
|
//na
|
||||||
}
|
}
|
||||||
|
if (!meta) meta = {};
|
||||||
var createtime = note.createdAt;
|
var createtime = note.createdAt;
|
||||||
var updatetime = note.lastchangeAt;
|
var updatetime = note.lastchangeAt;
|
||||||
var text = S(body).escapeHTML().s;
|
var text = S(body).escapeHTML().s;
|
||||||
|
@ -546,6 +548,7 @@ function showPublishSlide(req, res, next) {
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
//na
|
//na
|
||||||
}
|
}
|
||||||
|
if (!meta) meta = {};
|
||||||
var text = S(body).escapeHTML().s;
|
var text = S(body).escapeHTML().s;
|
||||||
var title = models.Note.decodeTitle(note.title);
|
var title = models.Note.decodeTitle(note.title);
|
||||||
title = models.Note.generateWebTitle(meta.title || title);
|
title = models.Note.generateWebTitle(meta.title || title);
|
||||||
|
|
Loading…
Reference in a new issue