mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
Add Shiki's defaultColor
option to <Code />
(#11391)
This commit is contained in:
parent
b46a78e1c9
commit
6f9b527105
2 changed files with 17 additions and 0 deletions
5
.changeset/thin-dodos-serve.md
Normal file
5
.changeset/thin-dodos-serve.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Adds Shiki's [`defaultColor`](https://shiki.style/guide/dual-themes#without-default-color) option to the `<Code />` component, giving you more control in applying multiple themes
|
|
@ -36,6 +36,16 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
||||||
* Supports all themes found above; see https://shiki.style/guide/dual-themes for more information.
|
* Supports all themes found above; see https://shiki.style/guide/dual-themes for more information.
|
||||||
*/
|
*/
|
||||||
themes?: Record<string, ThemePresets | ThemeRegistration | ThemeRegistrationRaw>;
|
themes?: Record<string, ThemePresets | ThemeRegistration | ThemeRegistrationRaw>;
|
||||||
|
/**
|
||||||
|
* Chooses a theme from the "themes" option that you've defined as the default styling theme.
|
||||||
|
* - <string>: one of the keys defined in the "themes" option. Will throw an error if the key is not defined.
|
||||||
|
* - false: disabled. You'll have to apply the styling theme yourself. No effect if the "themes" option is not set.
|
||||||
|
*
|
||||||
|
* See https://shiki.style/guide/dual-themes#without-default-color for more information.
|
||||||
|
*
|
||||||
|
* @default "light"
|
||||||
|
*/
|
||||||
|
defaultColor?: 'light' | 'dark' | string | false
|
||||||
/**
|
/**
|
||||||
* Enable word wrapping.
|
* Enable word wrapping.
|
||||||
* - true: enabled.
|
* - true: enabled.
|
||||||
|
@ -64,6 +74,7 @@ const {
|
||||||
lang = 'plaintext',
|
lang = 'plaintext',
|
||||||
theme = 'github-dark',
|
theme = 'github-dark',
|
||||||
themes = {},
|
themes = {},
|
||||||
|
defaultColor = 'light',
|
||||||
wrap = false,
|
wrap = false,
|
||||||
inline = false,
|
inline = false,
|
||||||
transformers = [],
|
transformers = [],
|
||||||
|
@ -92,6 +103,7 @@ const highlighter = await getCachedHighlighter({
|
||||||
],
|
],
|
||||||
theme,
|
theme,
|
||||||
themes,
|
themes,
|
||||||
|
defaultColor,
|
||||||
wrap,
|
wrap,
|
||||||
transformers,
|
transformers,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue