Add addTransform option to filter by outputPath file extension (better handle outputPath.endsWith check fails with permalink: false) #4163
Replies: 14 comments
|
Hmmmmmmmmmmmmmmmmmm… Should we solve this in the library? Transforms should run on |
|
How about |
|
Hmm, this makes me a little uncomfortable because it’s a little bit of magic? Right now Not saying no, just want to think it out all the way. One other question that comes to mind: if you set |
|
You could require |
|
I just came across this - added the html minification example to my Two things caused this:
I'm not sure the transform necessarily needs to so something differently, but I think the example code for minification should handle this case. Something as simple as testing for a string / url and then proceeding. It using |
|
For anyone coming across this by using the html-minifier example in the docs and a link to an outside url using |
|
What if the outputPath has no html file extension? As in: How would a transform plugin for HTML would know the file to transform is HTML prior to the transformation itself? |
|
I think I found a good balance in my plugin to deal with both undefined file extensions and permalink false: |
|
I also came across this issue by following the html-minifier transform example in the docs. I fixed it by changing the code as @davidysoards suggested (thanks!). It seems to me that the most immediate problem is not necessarily that there's anything unintuitive about the API, but that the docs contain a code example that breaks fairly easily (i.e. whenever any template has |
|
@igelstorm you're welcome! glad it helped someone. |
|
I think the docs page is at https://github.com/11ty/11ty-website/blob/master/docs/config.md, if somebody want to create a Pull request for this. |
|
I have opened a PR to fix the minification example and clarify this behaviour in a few other places in the docs: 11ty/docs#991 Comments welcome from anyone who encountered this issue about whether these changes would've been enough to help them at the time! |
|
My temporary and not smart solution for such case with AMP-plugin is to not use false value for permalink and generate empty page with no collision for plugin |
|
Slightly altering this to be an enhancement queue to add support for filtering by outputPath. See also the preprocessor API (that allows filtering by template syntax).
Might look like adding an optional second argument (or maybe a third options object argument):
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When you have files with
permalink: falsethenoutputPath.endsWithcheck fails.To Reproduce
permalink: falsethat resolves into*.htmlExpected behavior
Successful build.
Environment:
Additional context
It could be fixed by checking if
outputPathis available:…or by changing the
outputPathbehavior, which is preferable :)All reactions