-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Support Astro.slots.render for mdx #4973
Conversation
🦋 Changeset detectedLatest commit: 0392db9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
// Astro | ||
const expression = getFunctionExpression(component); | ||
if (expression) { | ||
const slot = expression(...args); | ||
return await renderSlot(this.#result, slot).then((res) => | ||
res != null ? String(res) : res | ||
); | ||
} | ||
// JSX | ||
if (typeof component === 'function') { | ||
return await renderJSX(this.#result, component(...args)).then((res) => | ||
res != null ? String(res) : res | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mixes JSX rendering into Astro.slots.render
. I'm not sure if this is fine architecture-wise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that this is a bit odd but I can't think of a better way. I think it's ok for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests, thanks!
Changes
Fix #4826
The
Astro.slots.render
API only renders Astro slots, but not JSX slots. This PR updates the API to support rendering JSX slots.Testing
Copied astro-slots tests for
Astro.slots.render
for mdx.Docs
N/A. this should be working in the first place.