diff --git a/package.json b/package.json index 0008924c69..c9375ca286 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "resolutions": { "connected-next-router/react-redux": "8.0.7", "react-beautiful-dnd/react-redux": "8.0.7", - "@prismicio/types-internal": "3.2.0", + "@prismicio/types-internal": "3.3.0", "express": "4.20.0" }, "workspaces": [ diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 335dc25403..dc07330663 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -67,7 +67,7 @@ }, "dependencies": { "@prismicio/simulator": "^0.1.4", - "@prismicio/types-internal": "3.2.0", + "@prismicio/types-internal": "3.3.0", "@slicemachine/plugin-kit": "workspace:*", "common-tags": "^1.8.2", "fp-ts": "^2.13.1", diff --git a/packages/adapter-next/src/hooks/snippet-read.ts b/packages/adapter-next/src/hooks/snippet-read.ts index 6057cf3e0e..ed615374bf 100644 --- a/packages/adapter-next/src/hooks/snippet-read.ts +++ b/packages/adapter-next/src/hooks/snippet-read.ts @@ -62,33 +62,48 @@ 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, prefix: "" | "\n " = "") => + allowVariants ? `${prefix}className={${path}.variant}` : ""; + + const path = dotPath(fieldPath); + let code; if (!repeat && !allowText) { code = await format( stripIndent` - Link + Link `, helpers, ); } else if (!repeat && allowText) { code = await format( stripIndent` - + `, helpers, ); } else if (repeat && !allowText) { - code = stripIndent` - {${dotPath(fieldPath)}.map((link) => ( - Link - ))} - `; + // We cannot use `format` since this snippet contains invalid syntax. + // Please ensure this snippet is manually formatted correctly. + // Make sure to use spaces instead of tabs. + code = stripIndent`{${path}.map((link) => ( + + Link + +))}`; } else if (repeat && allowText) { - code = stripIndent` - {${dotPath(fieldPath)}.map((link) => ( - - ))} - `; + // We cannot use `format` since this snippet contains invalid syntax. + // Please ensure this snippet is manually formatted correctly. + // Make sure to use spaces instead of tabs. + code = stripIndent`{${path}.map((link) => ( + +))}`; } else { throw new Error("Invalid configuration."); } diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index 204266b68c..dabb487970 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "@prismicio/simulator": "^0.1.4", - "@prismicio/types-internal": "3.2.0", + "@prismicio/types-internal": "3.3.0", "@slicemachine/plugin-kit": "workspace:*", "common-tags": "^1.8.2", "fp-ts": "^2.13.1", diff --git a/packages/adapter-nuxt/src/hooks/snippet-read.ts b/packages/adapter-nuxt/src/hooks/snippet-read.ts index 03eaf4c982..763b4ff001 100644 --- a/packages/adapter-nuxt/src/hooks/snippet-read.ts +++ b/packages/adapter-nuxt/src/hooks/snippet-read.ts @@ -61,25 +61,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` -