fix: component is not able to use a custom theme anymore (#5952)
* Astro <Code> component is not able to use a custom theme anymore * Astro <Code> component is not able to use a custom theme anymore * Astro <Code> component is not able to use a custom theme anymore Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
883e0cc299
commit
aedf23f858
3 changed files with 10 additions and 3 deletions
5
.changeset/ten-icons-raise.md
Normal file
5
.changeset/ten-icons-raise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Astro <Code> component is not able to use a custom theme anymore
|
|
@ -57,8 +57,7 @@ const highlighter = await getHighlighter({
|
|||
langs: typeof lang !== 'string' ? [lang] : undefined,
|
||||
});
|
||||
const _html = highlighter.codeToHtml(code, {
|
||||
lang: typeof lang === 'string' ? lang : lang.id,
|
||||
theme,
|
||||
lang: typeof lang === 'string' ? lang : lang.id
|
||||
});
|
||||
const html = repairShikiTheme(_html);
|
||||
---
|
||||
|
|
|
@ -19,10 +19,13 @@ function stringify(opts) {
|
|||
*/
|
||||
async function resolveHighlighter(opts) {
|
||||
const resolvedThemes = [];
|
||||
if (opts.theme && opts.theme in themes) {
|
||||
if (Object.keys(opts.theme).length) {
|
||||
resolvedThemes.push(opts.theme);
|
||||
} else if (opts.theme && opts.theme in themes) {
|
||||
resolvedThemes.push(await themes[opts.theme]());
|
||||
}
|
||||
|
||||
|
||||
let resolvedLanguages;
|
||||
if (opts.langs) {
|
||||
resolvedLanguages = opts.langs;
|
||||
|
|
Loading…
Reference in a new issue