11ty / eleventy-plugin-rss

A pack of Eleventy plugins for generating an RSS feed.
https://www.11ty.dev/docs/plugins/rss/
MIT License
92 stars 22 forks source link

htmlToAbsoluteUrls(absolutePostUrl) was missing the full URL base `absolutePostUrl` argument #31

Closed xplosionmind closed 2 years ago

xplosionmind commented 2 years ago

While building, I get this error and I cannot understand how to fix it.

[11ty] Unhandled rejection in promise: (more in DEBUG output)
[11ty] > eleventy-plugin-rss, htmlToAbsoluteUrls(absolutePostUrl) was missing the full URL base `absolutePostUrl` argument.

`Error` was thrown:
[11ty]     Error: eleventy-plugin-rss, htmlToAbsoluteUrls(absolutePostUrl) was missing the full URL base `absolutePostUrl` argument.
        at module.exports (/Users/tommi/tommi.space/node_modules/@11ty/eleventy-plugin-rss/src/htmlToAbsoluteUrls.js:7:11)
        at Context.<anonymous> (/Users/tommi/tommi.space/node_modules/@11ty/eleventy-plugin-rss/.eleventy.js:27:5)
        at Context.<anonymous> (/Users/tommi/tommi.space/node_modules/@11ty/eleventy/src/BenchmarkGroup.js:32:26)
        at eval (eval at _compile (/Users/tommi/tommi.space/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:47:37)
        at iterCallback (/Users/tommi/tommi.space/node_modules/nunjucks/src/runtime.js:293:11)
        at next (/Users/tommi/tommi.space/node_modules/nunjucks/src/lib.js:328:7)
        at Object.asyncIter (/Users/tommi/tommi.space/node_modules/nunjucks/src/lib.js:334:3)
        at Object.asyncEach (/Users/tommi/tommi.space/node_modules/nunjucks/src/runtime.js:290:9)
        at Template.root [as rootRenderFunc] (eval at _compile (/Users/tommi/tommi.space/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:29:9)
        at Template.render (/Users/tommi/tommi.space/node_modules/nunjucks/src/environment.js:552:10)
ERROR: "watch:eleventy" exited with 1.
pdehaan commented 2 years ago

Are you passing a base argument to the htmlToAbsoluteUrls filter? For example {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}

pdehaan commented 2 years ago

This worked for me: https://github.com/pdehaan/11ty-rss-31

---
# src/index.njk
title: HOMEPAGE
---

<p>{{ site.baseUrl }}</p>

{% for post in collections.pages %}
  {% set absolutePostUrl %}{{ post.url | url | absoluteUrl(site.baseUrl) }}{% endset %}
  <article>
    {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) | safe }}
  </article>
{% endfor %}

Where my src/_data/site.js file looks like this:

// src/_data/site.js
module.exports = {
  baseUrl: "https://pdehaan.dev/"
};
xplosionmind commented 2 years ago

yep, I omitted {% set absolutePostUrl %}{{ post.url | url | absoluteUrl(site.baseUrl) }}{% endset %}. Thanks a lot!