summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar wulinsheng123 <409187100@qq.com> 2023-01-26 07:21:15 +0800
committerGravatar GitHub <noreply@github.com> 2023-01-25 17:21:15 -0600
commitaedf23f8582e32a6b94b81ddba9b323831f2b22a (patch)
treefbe13c1584a55db290e6e767562288cbfd1969bd
parent883e0cc29968d51ed6c7515be035a40b28bafdad (diff)
downloadastro-aedf23f8582e32a6b94b81ddba9b323831f2b22a.tar.gz
astro-aedf23f8582e32a6b94b81ddba9b323831f2b22a.tar.zst
astro-aedf23f8582e32a6b94b81ddba9b323831f2b22a.zip
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>
-rw-r--r--.changeset/ten-icons-raise.md5
-rw-r--r--packages/astro/components/Code.astro3
-rw-r--r--packages/astro/components/Shiki.js5
3 files changed, 10 insertions, 3 deletions
diff --git a/.changeset/ten-icons-raise.md b/.changeset/ten-icons-raise.md
new file mode 100644
index 000000000..2c283d8b3
--- /dev/null
+++ b/.changeset/ten-icons-raise.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Astro <Code> component is not able to use a custom theme anymore
diff --git a/packages/astro/components/Code.astro b/packages/astro/components/Code.astro
index 5066b9594..7996e1b53 100644
--- a/packages/astro/components/Code.astro
+++ b/packages/astro/components/Code.astro
@@ -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);
---
diff --git a/packages/astro/components/Shiki.js b/packages/astro/components/Shiki.js
index 79d61d102..8e32f5f74 100644
--- a/packages/astro/components/Shiki.js
+++ b/packages/astro/components/Shiki.js
@@ -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;