Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@11ty/eleventy

Package Overview
Dependencies
Maintainers
1
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@11ty/eleventy - npm Package Compare versions

Comparing version 3.0.0-alpha.12 to 3.0.0-alpha.13

2

package.json
{
"name": "@11ty/eleventy",
"version": "3.0.0-alpha.12",
"version": "3.0.0-alpha.13",
"description": "A simpler static site generator.",

@@ -5,0 +5,0 @@ "publishConfig": {

@@ -20,3 +20,3 @@ import TemplateEngine from "./TemplateEngine.js";

// Enable cacheability for this template
if (this.entry.compileOptions && "cache" in this.entry.compileOptions) {
if (this.entry?.compileOptions?.cache) {
this.cacheable = this.entry.compileOptions.cache;

@@ -275,3 +275,4 @@ } else if (this.needsToReadFileContents()) {

return true;
// Breaking: default changed from `true` to `false` in 3.0.0-alpha.13
return false;
}

@@ -278,0 +279,0 @@

@@ -57,8 +57,4 @@ import { DeepCopy } from "@11ty/eleventy-utils";

name: "htmlBaseWithPathPrefix",
filters: {
base: "htmlBaseUrl",
html: "transformWithHtmlBase",
pathPrefix: "addPathPrefixToFullUrl",
},
// `filters` option to rename filters was removed in 3.0.0-alpha.13
// Renaming these would cause issues in other plugins (e.g. RSS)
},

@@ -68,7 +64,13 @@ defaultOptions,

if (opts.filters !== undefined) {
throw new Error(
"The `filters` option in the HTML Base plugin was removed to prevent future cross-plugin compatibility issues.",
);
}
if (opts.baseHref === undefined) {
throw new Error("The `base` option is required in the Eleventy HTML Base plugin.");
throw new Error("The `base` option is required in the HTML Base plugin.");
}
eleventyConfig.addFilter(opts.filters.pathPrefix, function (url) {
eleventyConfig.addFilter("addPathPrefixToFullUrl", function (url) {
return addPathPrefixToUrl(url, eleventyConfig.pathPrefix);

@@ -78,3 +80,3 @@ });

// Apply to one URL
eleventyConfig.addFilter(opts.filters.base, function (url, baseOverride, pageUrlOverride) {
eleventyConfig.addFilter("htmlBaseUrl", function (url, baseOverride, pageUrlOverride) {
let base = baseOverride || opts.baseHref;

@@ -95,3 +97,3 @@

eleventyConfig.addAsyncFilter(
opts.filters.html,
"transformWithHtmlBase",
function (content, baseOverride, pageUrlOverride) {

@@ -114,19 +116,20 @@ let base = baseOverride || opts.baseHref;

// Skip the transform with a default base
if (opts.baseHref !== "/") {
// Apply to all HTML output in your project
eleventyConfig.htmlTransformer.addUrlTransform(
opts.extensions,
function (urlInMarkup) {
// baseHref override is via renderTransforms filter for adding the absolute URL (e.g. https://example.com/pathPrefix/) for RSS/Atom/JSON feeds
return transformUrl(urlInMarkup.trim(), this.baseHref || opts.baseHref, {
pathPrefix: eleventyConfig.pathPrefix,
pageUrl: this.url,
});
// Apply to all HTML output in your project
eleventyConfig.htmlTransformer.addUrlTransform(
opts.extensions,
function (urlInMarkup) {
// baseHref override is via renderTransforms filter for adding the absolute URL (e.g. https://example.com/pathPrefix/) for RSS/Atom/JSON feeds
return transformUrl(urlInMarkup.trim(), this.baseHref || opts.baseHref, {
pathPrefix: eleventyConfig.pathPrefix,
pageUrl: this.url,
});
},
{
priority: -1, // run last (especially after PathToUrl transform)
enabled: function (context) {
// Enabled when pathPrefix is non-default or via renderTransforms
return context.baseHref || opts.baseHref !== "/";
},
{
priority: -1, // run last (especially after PathToUrl transform)
},
);
}
},
);
}

@@ -133,0 +136,0 @@

@@ -401,4 +401,5 @@ import chalk from "kleur";

addPlugin(plugin, options = {}) {
// First addPlugin of a unique plugin wins
if (plugin?.eleventyPluginOptions?.unique && this.hasPlugin(plugin)) {
debug("Skipping duplicate unique addPlugin for %o", this.plugin);
debug("Skipping duplicate unique addPlugin for %o", this._getPluginName(plugin));
return;

@@ -463,3 +464,3 @@ }

let ret;
debug(`Adding ${name || "anonymous"} plugin`);
debug(`Adding %o plugin`, name || "anonymous");
let pluginBenchmark = this.benchmarks.aggregate.get("Configuration addPlugin");

@@ -466,0 +467,0 @@

@@ -82,2 +82,3 @@ import posthtml from "posthtml";

priority: options.priority,
enabled: options.enabled || (() => true),
});

@@ -101,8 +102,16 @@

isTransformable(extension) {
return !!this.callbacks[extension] || !!this.plugins[extension];
isTransformable(extension, context) {
return (
this.getCallbacks(extension, context).length > 0 || this.getPlugins(extension).length > 0
);
}
getCallbacks(extension) {
return this.callbacks[extension] || [];
getCallbacks(extension, context) {
let callbacks = this.callbacks[extension] || [];
return callbacks.filter(({ enabled }) => {
if (!enabled || typeof enabled !== "function") {
return true;
}
return enabled(context);
});
}

@@ -115,3 +124,8 @@

static async transformStandalone(content, callback, posthtmlProcessOptions = {}) {
let posthtmlInstance = this._getPosthtmlInstance([{ fn: callback }]);
let posthtmlInstance = this._getPosthtmlInstance([
{
fn: callback,
enabled: () => true,
},
]);
let result = await posthtmlInstance.process(content, posthtmlProcessOptions);

@@ -123,3 +137,3 @@ return result.html;

let extension = FilePathUtil.getFileExtension(outputPath);
if (!this.isTransformable(extension)) {
if (!this.isTransformable(extension, context)) {
return content;

@@ -130,3 +144,3 @@ }

bench.before();
let callbacks = this.getCallbacks(extension);
let callbacks = this.getCallbacks(extension, context);
let plugins = this.getPlugins(extension);

@@ -133,0 +147,0 @@ let posthtmlInstance = HtmlTransformer._getPosthtmlInstance(callbacks, plugins, context);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc