-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
💡 RFC: Vue Dynamic Components #1413
Comments
Thanks for submitting @radohingis. I'm having a hard time understanding this issue, is this a proposal for a new feature? If so what is the new feature? From reading this it sounds like you are saying that client-side Vue components are not working on dynamic route pages? If that's the case then this is a bug. |
Thank you for getting involved in topic @matthewp. When you import Vue component to astro file and try to use it, it's not a problem. Problem is that Astro doesn't know which vue components are getting rendered via 'DynamicVueComponent.vue', and even if I import these files in astro page, or directly to DynamicVueComponent.vue, it's rendering only them as tags, not their templates. I'm looking for way how to tell Astro 'Hey, you need to know about all vue components in this project and be prepared to render them if necessary'. If you would like to get a little demonstration I would love to show you where is the problem on video call or google meet or smth :) |
I wasted a whole day trying to get this working and just took 3 Motrin for the headache it gave me. I’d also be happy to get on a call and discuss or provide code samples. |
Hey everyone! Our current RFC process is beginning to break down at this size, with over 50 open RFCs currently in the "discussing" stage. A growing community is a great problem to have, but our ability to give you RFC feedback has suffered as a result. In an effort to improve our RFC process, we are making some changes to better organize things. From now on, all RFCs will live in a standalone repo: https://github.com/withastro/rfcs This allows us to do three things: 1) Use threaded discussions for high-level ideas and improvements, without necessarily requiring an implementation for every idea. 2) Improve the quality of our RFC template and the speed/quality of all feedback. 3) Support inline comments and explicit approvals on RFCs, via a new Pull Request review process. We hope that this new process leads to better RFC weekly calls and faster feedback on your RFCs from maintainers. More detail can be found in the new RFC repo README. We can't automatically convert this issue to an RFC in the new repo because new RFC template is more detailed that this one. But, you can still continue this discussion in the new repo by creating a new Discussion in the RFC repo and copy-and-pasting this post (and any relevant follow-up comments) into it. Discussions are available for high-level ideas and suggestions without the requirement of a full implementation proposal. Then, when you are ready to propose (or re-propose) an implementation for feedback and approval, you can create a new RFC using the new RFC template. More detail about how to do this can be found in the new RFC repo README. Thanks for your patience as we attempt to improve things for both authors and reviewers. If you have any questions, don't hesitate to reach out on Discord. https://astro.build/chat |
Background & Motivation
Main idea
Main idea of this feature request is to render vue components on dynamic routes as they come from CMS API.
Proposed Solution
Possible solutions
Alternatives considered
Risks, downsides, and/or tradeoffs
Open Questions
Detailed Design
Example
To get a real world example what this feature should do, consider following
[...slug].astro
page in ~/pages folder.First we import our DynamicVueComponent
Consider
DynamicVueComponent.vue
as a parser between cms api and vue.It is design for its minimal purpose. To render what is described in data it receives:
You'll get the point along with reading further. Let's write some latest Astro:
Now consider endpointData as an array with objects. For example:
Now consider you have multiple objects in your top level array you receive, and so you can use 'page' property to tell astro which pages it is going to build, since
[...slug].astro
page creation is possible, it is easy to even build pages that have slugs like'/blog/post-352gwgs23436'
Lets return an array of slugs for astro to generate
Now astro knows which pages is it going to generate, but wait, we also need a content, not just blank pages.
And so we're using components property of our mapped pages
And at the very end we also need to request Astro for props, so we can use them as variables in template later.
Conclusion
Even though Astro renders for example two cards on given slug, the question is how to tell Astro that he has to render these vue components? I tried to import for example
import CardWithImage from '../components/CardWithImage.vue'
to[...slug].astro
, but instead of component's template I was given just<CardWithImage><CardWithImage />
or astro-root component with my component in it, and also astro knew what data it has to hydrate, but simply couldn't render this component to it's template. I think the main issue is to tell Astro which vue components it has to import and use dynamically, no matter if they are hardcoded or dynamically rendered with our DynamicVueComponent.The text was updated successfully, but these errors were encountered: