From f41419a436252f7b320e295f6f6172315cc10ad8 Mon Sep 17 00:00:00 2001 From: "Graham F. Scott" Date: Sun, 8 Dec 2024 14:43:06 -0500 Subject: [PATCH 1/2] Deduplicate active plugin list when using 'add' option --- packages/everything/lib/configOptions.js | 3 ++- packages/everything/test/test-configOptions.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/everything/lib/configOptions.js b/packages/everything/lib/configOptions.js index a1cf6e55..7f5df983 100644 --- a/packages/everything/lib/configOptions.js +++ b/packages/everything/lib/configOptions.js @@ -21,8 +21,9 @@ module.exports = function(options = {}) { function setActivePlugins(obj) { let active = [...defaultPlugins]; // default // Add to default plugin list + // The `Set` ensures there are no duplicates if (obj.add) { - active = [...defaultPlugins, ...obj.add]; + active = [...new Set([...defaultPlugins, ...obj.add])]; } // Define custom plugin list from scratch. // Will always override `add` diff --git a/packages/everything/test/test-configOptions.js b/packages/everything/test/test-configOptions.js index a8465b17..58204bdb 100644 --- a/packages/everything/test/test-configOptions.js +++ b/packages/everything/test/test-configOptions.js @@ -70,6 +70,17 @@ test( }, ); +test( + `Config "add" option returns deduplicated output when adding plugins already included by default`, + (t) => { + let output = config({ + // These are already active by default, so `add`ing should do nothing + add: ["youtube", "vimeo"], + }); + t.deepEqual(output, defaultOptions); + }, +) + test( `Config returns expected output with valid "use" option`, (t) => { From 1fd1ba81d920f65d9ba9cb32d2d9b2a5ac79e9a3 Mon Sep 17 00:00:00 2001 From: "Graham F. Scott" Date: Sun, 8 Dec 2024 14:51:51 -0500 Subject: [PATCH 2/2] Changeset --- .changeset/green-cameras-invent.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/green-cameras-invent.md diff --git a/.changeset/green-cameras-invent.md b/.changeset/green-cameras-invent.md new file mode 100644 index 00000000..911f2889 --- /dev/null +++ b/.changeset/green-cameras-invent.md @@ -0,0 +1,5 @@ +--- +"eleventy-plugin-embed-everything": patch +--- + +Deduplicate list of active plugins when using the 'add' option