Comments (6)
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 css
and get something added to the bundle, when used in a JavaScript template?
from eleventy.
Some overlap with #3310
from eleventy.
In Eleventy itself, the context this
is binded to filters (what makes it possible to work for filters from the bundle plugin) something like this:
eleventy/src/Engines/JavaScript.js
Lines 12 to 13 in 55e2279
eleventy/src/Engines/JavaScript.js
Lines 119 to 145 in 55e2279
from eleventy.
@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 this
is enough for this. There's something deferred happening when the bundle gets put in the head, with some re-evaluation/resolution happening after the first pass through. (Confession: I should read the source rather than guess.)
from eleventy.
Eleventy bundle plugin functions inserts placeholders into html, then transforms replace them with content or links of bundles.
from eleventy.
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. addContent
needs a `page.url.
My subcomponent doesn't have this.page
. I would need to pass in the URL each time, and find a way to get to page.url
in each subcomponent. I made an arrow function in compile
to automate that.
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 jsx-async-runtime
project (nice small codebase) where it allowed a pluggable factory to control the this
.
I'd be ok with closing this ticket.
from eleventy.
Related Issues (20)
- template dependency changes not propagating through to built output HOT 4
- Aliasing `markdown` to `md` isn’t quite working right with new `permalink: raw` default HOT 2
- I wonder if there will be a Union file system like hugo after 11ty? | 不知道11ty以后会有类似hugo的Union file system吗? HOT 2
- JS import attributes break `watch` HOT 2
- Global import of macros fails in Eleventy 3.0.0-alpha.14 HOT 7
- Add support for 11ty.js Virtual Templates HOT 3
- Add support for `rawInput` for `11ty.js` templates. HOT 1
- Programmatic use of Render Plugin HOT 1
- i18n | Issue with the page.lang variable on some pages. HOT 1
- When using tsx and pnpm, eleventy fails to run dev server (workaround included) HOT 1
- `eleventyConfig.augmentFunctionContext` to add `this.eleventy` and `this.page` to the context of any function (but mostly for filters/shortcodes) HOT 4
- [email protected]` regression (TLDR: no issue here, everything is good) HOT 1
- v3.0.0 Upgrade Plugin HOT 4
- JavaScript template as class can't export any other functions HOT 1
- Swap to use Node’s `fs.cp` instead of `recursive-copy`
- New `IdAttributePlugin` will add `id` attributes to your headings HOT 2
- Error on serve - eleventyConfig.getFilter(...) is not a function HOT 2
- Stop .txt files from rendering as HTML HOT 1
- Exposing rendering context to Nunjucks shortcodes fails in Eleventy 3.0.0-alpha.17 HOT 1
- Process eleventy shortcodes in markdown-rendered FrontMatter data HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eleventy.