From 7a52ddeba2a68388b544f529d2d92104420f77b0 Mon Sep 17 00:00:00 2001 From: Shipwreckt Date: Fri, 31 Oct 2025 20:02:14 +0000 Subject: Changed from static to 11ty! --- .../eleventy/src/Plugins/HtmlRelativeCopyPlugin.js | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 node_modules/@11ty/eleventy/src/Plugins/HtmlRelativeCopyPlugin.js (limited to 'node_modules/@11ty/eleventy/src/Plugins/HtmlRelativeCopyPlugin.js') diff --git a/node_modules/@11ty/eleventy/src/Plugins/HtmlRelativeCopyPlugin.js b/node_modules/@11ty/eleventy/src/Plugins/HtmlRelativeCopyPlugin.js new file mode 100644 index 0000000..ac1391d --- /dev/null +++ b/node_modules/@11ty/eleventy/src/Plugins/HtmlRelativeCopyPlugin.js @@ -0,0 +1,52 @@ +import { HtmlRelativeCopy } from "../Util/HtmlRelativeCopy.js"; + +// one HtmlRelativeCopy instance per entry +function init(eleventyConfig, options) { + let opts = Object.assign( + { + extensions: "html", + match: false, // can be one glob string or an array of globs + paths: [], // directories to also look in for files + failOnError: true, // fails when a path matches (via `match`) but not found on file system + copyOptions: undefined, + }, + options, + ); + + let htmlrel = new HtmlRelativeCopy(); + htmlrel.setUserConfig(eleventyConfig); + htmlrel.addMatchingGlob(opts.match); + htmlrel.setFailOnError(opts.failOnError); + htmlrel.setCopyOptions(opts.copyOptions); + + eleventyConfig.htmlTransformer.addUrlTransform( + opts.extensions, + function (targetFilepathOrUrl) { + // @ts-ignore + htmlrel.copy(targetFilepathOrUrl, this.page.inputPath, this.page.outputPath); + + // TODO front matter option for manual copy + return targetFilepathOrUrl; + }, + { + enabled: () => htmlrel.isEnabled(), + // - MUST run after other plugins but BEFORE HtmlBase plugin + priority: -1, + }, + ); + + htmlrel.addPaths(opts.paths); +} + +function HtmlRelativeCopyPlugin(eleventyConfig) { + // Important: if this is empty, no URL transforms are added + for (let options of eleventyConfig.passthroughCopiesHtmlRelative) { + init(eleventyConfig, options); + } +} + +Object.defineProperty(HtmlRelativeCopyPlugin, "eleventyPackage", { + value: "@11ty/eleventy/html-relative-copy-plugin", +}); + +export { HtmlRelativeCopyPlugin }; -- cgit v1.2.3