Portals #1032
eric-burel
started this conversation in
Proposal
Portals
#1032
Replies: 1 comment 4 replies
-
This seems completely doable from userland as an integration. Enabling it (regardless if by an integration or built into Astro) would disable streaming responses for any page containing a portal tho, since it's contents can only be known when every component renders. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
In addition to slots that work on parent-children relationship, introduce a concept of portals that works from any-level of nesting.
Background & Motivation
The component hierarchy is directly tied to the DOM hierarchy which is not always the best structure for implementing a specific feature.
I am currently thinking of 2 use cases though some more might emerge during discussions:
<head>
section. It's certainly not clean, but I suspect it does have an impact on SEO too.For the first use case, at the moment you may use portals from your favorite client-side library, maybe this would just need some documentation to tell whether portals are supported or not.
However for proper SEO you may want the injection into the head tag to happen during server-side rendering only, it would be ideal to support this directly in Astro.
I've encountered the second use case while working on improving TutorialKit metadata.
Multiple changes were needed to make a proper connection between
.mdx
files and theLayout
component that renders the meta tags:And we still only support a few metadata : image, title, description. A similar work would be needed for more advanced tags like alternate links.
Goals
Example
Related:
stackblitz/tutorialkit#342
withastro/astro#8703
https://react.dev/reference/react-dom/createPortal
Beta Was this translation helpful? Give feedback.
All reactions