Support `browser_compatibility` as a front matter key
See original GitHub issue(and make it available to KS. Actually, make all of front matter available to KS).
Like:
browser_compatibility: css.properties.margin
At the moment compat tables are built something like:
- authors include the {{ Compat }} macro, passing it a BCD query like “css.properties.margin”
- the {{ Compat }} macro emits a
<div class="bc-data">
with anid
set to that query - some magic Yari code, when it finds a
<div>
like that, fetches the BCD query value from theid
and uses it to construct a table
Just semantically, I think it would be better to have the BCD query in front matter than as an argument to the {{ Compat }} macro. Then it just represents an extra bit of data to associate with this thing, and the only thing {{ Compat }} is doing is telling Yari where in the page to put the table. And if we ever have machine-readable page types (aka recipes), we don’t need that either, because a common page type would include that location information.
But! BCD can be used for more than just the compat tables. There’s a project to include spec URLs in BCD, and use a KS macro to add the spec tables, based on the BCD query (https://github.com/mdn/content/issues/1146). If the BCD query is in front matter, then compat and spec tables can be driven from that one data item.
Also, BCD indicates when features are “deprecated”: elsewhere we’ve discussed using this to power “This feature is deprecated” warnings in pages. If BCD is in front matter, then this feature can also be driven by the same data item.
Also, we’ve talked in the past about having a sort of “BCD summary” thing at the tops of pages, to flag compat issues. Same thing: if BCD is in the front matter we can use it to drive that, too.
For the first attempt it would be helpful to make this front matter item accessible to KS. Then for now, the platform code that finds the <div class="bc-data">
doesn’t need to change, we could just adjust {{ Compat }} to use the front matter instead of an argument. Ideally I think KS macros should just get access to all front matter values. But eventually we could change things so {{ Compat }} is just not aware of the BCD query at all, in the common case.
We would still need to support a BCD query argument to {{ Compat }}, because some pages contain more than one compat table. But this I think is pretty unusual. So we would make the argument optional (and omit it in 95% of cases).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:6 (5 by maintainers)
Top GitHub Comments
I quite like the hyphenation because it feels more human.
browser_compat
looks like a programming variable name, whereasbrowser-compat
looks like something a writer would type into a CMS.My solution takes quite a lax stance. All and anything that’s in the front-matter is available on the
env
object inside the.ejs
code. So you can call it whatever you like in a sense, but you just need to align you edits to the front-matter with the relevant.ejs
file that uses it.Yes, exactly!
I don’t feel strongly here, but would vote for
browser_compatibility
: I agree it’s harder to write but it is easier to read, and reading happens more often than writing.