@apleasantview/eleventy-plugin-baseline 0.1.0-next.19 → 0.1.0-next.21
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.
package/core/shortcodes/image.js
CHANGED
|
@@ -57,6 +57,8 @@ export async function imageShortcode(options = {}) {
|
|
|
57
57
|
setDimensions = true,
|
|
58
58
|
} = options;
|
|
59
59
|
|
|
60
|
+
const hasImageTransformPlugin = this.ctx._baseline.hasImageTransformPlugin;
|
|
61
|
+
|
|
60
62
|
if (!src) throw new Error("imageShortcode: src is required");
|
|
61
63
|
if (alt === undefined) {
|
|
62
64
|
throw new Error(
|
|
@@ -111,7 +113,7 @@ export async function imageShortcode(options = {}) {
|
|
|
111
113
|
style,
|
|
112
114
|
...(setDimensions ? { width: highsrc.width, height: highsrc.height } : {}),
|
|
113
115
|
...restAttrs,
|
|
114
|
-
"eleventy:ignore": true
|
|
116
|
+
...(hasImageTransformPlugin ? { "eleventy:ignore": true } : {})
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
const imgAttrString = Object.entries(imageAttributes)
|
package/eleventy.config.js
CHANGED
|
@@ -7,8 +7,9 @@ import shortcodes from "./core/shortcodes.js";
|
|
|
7
7
|
import { eleventyImageOnRequestDuringServePlugin } from "@11ty/eleventy-img";
|
|
8
8
|
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const __require = createRequire(import.meta.url);
|
|
11
|
+
|
|
12
|
+
const { name, version } = __require("./package.json");
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Eleventy Plugin Baseline.
|
|
@@ -23,11 +24,11 @@ const { version } = require("./package.json");
|
|
|
23
24
|
* @property {Object} [assetsESBuild] Options forwarded to assets-esbuild (minify/target).
|
|
24
25
|
*
|
|
25
26
|
* @param {BaselineOptions} [options={}] Custom options for the plugin.
|
|
26
|
-
* @returns {(eleventyConfig: UserConfig) => void}
|
|
27
|
+
* @returns {(eleventyConfig: import("@11ty/eleventy").UserConfig) => Promise<void>}
|
|
27
28
|
*/
|
|
28
29
|
export default function baseline(options = {}) {
|
|
29
30
|
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
|
|
30
|
-
|
|
31
|
+
const plugin = async function (eleventyConfig) {
|
|
31
32
|
try {
|
|
32
33
|
// Emit a warning message if the application is not using Eleventy 3.0 or newer (including prereleases).
|
|
33
34
|
eleventyConfig.versionCheck(">=3.0");
|
|
@@ -35,13 +36,19 @@ export default function baseline(options = {}) {
|
|
|
35
36
|
console.log(`[eleventy-plugin-baseline] WARN Eleventy plugin compatibility: ${e.message}`);
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
const hasImageTransformPlugin = eleventyConfig.hasPlugin("eleventyImageTransformPlugin");
|
|
40
|
+
|
|
38
41
|
const userOptions = {
|
|
39
|
-
version
|
|
42
|
+
version,
|
|
43
|
+
name,
|
|
40
44
|
verbose: options.verbose ?? false,
|
|
45
|
+
hasImageTransformPlugin,
|
|
41
46
|
enableNavigatorTemplate: options.enableNavigatorTemplate ?? false,
|
|
42
47
|
enableSitemapTemplate: options.enableSitemapTemplate ?? true,
|
|
48
|
+
assets: {
|
|
49
|
+
esbuild: options.assetsESBuild ?? { minify: true, target: "es2020" }
|
|
50
|
+
},
|
|
43
51
|
multilingual: options.multilingual ?? false,
|
|
44
|
-
assetsESBuild: options.assetsESBuild ?? {},
|
|
45
52
|
...options
|
|
46
53
|
};
|
|
47
54
|
|
|
@@ -76,7 +83,7 @@ export default function baseline(options = {}) {
|
|
|
76
83
|
eleventyConfig.addPlugin(modules.EleventyHtmlBasePlugin, { baseHref: process.env.URL || eleventyConfig.pathPrefix });
|
|
77
84
|
eleventyConfig.addPlugin(modules.assetsCore);
|
|
78
85
|
eleventyConfig.addPlugin(modules.assetsPostCSS);
|
|
79
|
-
eleventyConfig.addPlugin(modules.assetsESBuild, userOptions.
|
|
86
|
+
eleventyConfig.addPlugin(modules.assetsESBuild, userOptions.assets.esbuild);
|
|
80
87
|
eleventyConfig.addPlugin(modules.headCore);
|
|
81
88
|
eleventyConfig.addPlugin(modules.sitemapCore, { enableSitemapTemplate: userOptions.enableSitemapTemplate, multilingual: isMultilingual, languages });
|
|
82
89
|
|
|
@@ -97,6 +104,10 @@ export default function baseline(options = {}) {
|
|
|
97
104
|
eleventyConfig.addFilter("_keys", debug.keys);
|
|
98
105
|
eleventyConfig.addPlugin(modules.navigatorCore, { enableNavigatorTemplate: userOptions.enableNavigatorTemplate });
|
|
99
106
|
};
|
|
107
|
+
|
|
108
|
+
// Set plugin name so `eleventyConfig.hasPlugin()` can detect it.
|
|
109
|
+
Object.defineProperty(plugin, "name", { value: `${name}` });
|
|
110
|
+
return plugin;
|
|
100
111
|
}
|
|
101
112
|
|
|
102
113
|
export const config = {
|
|
@@ -68,9 +68,12 @@ export default function assetsCore(eleventyConfig, options = {}) {
|
|
|
68
68
|
|
|
69
69
|
eleventyConfig.addGlobalData("_baseline.assets", () => {
|
|
70
70
|
ensureCache(cache, eleventyConfig, rawDir, verbose);
|
|
71
|
+
// Merge with existing _baseline.assets (e.g., esbuild config)
|
|
72
|
+
const existing = eleventyConfig.globalData?._baseline?.assets || {};
|
|
71
73
|
return {
|
|
72
74
|
input: cache.assetsInput,
|
|
73
|
-
output: cache.assetsOutput
|
|
75
|
+
output: cache.assetsOutput,
|
|
76
|
+
...existing
|
|
74
77
|
};
|
|
75
78
|
});
|
|
76
79
|
|
|
@@ -24,7 +24,7 @@ permalink: /navigator-core.html
|
|
|
24
24
|
<p><a id="go-back" href=""><span style="vertical-align: text-bottom;">←</span> Go back</a></p>
|
|
25
25
|
<h2><u>Navigator</u></h2>
|
|
26
26
|
{% for key, value in _navigator() %}
|
|
27
|
-
<details>
|
|
27
|
+
<details name="navigator-item">
|
|
28
28
|
<summary><strong>{{ key }}</strong></summary>
|
|
29
29
|
{% if value | isString %}
|
|
30
30
|
<pre>{{ value | safe }}</pre>
|
package/package.json
CHANGED