diff options
| author | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
|---|---|---|
| committer | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
| commit | 7a52ddeba2a68388b544f529d2d92104420f77b0 (patch) | |
| tree | 15ddd47457a2cb4a96060747437d36474e4f6b4e /node_modules/@11ty/eleventy/src/TemplateGlob.js | |
| parent | 53d6ae2b5568437afa5e4995580a3fb679b7b91b (diff) | |
Changed from static to 11ty!
Diffstat (limited to 'node_modules/@11ty/eleventy/src/TemplateGlob.js')
| -rw-r--r-- | node_modules/@11ty/eleventy/src/TemplateGlob.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/@11ty/eleventy/src/TemplateGlob.js b/node_modules/@11ty/eleventy/src/TemplateGlob.js new file mode 100644 index 0000000..9db85e9 --- /dev/null +++ b/node_modules/@11ty/eleventy/src/TemplateGlob.js @@ -0,0 +1,35 @@ +import { TemplatePath } from "@11ty/eleventy-utils"; + +class TemplateGlob { + static normalizePath(...paths) { + if (paths[0].charAt(0) === "!") { + throw new Error( + `TemplateGlob.normalizePath does not accept ! glob paths like: ${paths.join("")}`, + ); + } + return TemplatePath.addLeadingDotSlash(TemplatePath.join(...paths)); + } + + static normalize(path) { + path = path.trim(); + if (path.charAt(0) === "!") { + return "!" + TemplateGlob.normalizePath(path.slice(1)); + } else { + return TemplateGlob.normalizePath(path); + } + } + + static map(files) { + if (typeof files === "string") { + return TemplateGlob.normalize(files); + } else if (Array.isArray(files)) { + return files.map(function (path) { + return TemplateGlob.normalize(path); + }); + } else { + return files; + } + } +} + +export default TemplateGlob; |
