I am fetching some data from my CMS and got stuck trying to initialize a component i get as a string.
These are my components as a string array:
[
'<Header text="title1" img="link/to/image1" />',
'<Header text="title2" img="link/to/image2" />'
]
I could not find any way to init those strings as components in astro. Is this even possible?
Also, i am not using any frontend framework integrations atm
Thanks in advance!
2
Answers
As a Follow-Up:
As could not find any way to do this in vanilla astro, I now use the svelte integration to do create components dynamically.
In svelte, I can do something like this:
Sounds like you have access to a structured data about your components from your CMS. I’m going to assume this looks like this:
If you have this, you can do something like the following:
This is based on the basic Dynamic Tags example in the Astro docs.