diff --git a/packages/adapter-sveltekit/src/hooks/snippet-read.ts b/packages/adapter-sveltekit/src/hooks/snippet-read.ts index 0de45f568..c2760f4e3 100644 --- a/packages/adapter-sveltekit/src/hooks/snippet-read.ts +++ b/packages/adapter-sveltekit/src/hooks/snippet-read.ts @@ -60,25 +60,31 @@ export const snippetRead: SnippetReadHook = async ( const repeat = data.model.config?.repeat ?? false; const allowText = data.model.config?.allowText ?? false; + const allowVariants = Boolean(data.model.config?.variants); + const variant = (path: string) => + allowVariants ? ` class={${path}.variant}` : ""; + + const path = dotPath(fieldPath); + let codeText; if (!repeat && !allowText) { codeText = stripIndent` - Link + Link `; } else if (!repeat && allowText) { codeText = stripIndent` - + `; } else if (repeat && !allowText) { codeText = stripIndent` - {#each ${dotPath(fieldPath)} as link (link.key)} - Link + {#each ${path} as link (link.key)} + Link {/each} `; } else if (repeat && allowText) { codeText = stripIndent` - {#each ${dotPath(fieldPath)} as link (link.key)} - + {#each ${path} as link (link.key)} + {/each} `; } else {