Skip to content

Commit

Permalink
Merge branch 'main' of github.com:prismicio/slice-machine into repeat…
Browse files Browse the repository at this point in the history
…able-link
  • Loading branch information
dani-mp committed Nov 5, 2024
2 parents 00371f5 + b8eb04e commit a74aecd
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/adapter-next",
"version": "0.3.54",
"version": "0.3.55",
"description": "Slice Machine adapter for Next.js.",
"keywords": [
"typescript",
Expand Down
16 changes: 10 additions & 6 deletions packages/adapter-next/src/hooks/documentation-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
type Params = { uid: string };
export default async function Page({ params }: { params: Params }) {
export default async function Page({ params }: { params: Promise<Params> }) {
const { uid } = await params
const client = createClient();
const page = await client
.getByUID("${model.id}", params.uid)
.getByUID("${model.id}", uid)
.catch(() => notFound());
return <SliceZone slices={page.data.slices} components={components} />;
Expand All @@ -53,11 +54,12 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
export async function generateMetadata({
params,
}: {
params: Params;
params: Promise<Params>;
}): Promise<Metadata> {
const { uid } = await params
const client = createClient();
const page = await client
.getByUID("${model.id}", params.uid)
.getByUID("${model.id}", uid)
.catch(() => notFound());
return {
Expand Down Expand Up @@ -205,18 +207,20 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
export default async function Page({ params }) {
const { uid } = await params
const client = createClient();
const page = await client
.getByUID("${model.id}", params.uid)
.getByUID("${model.id}", uid)
.catch(() => notFound());
return <SliceZone slices={page.data.slices} components={components} />;
}
export async function generateMetadata({ params }) {
const { uid } = await params
const client = createClient();
const page = await client
.getByUID("${model.id}", params.uid)
.getByUID("${model.id}", uid)
.catch(() => notFound());
return {
Expand Down
10 changes: 6 additions & 4 deletions packages/adapter-next/src/hooks/project-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,11 @@ const createSliceSimulatorPage = async ({
import { components } from "../../slices";
export default function SliceSimulatorPage({
export default async function SliceSimulatorPage({
searchParams,
}: SliceSimulatorParams) {
const slices = getSlices(searchParams.state);
const { state } = await searchParams
const slices = getSlices(state);
return (
<SliceSimulator>
Expand All @@ -306,8 +307,9 @@ const createSliceSimulatorPage = async ({
import { components } from "../../slices";
export default function SliceSimulatorPage({ searchParams }) {
const slices = getSlices(searchParams.state);
export default async function SliceSimulatorPage({ searchParams }) {
const { state } = await searchParams
const slices = getSlices(state);
return (
<SliceSimulator>
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-next/src/simulator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Server Component.
*/
export type SliceSimulatorParams = {
searchParams: {
searchParams: Promise<{
state?: string;
};
}>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ import { createClient } from \\"@/prismicio\\";
import { components } from \\"@/slices\\";
export default async function Page({ params }) {
const { uid } = await params;
const client = createClient();
const page = await client
.getByUID(\\"foo_bar\\", params.uid)
.catch(() => notFound());
const page = await client.getByUID(\\"foo_bar\\", uid).catch(() => notFound());
return <SliceZone slices={page.data.slices} components={components} />;
}
export async function generateMetadata({ params }) {
const { uid } = await params;
const client = createClient();
const page = await client
.getByUID(\\"foo_bar\\", params.uid)
.catch(() => notFound());
const page = await client.getByUID(\\"foo_bar\\", uid).catch(() => notFound());
return {
title: page.data.meta_title,
Expand Down Expand Up @@ -69,24 +67,22 @@ import { components } from \\"@/slices\\";
type Params = { uid: string };
export default async function Page({ params }: { params: Params }) {
export default async function Page({ params }: { params: Promise<Params> }) {
const { uid } = await params;
const client = createClient();
const page = await client
.getByUID(\\"foo_bar\\", params.uid)
.catch(() => notFound());
const page = await client.getByUID(\\"foo_bar\\", uid).catch(() => notFound());
return <SliceZone slices={page.data.slices} components={components} />;
}
export async function generateMetadata({
params,
}: {
params: Params;
params: Promise<Params>;
}): Promise<Metadata> {
const { uid } = await params;
const client = createClient();
const page = await client
.getByUID(\\"foo_bar\\", params.uid)
.catch(() => notFound());
const page = await client.getByUID(\\"foo_bar\\", uid).catch(() => notFound());
return {
title: page.data.meta_title,
Expand Down
15 changes: 9 additions & 6 deletions packages/adapter-next/test/plugin-project-init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,9 @@ describe("Slice Simulator route", () => {
import { components } from \\"../../slices\\";
export default function SliceSimulatorPage({ searchParams }) {
const slices = getSlices(searchParams.state);
export default async function SliceSimulatorPage({ searchParams }) {
const { state } = await searchParams;
const slices = getSlices(state);
return (
<SliceSimulator>
Expand Down Expand Up @@ -915,8 +916,9 @@ describe("Slice Simulator route", () => {
import { components } from \\"../../slices\\";
export default function SliceSimulatorPage({ searchParams }) {
const slices = getSlices(searchParams.state);
export default async function SliceSimulatorPage({ searchParams }) {
const { state } = await searchParams;
const slices = getSlices(state);
return (
<SliceSimulator>
Expand Down Expand Up @@ -1012,10 +1014,11 @@ describe("Slice Simulator route", () => {
import { components } from \\"../../slices\\";
export default function SliceSimulatorPage({
export default async function SliceSimulatorPage({
searchParams,
}: SliceSimulatorParams) {
const slices = getSlices(searchParams.state);
const { state } = await searchParams;
const slices = getSlices(state);
return (
<SliceSimulator>
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/adapter-nuxt",
"version": "0.3.54",
"version": "0.3.55",
"description": "Slice Machine adapter for Nuxt 3.",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/adapter-nuxt2",
"version": "0.3.54",
"version": "0.3.55",
"description": "Slice Machine adapter for Nuxt 2.",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/adapter-sveltekit",
"version": "0.3.54",
"version": "0.3.55",
"description": "Slice Machine adapter for SvelteKit.",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion packages/init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/init",
"version": "2.10.11",
"version": "2.10.12",
"description": "Init Prismic Slice Machine in your project",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/manager",
"version": "0.22.0",
"version": "0.22.1",
"description": "Manage all aspects of a Slice Machine project.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slicemachine/plugin-kit",
"version": "0.4.54",
"version": "0.4.55",
"description": "A set of helpers to develop and run Slice Machine plugins",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slice-machine-ui",
"version": "2.10.0",
"version": "2.10.1",
"license": "MIT",
"description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ const Hint: React.FC<HintProps> = ({
}) => {
const fieldPathString = renderHintBase({ item });

// TODO: Call `swr`'s global `mutate` function when something changes to clear the cache.
const snippetCacheKey = [fieldPathString];
if (item.value.type === "Link") {
if (item.value.config?.allowText ?? false)
snippetCacheKey.push("allowText");
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data, error } = useSWR(fieldPathString, async () => {
const { data, error } = useSWR(snippetCacheKey.join("$"), async () => {
return await managerClient.snippets.readSnippets({
fieldPath: fieldPathString.split("."),
model: item.value,
Expand Down
2 changes: 1 addition & 1 deletion packages/start-slicemachine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "start-slicemachine",
"version": "0.12.34",
"version": "0.12.35",
"description": "Start Slice Machine from within a project.",
"repository": {
"type": "git",
Expand Down

0 comments on commit a74aecd

Please sign in to comment.