-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add docs for meta attribute in Code component #9054
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this along with your PR, @jcayzac !
I think we can do better than duplicating an entire huge example just to add the meta property, though. So I may decide this should just be a line in the main transformers section, and we just show one example including the meta
tag. We do something similar in the config section on the Markdown page, where we just show one config example, and one of the plugins happens to have additional options passed.
I'm thinking maybe something like:
[Shiki transformers](https://shiki.style/packages/transformers#shikijs-transformers) can optionally be applied to code by passing them in through the `transformers` property as an array. Since Astro v4.14.0, you can also provide a string for [Shiki's `meta` attribute](https://shiki.style/guide/transformers#meta) to pass options to transformers.
And then update the code sample to include both transformers in the array, plus the meta
option, highlighting the two lines relevant to transformers (we use Expressive Code to do that in Docs 😉)
astro title="src/pages/index.astro" {12-13}
What do you think about something like that?
Oops, I see from the original PR that you're describing I asked for clarification in the PR there, or you can reply here! If |
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Erika replied there.
LGTM!
I did not understand that part. Expressive Code is not relevant to that documentation. |
Expressive Code is not a part of what we are documenting here, but it's how we have to format our code samples of your example here! I'm just pointing out that I find it coincidental that you have provided an example about line highlighting showing how to do it one way, but in order for us to actually document that, we have to use Expressive Code to do the highlighting of your example! 😄 |
Thanks @jcayzac ! Can you please take a look over my changes and make sure they're correct? Anything else you notice or want to see different here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs! @jcayzac , if you spot anything before this is released, feel free to return and let me know.
Otherwise, I'll consider this PR to be ready for our minor release on Thursday! Thank you for this contribution, and welcome to Team Docs! 🥳
@@ -2124,7 +2124,8 @@ console.log(foo + bar) // [!code focus] | |||
<Code | |||
code={code} | |||
lang="js" | |||
transformers={[transformerNotationFocus()]} /> | |||
transformers={[transformerNotationFocus(),[transformerMetaHighlight()]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bogus square bracket here.
transformers={[transformerNotationFocus(),[transformerMetaHighlight()]} | |
transformers={[transformerNotationFocus(), transformerMetaHighlight()]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! Oops! We'll fix this when we decide exactly which transformer(s) we should show!
@@ -2124,7 +2124,8 @@ console.log(foo + bar) // [!code focus] | |||
<Code | |||
code={code} | |||
lang="js" | |||
transformers={[transformerNotationFocus()]} /> | |||
transformers={[transformerNotationFocus(),[transformerMetaHighlight()]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because transformerNotationFocus
blurs everything but the line marked with // [!code focus]
, using it together with transformerMetaHighlight
makes little sense IMHO.
Or at least the highlighted line should be the same as the focused line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK! Shall we just delete the NotationFocus transformer then? Would also be OK if you wanted to suggest two that did go together! Just let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarah11918 sorry it took me some time to circle back to this PR. I see it's merged now.
The example now doesn't work. I has style for a transformer that's not used, and doesn't have any style for the transformer it uses.
The fixed example is that of the original commit: 975a6e1#diff-42959260ea642887b866e8e276a4520c1f112356eb9c15b31e510132a481aed6R2147-R2165
Thanks @sarah11918, I commented on the issues I found. |
Description (required)
Documentation for withastro/astro#11605
Related issues & labels (optional)
For Astro version:
4.14.0
. See astro PR 11605First-time contributor to Astro Docs?
Discord: @jcayzac