@apleasantview/eleventy-plugin-baseline 0.1.0-next.14 → 0.1.0-next.15

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.
@@ -34,6 +34,7 @@ function pickRenditions(metadata) {
34
34
  * @param {string} [options.outputDir=DEFAULT_OUTPUT.outputDir] Output directory for generated assets.
35
35
  * @param {string} [options.urlPath=DEFAULT_OUTPUT.urlPath] Public URL base for generated assets.
36
36
  * @param {Object} [options.attrs={}] Extra attributes applied to <img>; `class` merges with imageClass.
37
+ * @param {string} [options.style] Inline style applied to <img> (alias for attrs.style).
37
38
  * @param {boolean} [options.figure=true] Wrap in <figure> when caption is provided.
38
39
  * @param {boolean} [options.setDimensions=true] When false, omit width/height on <img>.
39
40
  */
@@ -45,6 +46,7 @@ export async function imageShortcode(options = {}) {
45
46
  loading = "lazy",
46
47
  containerClass = "",
47
48
  imageClass = "",
49
+ style,
48
50
  widths = DEFAULT_WIDTHS,
49
51
  sizes = DEFAULT_SIZES,
50
52
  formats = DEFAULT_FORMATS,
@@ -62,6 +64,9 @@ export async function imageShortcode(options = {}) {
62
64
  );
63
65
  }
64
66
 
67
+ const normalizedCaption = caption == null ? "" : String(caption);
68
+ const normalizedAlt = alt == null ? "" : String(alt);
69
+
65
70
  const inputDir = this?.eleventy?.directories?.input;
66
71
  const isRemote = /^https?:\/\//i.test(src);
67
72
  const resolvedSrc = !isRemote && inputDir
@@ -99,10 +104,11 @@ export async function imageShortcode(options = {}) {
99
104
 
100
105
  const imageAttributes = {
101
106
  src: lowsrc.url,
102
- alt,
107
+ alt: normalizedAlt,
103
108
  loading,
104
109
  decoding: loading === "eager" ? "sync" : "async",
105
110
  class: combinedClass,
111
+ style,
106
112
  ...(setDimensions ? { width: highsrc.width, height: highsrc.height } : {}),
107
113
  ...restAttrs,
108
114
  "eleventy:ignore": true
@@ -120,10 +126,10 @@ export async function imageShortcode(options = {}) {
120
126
  <img ${imgAttrString}>
121
127
  </picture>`;
122
128
 
123
- if (!figure || !caption) return picture;
129
+ if (!figure || !normalizedCaption) return picture;
124
130
 
125
131
  return `<figure>
126
132
  ${picture}
127
- <figcaption>${caption}</figcaption>
133
+ <figcaption>${normalizedCaption}</figcaption>
128
134
  </figure>`;
129
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apleasantview/eleventy-plugin-baseline",
3
- "version": "0.1.0-next.14",
3
+ "version": "0.1.0-next.15",
4
4
  "description": "An experimental Swiss army knife toolkit for Eleventy",
5
5
  "type": "module",
6
6
  "main": "eleventy.config.js",