Skip to content

šŸ› frontmatter in HTMLĀ #10313

@Zearin

Description

@Zearin

Environment information

(This is a repost of my comment from #3334. @dyc3 asked me to repost it as a standalone Issue.)


I just noticed the following in an HTML file I’m working on in VSCodium:

Image

The thing is… the statement that frontmatter is ā€œonly valid inside Astro filesā€ is false.

Back in the early 2010s, I was using the excellent Metalsmith static site generator to build websites, and it heavily featured frontmatter as a flexible tool for a ā€œroll your ownā€Ā config/workflow/whatever.

These days, I use Eleventy, but it also features frontmatter as an incredibly flexible, useful tool for developers who like the freedom that frontmatter provides.

Please don’t treat frontmatter as an Astro-specific feature.

  • Ideally, offer opt-in support for it at a general- or language-specific level.
  • (Less-than-ideally, at least update the parser’s message to say something like ā€œBiome currently only supports frontmatter in Astro filesā€.)

@dyc3 Asked me to explain my use case. The use case for frontmatter is always the same. This is true whether it is in an *.astro file, a markdown file, or any other file.

Here is an excerpt from this article that succinctly explain:

As with many new tech terms, the term front matter is borrowed from another domain; books. In the literary world, front matter refers to the information found in the first pages of a book. [ … ABRIDGED … ] Front matter in literary terms is the collection of information stored at the beginning of books that explains what the book is and how it was produced. For programming front matter refers to the section of a markdown file that gives context to the content of the file (though the concept is not specific to markdown and can be applied to other file types including yaml, toml and json as well).
This data allows us to do a wide range of actions with the file including creating dynamic routing for where the composed template is placed, access a title and cover photo, create preview cards and even sort collections based on creation dates.
Front matter allows us to access all of the context of a file, without having to rely solely on file attributes or parsing the file itself. Because front matter has special syntax to separate it from the content of the markdown file, we never need to worry about incorrectly parsing it.

What happened?

  1. I opened an HTML file with some frontmatter in VSCodium (with biome 2.4.14).
  2. I got a parser error that ā€œfrontmatter is only valid inside Astro filesā€ (see above image).

Expected result

Frontmatter is valid in all sorts of files, not just *.astro.

I think Biome should:

  • (Ideally) Offer opt-in support for it at a general- or language-specific level. OR,
  • (Less-than-ideally) At least update the parser’s message to say something like ā€œBiome currently only supports frontmatter in Astro filesā€.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-Needs triageStatus: this issue needs to be triaged

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions