Skip to content

Commit b778ed0

Browse files
committed
fix: improve shikiConfig handling to preserve user-defined values
1 parent e4e3e1b commit b778ed0

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

index.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export interface JaamdOptions {
1313

1414
/**
1515
* Shiki syntax-highlighting theme family.
16-
* Selects between `github-light` and `github-dark`.
17-
* @default "light"
16+
* @default "github-light"
1817
*/
19-
theme?: "light" | "dark";
18+
theme?: string;
2019

2120
/**
2221
* Skip injecting the default CSS variable fallbacks (`jaamd/default`).
@@ -48,7 +47,12 @@ export interface JaamdOptions {
4847
* Supports `astro add jaamd`.
4948
*/
5049
export default function jaamd(options: JaamdOptions = {}): AstroIntegration {
51-
const { selector = ".jaamd-content", theme = "light", noDefault = false, plugins = {} } = options;
50+
const {
51+
selector = ".jaamd-content",
52+
theme = "github-light",
53+
noDefault = false,
54+
plugins = {},
55+
} = options;
5256
const { codeTabs = true, alerts = true, directive = true } = plugins;
5357

5458
return {
@@ -67,11 +71,10 @@ export default function jaamd(options: JaamdOptions = {}): AstroIntegration {
6771
const existingRemarkPlugins: any[] = existingMarkdown.remarkPlugins ?? [];
6872
const existingShikiConfig: any = existingMarkdown.shikiConfig ?? {};
6973

70-
// Apply sensible defaults for shikiConfig only when the user hasn't
71-
// already set those specific keys.
72-
const shikiTheme = theme === "dark" ? "github-dark" : "github-light";
73-
const shikiDefaults: any = { theme: shikiTheme, wrap: true };
74-
const mergedShikiConfig = { ...shikiDefaults, ...existingShikiConfig };
74+
// `wrap` and other keys are only filled in when absent.
75+
const mergedShikiConfig: any = { ...existingShikiConfig };
76+
mergedShikiConfig.theme = theme;
77+
if (mergedShikiConfig.wrap === undefined) mergedShikiConfig.wrap = true;
7578

7679
updateConfig({
7780
vite: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jaamd",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"description": "Just Another Astro Markdown",
55
"type": "module",
66
"license": "MIT",

0 commit comments

Comments
 (0)