@apleasantview/eleventy-plugin-baseline 0.1.0-next.16 → 0.1.0-next.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,10 @@ import modules from "./core/modules.js";
6
6
  import shortcodes from "./core/shortcodes.js";
7
7
  import { eleventyImageOnRequestDuringServePlugin } from "@11ty/eleventy-img";
8
8
 
9
+ import { createRequire } from "node:module";
10
+ const require = createRequire(import.meta.url);
11
+ const { version } = require("./package.json");
12
+
9
13
  /**
10
14
  * Eleventy Plugin Baseline.
11
15
  *
@@ -32,6 +36,7 @@ export default function baseline(options = {}) {
32
36
  }
33
37
 
34
38
  const userOptions = {
39
+ version: version,
35
40
  verbose: options.verbose ?? false,
36
41
  enableNavigatorTemplate: options.enableNavigatorTemplate ?? false,
37
42
  enableSitemapTemplate: options.enableSitemapTemplate ?? true,
@@ -14,9 +14,11 @@ export default async function inlineESbuild(jsFilePath, options = {}) {
14
14
  write: false
15
15
  });
16
16
 
17
- return `<script>${result.outputFiles[0].text}</script>`;
17
+ // Return raw JS; markup wrapping is handled by the plugin registration.
18
+ return result.outputFiles[0].text;
18
19
  } catch (error) {
19
20
  console.error(error);
20
- return `<script>/* Error processing JS */</script>`;
21
+ // Surface a safe JS comment so the caller can decide how to wrap it.
22
+ return "/* Error processing JS */";
21
23
  }
22
24
  }
@@ -49,30 +49,26 @@ export default function assetsESBuild(eleventyConfig, options = {}) {
49
49
  }
50
50
  });
51
51
 
52
- // Filter to inline a bundled entry.
53
- eleventyConfig.addFilter("inlineESbuild", inlineESbuild);
54
-
55
- // Filter to inline a bundled entry (async, works with callback or promise).
52
+ // Filter to inline a bundled entry; supports callback style (Nunjucks/Liquid) and Promise return.
56
53
  eleventyConfig.addAsyncFilter("inlineESbuild", async function (jsFilePath, callback) {
57
54
  const done = typeof callback === "function" ? callback : null;
58
55
  try {
59
- const html = await inlineESbuild(jsFilePath);
56
+ const js = await inlineESbuild(jsFilePath);
57
+ const html = `<script>${js}</script>`;
60
58
  if (done) return done(null, html);
61
59
  return html;
62
60
  } catch (error) {
63
- if (done) return done(error);
64
- throw error;
61
+ // Non-fatal fallback: return an error comment wrapped in script tags.
62
+ const html = `<script>/* Error processing JS */</script>`;
63
+ if (done) return done(null, html);
64
+ return html;
65
65
  }
66
66
  });
67
67
 
68
68
  // Override the default collection behavior. Adding js as template format and extension collects 11tydata.js files.
69
69
  eleventyConfig.addCollection("all", function (collectionApi) {
70
70
  return collectionApi.getAll().filter(item => {
71
- // Skip 11tydata.js files
72
- if (item.inputPath.endsWith('11tydata.js')) {
73
- return false;
74
- }
75
- return true;
71
+ return !item.inputPath.endsWith("11tydata.js");
76
72
  });
77
73
  });
78
74
  };
@@ -28,9 +28,11 @@ export default async function inlinePostCSS(cssFilePath) {
28
28
  map: options?.map
29
29
  });
30
30
 
31
- return `<style>${result.css}</style>`;
31
+ // Return raw CSS; markup wrapping is handled in the plugin registration.
32
+ return result.css;
32
33
  } catch (error) {
33
34
  console.error(error);
34
- return `<style>/* Error processing CSS */</style>`;
35
+ // Surface a safe CSS string so the caller can decide how to wrap it.
36
+ return "/* Error processing CSS */";
35
37
  }
36
38
  }
@@ -61,12 +61,15 @@ export default function assetsPostCSS(eleventyConfig) {
61
61
  eleventyConfig.addAsyncFilter("inlinePostCSS", async function (cssFilePath, callback) {
62
62
  const done = typeof callback === "function" ? callback : null;
63
63
  try {
64
- const html = await inlinePostCSS(cssFilePath);
64
+ const css = await inlinePostCSS(cssFilePath);
65
+ const html = `<style>${css}</style>`;
65
66
  if (done) return done(null, html);
66
67
  return html;
67
68
  } catch (error) {
68
- if (done) return done(error);
69
- throw error;
69
+ // Keep behavior non-fatal: return a styled error comment instead of throwing.
70
+ const html = `<style>/* Error processing CSS */</style>`;
71
+ if (done) return done(null, html);
72
+ return html;
70
73
  }
71
74
  });
72
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apleasantview/eleventy-plugin-baseline",
3
- "version": "0.1.0-next.16",
3
+ "version": "0.1.0-next.18",
4
4
  "description": "An experimental Swiss army knife toolkit for Eleventy",
5
5
  "type": "module",
6
6
  "main": "eleventy.config.js",