%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/specpages-backup/node_modules/hexo/lib/plugins/processor/
Upload File :
Create Path :
Current File : /www/specpages-backup/node_modules/hexo/lib/plugins/processor/data.js

'use strict';

const { Pattern } = require('hexo-util');
const { extname } = require('path');

module.exports = ctx => ({
  pattern: new Pattern('_data/*path'),

  process: function dataProcessor(file) {
    const Data = ctx.model('Data');
    const { path } = file.params;
    const id = path.substring(0, path.length - extname(path).length);
    const doc = Data.findById(id);

    if (file.type === 'skip' && doc) {
      return;
    }

    if (file.type === 'delete') {
      if (doc) {
        return doc.remove();
      }

      return;
    }

    return file.render().then(result => {
      if (result == null) return;

      return Data.save({
        _id: id,
        data: result
      });
    });
  }
});

Zerion Mini Shell 1.0