How to use the hexo-front-matter.escape function in hexo-front-matter

To help you get started, we’ve selected a few hexo-front-matter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 52cik / hexo-admin-cn / update.js View on Github external
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) {
github jaredly / hexo-admin / update.js View on Github external
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
github hexojs / hexo / lib / plugins / renderer / yaml.js View on Github external
function yamlHelper(data) {
  return yaml.load(escape(data.text));
}
github zhuzhuyule / HexoEditor / views / main / hexo / plugins / renderer / yaml.js View on Github external
function yamlHelper(data) {
  return yaml.load(escapeYAML(data.text));
}

hexo-front-matter

Front-matter parser.

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis