Skip to content

Commit 5c8a85f

Browse files
committed
fix(options-error): Define default localStorageKey directly in virtual module
This fixes the integration expecting an options argument passed to it when called in a project. Previously the default `localStorageKey` was set within the `optionsSchema` with zod but this would not take effect when no options are passed to the integration.
1 parent cdfa128 commit 5c8a85f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

package/src/integration.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { z } from "astro/zod";
33

44
export const astroFoucKiller = defineIntegration({
55
name: "astro-fouc-killer",
6-
optionsSchema: z.object({
7-
localStorageKey: z.string().default("themeToggle"),
8-
}),
9-
setup({ name, options }) {
6+
optionsSchema: z
7+
.object({
8+
localStorageKey: z.string(),
9+
})
10+
.optional(),
11+
setup({ name, options = {} }) {
1012
return {
1113
hooks: {
1214
"astro:config:setup": (params) => {
@@ -16,7 +18,9 @@ export const astroFoucKiller = defineIntegration({
1618
name,
1719
imports: {
1820
"virtual:astro-fouc-killer/config": `
19-
export const localStorageKey = '${options.localStorageKey}';
21+
export const localStorageKey = ${JSON.stringify(
22+
options?.localStorageKey ?? "themeToggle"
23+
)};
2024
`,
2125
"virtual:astro-fouc-killer/script": `
2226
import { localStorageKey } from 'virtual:astro-fouc-killer/config';

0 commit comments

Comments
 (0)