Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderTransforms filter not rendering inputPathToUrl transform plugin #3320

Closed
cypressSap opened this issue Jun 12, 2024 · 4 comments
Closed
Assignees
Labels

Comments

@cypressSap
Copy link

Operating system

macOS Big Sur 11.5.2

Eleventy

3.0.0-alpha.12

Describe the bug

I'd been trying out the inputPathToUrl transform plugin on 3.0.0-alpha.10, but was ready to give up on it because it left a bunch of broken links in my RSS feed. Looking for a workaround led me to #3294, so I impatiently updated to the then-latest commit (16a0eeb) to see if renderTransforms would help - and it did, which was awesome!

Today I updated to 3.0.0-alpha.12 and my feed's links went back to pointing to .md and .njk files, as if the filter weren't there. It looks like commit fd6ff40 is what broke it, but I haven't been able to troubleshoot past that. Still not working as of 168f441.

Reproduction steps

See reproduction repo. Builds as expected using Eleventy commit 16a0eeb through 4640413. Beginning from commit fd6ff40 input path URLs are not transformed in feed.njk.

Expected behavior

Expected [home page](/index.md) from post.md to render as <a href="https://example.com/">home page</a> in _site/feed.xml. Renders instead as <a href="https://example.com/index.md">home page</a>

Reproduction URL

https://github.com/cypressSap/11ty-rendertransforms-issue-reproduction

Screenshots

No response

@zachleat zachleat self-assigned this Jun 12, 2024
@zachleat
Copy link
Member

You’re one day ahead of me here. Stay tuned!

@zachleat
Copy link
Member

v2.0.0 of the RSS plugin has shipped which fixes this issue.

Docs for this are shipping to: https://www.11ty.dev/docs/plugins/rss/

You can either use the Virtual Template approach (which solves this for you) or the updated sample feed templates: https://www.11ty.dev/docs/plugins/rss/#sample-feed-templates

I’ve updated the template from your reproduction project below:

---json
{
  "permalink": "feed.xml",
  "eleventyExcludeFromCollections": true,
  "metadata": {
    "title": "My Blog about Boats",
    "subtitle": "I am writing about my experiences as a naval navel-gazer.",
    "language": "en",
    "url": "https://example.com/",
    "author": {
      "name": "Boaty McBoatFace",
      "email": "[email protected]"
    }
  }
}
---

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.url }}">
	<title>{{ metadata.title }}</title>
	<subtitle>{{ metadata.subtitle }}</subtitle>
	<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self" />
	<link href="{{ metadata.url | addPathPrefixToFullUrl }}" />
	<updated
		>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339
		}}</updated
	>
	<id>{{ metadata.url | addPathPrefixToFullUrl }}</id>
	<author>
		<name>{{ metadata.author.name }}</name>
		<email>{{ metadata.author.email }}</email>
	</author>
	{%- for post in collections.posts | reverse %} {%- set absolutePostUrl =
	post.url | htmlBaseUrl(metadata.url) %}
	<entry>
		<title>{{ post.data.title }}</title>
		<link href="{{ absolutePostUrl }}" />
		<updated>{{ post.date | dateToRfc3339 }}</updated>
		<id>{{ absolutePostUrl }}</id>
		<content xml:lang="{{ metadata.language }}" type="html"
			>{{ post.templateContent | renderTransforms(post.data.page, metadata.url) }}</content
		>
	</entry>
	{%- endfor %}
</feed>

This new method uses the renderTransforms to apply the base url via the HTML plugin. This increases performance as we don’t need to run posthtml twice for each templates. Related: 11ty/eleventy-plugin-rss#38

@zachleat zachleat added this to the Eleventy 3.0.0 milestone Jun 12, 2024
@zachleat zachleat added bug and removed needs-triage labels Jun 12, 2024
@zachleat
Copy link
Member

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

@cypressSap
Copy link
Author

Works great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants