Replies: 8 comments 9 replies
-
|
I don't really like this idea. The triple dashes make it more seperate and emphasizes that that is build time run javascript etc. |
Beta Was this translation helpful? Give feedback.
-
|
+1 With the script tag it would automatically work in all IDEs fairly well out-of-the-box. It's just HTML with some JSX additions. The Frontmatter syntax on the other hand requires special plugins for all IDEs, including WebStorm/Jetbrains – Astro is currently not usable with WS which is a blocker for many. The workaround with the Textmate bundle is just that (fixes syntax errors but nothing else, no autocompletions, quick fixes, intelligence in any sense, etc.). Besides, it "feels" more like you're doing actual web dev... in a familiar syntax. |
Beta Was this translation helpful? Give feedback.
-
|
+1 I really like Frontmatter and the simplicity it adds but I feel like using it in a .astro is slightly awkward. To me Frontmatter is tained by its most common use in Markdown. So frontmatter to me = YAML while script = JS. The above proposed script solution with astro namespace tags is likely the most justifiable. Also I think having a .astro extension disengages concerns about cross-pollinating standard HTML script tag. I could argue that the .astro file extension helps assert the DSL inside the file. The astro namespace within the script tag actually reinforces the file designation so the colocation seems more intentional. This to me feels like a firmer argument than using arbitrary and untagged/unspecified Frontmatter. |
Beta Was this translation helpful? Give feedback.
-
|
What is nice about the frontmatter syntax is that it is a clear separate from the template part. In Svelte and other similar frontend oriented frameworks the If we used <script astro>
import MyHeader from '../components/Header.astro';
</script>
<html>
<head>
<title>My page</title>
<script>/* A regular in-page script tag */</script>
</head>
<body>
<MyHeader title="My page" />
</body>
</html> |
Beta Was this translation helpful? Give feedback.
-
|
I personally also prefer the current syntax over a The context in which the frontmatter and script tags run is so different that I'd rather we have them as separate as possible. I actually personally like that it's similar to Markdown because I like to think of the frontmatter of Astro files as the "metadata" of the file? I don't know if that makes sense but it fits my way of thinking very well 😅 And just for context on the editor integration part (as the person working on all of our editor integration things at Astro), using a script tag wouldn't make it any easier to support things really. It wouldn't make parsing necessarily easier, JSX does not support script tags so no grounds gained there, frontmatter and script tags run in separate contexts so you still need special care etc etc For formatting, we already have a Prettier plugin, almost since the birth of Astro actually 😅 Using script tags wouldn't have made it easier, the Svelte prettier plugin, which is what they use in VS Code, is pretty Svelte-exclusive. It uses their compiler to parse files and their compiler, script tag or not, does not support Astro files for sure haha 😄 |
Beta Was this translation helpful? Give feedback.
-
|
So I learned Frontmatter is actually defined in the traditional sense as:
Software has appropriated the concept to mean the head of the file and it works well that way. The most common use and perhaps only that I've seen to date, is as a KV structure usually to define configuration or specification for the material contained within the document. Bringing it back to Astro, sure you can use it as the logic/scripting ahead of the body but it really takes the definition of "frontmatter" very far outside the original meaning and common use. In practical terms the importance of the frontmatter is arguably secondary, despite being preliminary to the body. In the Astro case JS (typically the longer business logic portion) is being placed in a location considered secondary/preliminary. This insinuates or inherently emphasizes the markup is the critical piece. This may be intended intended in which case it triggers more thoughts/concerns. Regardless of what the intention is, it feels rather inappropriate to repurpose in this manner? Like a square peg in a round hole. |
Beta Was this translation helpful? Give feedback.
-
It is now! |
Beta Was this translation helpful? Give feedback.
-
|
The current syntax makes sense in an HTML-first kind of way, but requires it comes with a significant maintenance burden for various toolings you need to maintain, and bugs. For a plain JavaScript syntax, that works for both HTML and JSON responses, take a look at e.g. https://mastrojs.github.io |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it too late to change the syntax of Astro?
I think frontmatter makes a lot of sense in markdown files, but in
.astrofiles it just feels like an awkward HTML augmentation.So instead of triple dashes, I'd really love to see something like:
The added benefit of using just plain script tags is that I think it would be a lot easier to make a VScode formatter by just forking whatever Svelte is already using and removing things like
{#if ...Beta Was this translation helpful? Give feedback.
All reactions