Allow HTML in frontmatter #164
Closed
zadeviggers
started this conversation in
Proposal
Replies: 2 comments 3 replies
-
|
Fun history: this used to work in Astro! It was removed because it was really buggy, and also hard to document & explain to users. @natemoo-re one thing that comes to mind: since we removed support for this, have our HTML JS-expressions become more JSX-like and less custom? If our HTML JS-expressions are documented as JSX now, then I think there's a much stronger case for JSX inside of frontmatter as well. |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
We do have the ---
const {myListofThings} = Astro.props
const { RecursiveComponent } = Astro.self
---
<ul>
{myListOfThings.map(thing=>{
<li>
{thing.content}
{thing.kids && (<Astro.self list={thing.kids}/>)
</li>
})}
</ul> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This isn't an actual RFC - I'm just curious about what people think of this idea.
If someone who knows how this could actually be implemented, feel free to make an actual RFC.
Motivation: When I need to recursively render something like a list, I need to resort to using template literals with html string in them and then injecting that into the page. This works but it's clunky (no syntax highlighting, error detection, or intellisense), slow (no autocomplete), and means that one can't use Astro components, or framework components.
The only way I could really think of to remedy this is by allowing html to be used in the front matter of the astro component.
Here's the example from before re-written to make use of writing html in the frontmatter:
Look how much cleaner that is!
I'm not exactly sure how this would be implemented, but it would just be the same as the html in the component template, except asignable to a variable.
There are quite a few potential drawbacks, including:
Beta Was this translation helpful? Give feedback.
All reactions