github.com/Jeffail/benthos/v3@v3.65.0/website/src/plugins/cookbooks/markdownLoader.js (about)

     1  /**
     2   * Copyright (c) 2017-present, Facebook, Inc.
     3   *
     4   * This source code is licensed under the MIT license found in the
     5   * LICENSE file in the root directory of this source tree.
     6   */
     7  
     8  const {parseQuery, getOptions} = require('loader-utils');
     9  const {loader} = require('webpack');
    10  const {truncate} = require('./cookbookUtils');
    11  
    12  module.exports = function(fileString) {
    13    const callback = this.async();
    14  
    15    const {truncateMarker} = getOptions(this);
    16  
    17    let finalContent = fileString;
    18  
    19    // Truncate content if requested (e.g: file.md?truncated=true)
    20    const {truncated} = this.resourceQuery && parseQuery(this.resourceQuery);
    21    if (truncated) {
    22      finalContent = truncate(fileString, truncateMarker);
    23    }
    24    return callback && callback(null, finalContent);
    25  };