Skip to content

Commit

Permalink
Breaking: Removed filters option to rename filters in the HTML base…
Browse files Browse the repository at this point in the history
… plugin. Using this feature would have caused issues with the RSS plugin.
  • Loading branch information
zachleat committed Jun 12, 2024
1 parent b0b9c7c commit 5e571e1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Plugins/HtmlBasePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,28 @@ function eleventyHtmlBasePlugin(eleventyConfig, defaultOptions = {}) {

extensions: "html",

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)
},
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);
});

// 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;

// Do nothing with a default base
Expand All @@ -89,7 +91,7 @@ function eleventyHtmlBasePlugin(eleventyConfig, defaultOptions = {}) {

// Apply to a block of HTML
eleventyConfig.addAsyncFilter(
opts.filters.html,
"transformWithHtmlBase",
function (content, baseOverride, pageUrlOverride) {
let base = baseOverride || opts.baseHref;

Expand Down

0 comments on commit 5e571e1

Please sign in to comment.