Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function (model, id, update, callback, hexo) {
var post = hexo.model(model).get(id)
if (!post) {
return callback('Post not found');
}
var config = hexo.config,
slug = post.slug = hfm.escape(post.slug || post.title, config.filename_case),
layout = post.layout = (post.layout || config.default_layout).toLowerCase(),
date = post.date = post.date ? moment(post.date) : moment();
var split = hfm.split(post.raw),
frontMatter = split.data
compiled = hfm.parse([frontMatter, '---', split.content].join('\n'));
var preservedKeys = ['title', 'date', 'tags', 'categories', '_content', 'keywords', 'description'];
var prev_full = post.full_source,
full_source = prev_full;
if (update.source && update.source !== post.source) {
// post.full_source only readable ~ see: /hexo/lib/models/post.js
full_source = hexo.source_dir + update.source
}
preservedKeys.forEach(function (attr) {
module.exports = function (model, id, update, callback, hexo) {
function removeExtname(str) {
return str.substring(0, str.length - path.extname(str).length);
}
var post = hexo.model(model).get(id)
if (!post) {
return callback('Post not found');
}
var config = hexo.config,
slug = post.slug = hfm.escape(post.slug || post.title, config.filename_case),
layout = post.layout = (post.layout || config.default_layout).toLowerCase(),
date = post.date = post.date ? moment(post.date) : moment();
var split = hfm.split(post.raw),
frontMatter = split.data
compiled = hfm.parse([frontMatter, '---', split.content].join('\n'));
var preservedKeys = ['title', 'date', 'tags', 'categories', '_content', 'author'];
Object.keys(hexo.config.metadata || {}).forEach(function (key) {
preservedKeys.push(key);
});
var prev_full = post.full_source,
full_source = prev_full;
if (update.source && update.source !== post.source) {
// post.full_source only readable ~ see: /hexo/lib/models/post.js
full_source = hexo.source_dir + update.source
function yamlHelper(data) {
return yaml.load(escape(data.text));
}
function yamlHelper(data) {
return yaml.load(escapeYAML(data.text));
}