make all front-matter available in KS rendering #3503
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3258
In principle, this was an easy fix. Now I can make this change in the content:
and it works! It works because now any key in the front-matter becomes available in that
env
object you get inside the context of KS rendering.We used to hardcode the "transfer" of
slug
,title
, andtags
. Now it just takes all and everything from the front-matter and makes it available. There is a slight exception for the front-mattertags
because it could potentially beundefined
but I think the KS macros expects it to always be an array. By leaving it to always fall back on an empty array, no macro code would need to do something likeif (!Array.isArray(env.tags)) {
or anything like that.But yes, the
env['browser-compat']
might beundefined
but this is a new thing so I think it's fair for KS macros to always check for truthy'ness before using it.I'm not entirely sure what the consequences might be related to KS rendering caching so I'm tempted to make this a draft for @escattone to ponder. But I don't usually make draft PRs if there's nothing left on my to-do list for the branch work.