-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
TSX, components, and shortcodes #3331
Comments
Maybe a better way to think about it: eliminate the TSX part. Just think of it as a JavaScript template calling a shortcode. How would a universal shortcode call |
Some overlap with #3310 |
In Eleventy itself, the context eleventy/src/Engines/JavaScript.js Lines 12 to 13 in 55e2279
eleventy/src/Engines/JavaScript.js Lines 119 to 145 in 55e2279
|
@monochromer My plugin bundle concern...let's say I have a JavaScript template that inserts the CSS bundle in the head, then later, calls a shortcode. The shortcode adds something to the CSS bundle. But it is called after the bundle is put in the head. I don't think the binding to |
Eleventy bundle plugin functions inserts placeholders into html, then transforms replace them with content or links of bundles. |
Thanks a bunch for that tip @monochromer .... I now see the placeholder, its string scheme, and the event that processes after build. Thanks to my buddy Khalid, we found where the problem lies. My subcomponent doesn't have I made a video walking through the problem and hacky-y solution. Not much 11ty can do to help. It doesn't control the creation of the "shortcode" (subcomponent.) I could imagine some relationship with the I'd be ok with closing this ticket. |
it would be nice to have an API to control order (priority) of transforms. For example, if we have jsx-plugin with transform:
This transform will perform before bundle transform, which replace placeholders ( |
Operating system
macOS Big Sur
Eleventy
3.0 alpha 13
Describe the bug
Repo and video
TSX layout components work great. Subcomponents work great. But they don't have good access to universal shortcodes, in particular,
eleventy-plugin-bundle
stuff such ascss
.In short, Preact manages the instantiation of subcomponents, which means 11ty can't bind
this
. But Preact has a way to pass a "context" object to therender
function, and every component will getthis.context
. I'm able to pass inshortcodes: eleventyConfig.javascriptFunctions
and thus callthis.context.shortcodes.css(".xyz {}")
in my subcomponent.But when the caller (the layout template) renders,
this.getBundle()
doesn't return anything. Which makes sense, from an order-of-execution perspective.Here is a repo with a README and example code.
Reproduction steps
Expected behavior
build
script.xyz
is not in the build output.Reproduction URL
https://github.com/pauleveritt/eleventy-tsx-shortcodes
Screenshots
Video: https://youtu.be/m0lzT7__O7U
The text was updated successfully, but these errors were encountered: