mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
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,
|
langs: typeof lang !== 'string' ? [lang] : undefined,
|
||||||
});
|
});
|
||||||
const _html = highlighter.codeToHtml(code, {
|
const _html = highlighter.codeToHtml(code, {
|
||||||
lang: typeof lang === 'string' ? lang : lang.id,
|
lang: typeof lang === 'string' ? lang : lang.id
|
||||||
theme,
|
|
||||||
});
|
});
|
||||||
const html = repairShikiTheme(_html);
|
const html = repairShikiTheme(_html);
|
||||||
---
|
---
|
||||||
|
|
|
@ -19,10 +19,13 @@ function stringify(opts) {
|
||||||
*/
|
*/
|
||||||
async function resolveHighlighter(opts) {
|
async function resolveHighlighter(opts) {
|
||||||
const resolvedThemes = [];
|
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]());
|
resolvedThemes.push(await themes[opts.theme]());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let resolvedLanguages;
|
let resolvedLanguages;
|
||||||
if (opts.langs) {
|
if (opts.langs) {
|
||||||
resolvedLanguages = opts.langs;
|
resolvedLanguages = opts.langs;
|
||||||
|
|
Loading…
Add table
Reference in a new issue