UNPKG

839 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.plugin = void 0;
4const config_js_1 = require("./config.js");
5const plugin = async (schema, documents, config) => {
6 const placement = config.placement || 'prepend';
7 const { content } = config;
8 if (!config_js_1.VALID_PLACEMENTS.includes(placement)) {
9 throw Error(`Configuration provided for 'add' plugin is invalid: value of 'placement' field is not valid (valid values are: ${config_js_1.VALID_PLACEMENTS.join(', ')})`);
10 }
11 if (!content) {
12 throw Error(`Configuration provided for 'add' plugin is invalid: "content" is missing!`);
13 }
14 return {
15 content: null,
16 [placement]: Array.isArray(content) ? content : [content],
17 };
18};
19exports.plugin = plugin;
20exports.default = { plugin: exports.plugin };