Skip to content
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

JS front-matter? #232

Closed
Fil opened this issue Nov 23, 2023 · 3 comments
Closed

JS front-matter? #232

Fil opened this issue Nov 23, 2023 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@Fil
Copy link
Contributor

Fil commented Nov 23, 2023

We already have a profusion of languages (html, js, css, md), which are intertwined in a single document (not even counting data loaders or tex cells).

For front-matter we adopted yaml since it's the default in many static site generators, but it means that people have to learn yet another markup language, look up yet another reference. (I've also noticed that yaml in all its easiness is often a bit perplexing to users.) It's not a huge deal, since it's a very simple format, but would it make sense to remove it and express the front matter in javascript / typescript / json instead?

Another argument in favor of the change is that the config file must be js or ts, and shares its structure with the front-matter.

Keeping in mind that this informs the server, not the client, it would seem difficult to write it like this:

---js
const toc = false;
const title = "Welcome";
---

although, if we want to support server-side rendering of some elements (like tex #150), we'll need a way to specify that.

But there are other possibilities:

```js SSR
const config = {toc: false, title: "Welcome"};
```

or a config flag:

```js config
{toc: false, title: "Welcome"}
```

which accepts JSON but is functionally equivalent to

```js
export config = {toc: false, title: "Welcome"};
```
@Fil Fil added the question Further information is requested label Nov 23, 2023
@mbostock mbostock added the enhancement New feature or request label Nov 23, 2023
@mbostock mbostock added this to the Future milestone Nov 23, 2023
@mbostock
Copy link
Member

This is an interesting idea but not one that I think we should pursue in the near future. I think YAML front matter is fine as-is and there’s enough precedent that we don’t need to reinvent how it works. I agree it’s another thing to explain, but I don’t expect there to be much complexity in our front matter configuration — I suggest we try to keep the configuration as small as possible.

@Fil
Copy link
Contributor Author

Fil commented Nov 27, 2023

Closing. The suggestion here was to remove yaml front-matter and adopt js instead. Supporting both would be a different issue (and I don't think we would want that).

@Fil Fil closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@Fil
Copy link
Contributor Author

Fil commented Nov 27, 2023

I just realized that gray-matter already supports JSON:

---js
{toc: false, title: "Hi"}
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants