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

add docs for meta attribute in Code component #9054

Merged
merged 8 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/content/docs/en/reference/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2108,13 +2108,13 @@ This component **does not** inherit the settings from your [Shiki configuration]

<p><Since v="4.11.0" /></p>

[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:
[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.

Note that `transformers` only applies classes and you must provide your own CSS rules to target the elements of your code block.

```astro
```astro title="src/pages/index.astro" {12-13}
---
import { transformerNotationFocus } from '@shikijs/transformers'
import { transformerNotationFocus, transformerMetaHighlight } from '@shikijs/transformers'
import { Code } from 'astro:components'
const code = `const foo = 'hello'
const bar = ' world'
Expand All @@ -2124,7 +2124,8 @@ console.log(foo + bar) // [!code focus]
<Code
code={code}
lang="js"
transformers={[transformerNotationFocus()]} />
transformers={[transformerMetaHighlight()]}
meta="{1,3}" />

<style is:global>
pre.has-focused .line:not(.focused) {
sarah11918 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading