Skip to content

Commit eb9440d

Browse files
chore(prettier): 🤖 ✨ (#142)
Co-authored-by: squiggler[bot] <128108030+squiggler[bot]@users.noreply.github.com>
1 parent f130b40 commit eb9440d

36 files changed

+583
-695
lines changed
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,59 @@
1-
import type { Metadata } from "next";
2-
import Head from "next/head";
1+
import type {Metadata} from 'next'
2+
import Head from 'next/head'
33

4-
import PageBuilderPage from "@/app/components/PageBuilder";
5-
import { sanityFetch } from "@/sanity/lib/live";
6-
import { getPageQuery, pagesSlugs } from "@/sanity/lib/queries";
7-
import { GetPageQueryResult } from "@/sanity.types";
8-
import { PageOnboarding } from "@/app/components/Onboarding";
4+
import PageBuilderPage from '@/app/components/PageBuilder'
5+
import {sanityFetch} from '@/sanity/lib/live'
6+
import {getPageQuery, pagesSlugs} from '@/sanity/lib/queries'
7+
import {GetPageQueryResult} from '@/sanity.types'
8+
import {PageOnboarding} from '@/app/components/Onboarding'
99

1010
type Props = {
11-
params: Promise<{ slug: string }>;
12-
};
11+
params: Promise<{slug: string}>
12+
}
1313

1414
/**
1515
* Generate the static params for the page.
1616
* Learn more: https://nextjs.org/docs/app/api-reference/functions/generate-static-params
1717
*/
1818
export async function generateStaticParams() {
19-
const { data } = await sanityFetch({
19+
const {data} = await sanityFetch({
2020
query: pagesSlugs,
2121
// // Use the published perspective in generateStaticParams
22-
perspective: "published",
22+
perspective: 'published',
2323
stega: false,
24-
});
25-
return data;
24+
})
25+
return data
2626
}
2727

2828
/**
2929
* Generate metadata for the page.
3030
* Learn more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function
3131
*/
3232
export async function generateMetadata(props: Props): Promise<Metadata> {
33-
const params = await props.params;
34-
const { data: page } = await sanityFetch({
33+
const params = await props.params
34+
const {data: page} = await sanityFetch({
3535
query: getPageQuery,
3636
params,
3737
// Metadata should never contain stega
3838
stega: false,
39-
});
39+
})
4040

4141
return {
4242
title: page?.name,
4343
description: page?.heading,
44-
} satisfies Metadata;
44+
} satisfies Metadata
4545
}
4646

4747
export default async function Page(props: Props) {
48-
const params = await props.params;
49-
const [{ data: page }] = await Promise.all([
50-
sanityFetch({ query: getPageQuery, params }),
51-
]);
48+
const params = await props.params
49+
const [{data: page}] = await Promise.all([sanityFetch({query: getPageQuery, params})])
5250

5351
if (!page?._id) {
5452
return (
5553
<div className="py-40">
5654
<PageOnboarding />
5755
</div>
58-
);
56+
)
5957
}
6058

6159
return (
@@ -79,5 +77,5 @@ export default async function Page(props: Props) {
7977
</div>
8078
<PageBuilderPage page={page as GetPageQueryResult} />
8179
</div>
82-
);
80+
)
8381
}

‎frontend/app/actions.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
"use server";
1+
'use server'
22

3-
import { draftMode } from "next/headers";
3+
import {draftMode} from 'next/headers'
44

55
export async function disableDraftMode() {
6-
"use server";
6+
'use server'
77
await Promise.allSettled([
88
(await draftMode()).disable(),
99
// Simulate a delay to show the loading state
1010
new Promise((resolve) => setTimeout(resolve, 1000)),
11-
]);
11+
])
1212
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { defineEnableDraftMode } from "next-sanity/draft-mode";
1+
import {defineEnableDraftMode} from 'next-sanity/draft-mode'
22

3-
import { client } from "@/sanity/lib/client";
4-
import { token } from "@/sanity/lib/token";
3+
import {client} from '@/sanity/lib/client'
4+
import {token} from '@/sanity/lib/token'
55

66
/**
77
* defineEnableDraftMode() is used to enable draft mode. Set the route of this file
88
* as the previewMode.enable option for presentationTool in your sanity.config.ts
99
* Learn more: https://github.com/sanity-io/next-sanity?tab=readme-ov-file#5-integrating-with-sanity-presentation-tool--visual-editing
1010
*/
1111

12-
export const { GET } = defineEnableDraftMode({
13-
client: client.withConfig({ token }),
14-
});
12+
export const {GET} = defineEnableDraftMode({
13+
client: client.withConfig({token}),
14+
})
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
"use client";
1+
'use client'
22

3-
import { isCorsOriginError } from "next-sanity";
4-
import { toast } from "sonner";
3+
import {isCorsOriginError} from 'next-sanity'
4+
import {toast} from 'sonner'
55

66
export function handleError(error: unknown) {
77
if (isCorsOriginError(error)) {
88
// If the error is a CORS origin error, let's display that specific error.
9-
const { addOriginUrl } = error;
9+
const {addOriginUrl} = error
1010
toast.error(`Sanity Live couldn't connect`, {
1111
description: `Your origin is blocked by CORS policy`,
1212
duration: Infinity,
1313
action: addOriginUrl
1414
? {
15-
label: "Manage",
16-
onClick: () => window.open(addOriginUrl.toString(), "_blank"),
15+
label: 'Manage',
16+
onClick: () => window.open(addOriginUrl.toString(), '_blank'),
1717
}
1818
: undefined,
19-
});
19+
})
2020
} else if (error instanceof Error) {
21-
console.error(error);
22-
toast.error(error.name, { description: error.message, duration: Infinity });
21+
console.error(error)
22+
toast.error(error.name, {description: error.message, duration: Infinity})
2323
} else {
24-
console.error(error);
25-
toast.error("Unknown error", {
26-
description: "Check the console for more details",
24+
console.error(error)
25+
toast.error('Unknown error', {
26+
description: 'Check the console for more details',
2727
duration: Infinity,
28-
});
28+
})
2929
}
3030
}
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { Image } from "next-sanity/image";
1+
import {Image} from 'next-sanity/image'
22

3-
import { urlForImage } from "@/sanity/lib/utils";
4-
import DateComponent from "@/app/components/Date";
3+
import {urlForImage} from '@/sanity/lib/utils'
4+
import DateComponent from '@/app/components/Date'
55

66
type Props = {
77
person: {
8-
firstName: string | null;
9-
lastName: string | null;
10-
picture?: any;
11-
};
12-
date?: string;
13-
small?: boolean;
14-
};
8+
firstName: string | null
9+
lastName: string | null
10+
picture?: any
11+
}
12+
date?: string
13+
small?: boolean
14+
}
1515

16-
export default function Avatar({ person, date, small = false }: Props) {
17-
const { firstName, lastName, picture } = person;
16+
export default function Avatar({person, date, small = false}: Props) {
17+
const {firstName, lastName, picture} = person
1818

1919
return (
2020
<div className="flex items-center font-mono">
2121
{picture?.asset?._ref ? (
22-
<div className={`${small ? "h-6 w-6 mr-2" : "h-9 w-9 mr-4"}`}>
22+
<div className={`${small ? 'h-6 w-6 mr-2' : 'h-9 w-9 mr-4'}`}>
2323
<Image
24-
alt={picture?.alt || ""}
24+
alt={picture?.alt || ''}
2525
className="h-full rounded-full object-cover"
2626
height={small ? 32 : 48}
2727
width={small ? 32 : 48}
2828
src={
2929
urlForImage(picture)
3030
?.height(small ? 64 : 96)
3131
.width(small ? 64 : 96)
32-
.fit("crop")
32+
.fit('crop')
3333
.url() as string
3434
}
3535
/>
@@ -39,14 +39,14 @@ export default function Avatar({ person, date, small = false }: Props) {
3939
)}
4040
<div className="flex flex-col">
4141
{firstName && lastName && (
42-
<div className={`font-bold ${small ? "text-sm" : ""}`}>
42+
<div className={`font-bold ${small ? 'text-sm' : ''}`}>
4343
{firstName} {lastName}
4444
</div>
4545
)}
46-
<div className={`text-gray-500 ${small ? "text-xs" : "text-sm"}`}>
46+
<div className={`text-gray-500 ${small ? 'text-xs' : 'text-sm'}`}>
4747
<DateComponent dateString={date} />
4848
</div>
4949
</div>
5050
</div>
51-
);
51+
)
5252
}
Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,36 @@
1-
import React from "react";
1+
import React from 'react'
22

3-
import Cta from "@/app/components/Cta";
4-
import Info from "@/app/components/InfoSection";
5-
import { dataAttr } from "@/sanity/lib/utils";
3+
import Cta from '@/app/components/Cta'
4+
import Info from '@/app/components/InfoSection'
5+
import {dataAttr} from '@/sanity/lib/utils'
66

77
type BlocksType = {
8-
[key: string]: React.FC<any>;
9-
};
8+
[key: string]: React.FC<any>
9+
}
1010

1111
type BlockType = {
12-
_type: string;
13-
_key: string;
14-
};
12+
_type: string
13+
_key: string
14+
}
1515

1616
type BlockProps = {
17-
index: number;
18-
block: BlockType;
19-
pageId: string;
20-
pageType: string;
21-
};
17+
index: number
18+
block: BlockType
19+
pageId: string
20+
pageType: string
21+
}
2222

2323
const Blocks: BlocksType = {
2424
callToAction: Cta,
2525
infoSection: Info,
26-
};
26+
}
2727

2828
/**
2929
* Used by the <PageBuilder>, this component renders a the component that matches the block type.
3030
*/
31-
export default function BlockRenderer({
32-
block,
33-
index,
34-
pageId,
35-
pageType,
36-
}: BlockProps) {
31+
export default function BlockRenderer({block, index, pageId, pageType}: BlockProps) {
3732
// Block does exist
38-
if (typeof Blocks[block._type] !== "undefined") {
33+
if (typeof Blocks[block._type] !== 'undefined') {
3934
return (
4035
<div
4136
key={block._key}
@@ -51,7 +46,7 @@ export default function BlockRenderer({
5146
index: index,
5247
})}
5348
</div>
54-
);
49+
)
5550
}
5651
// Block doesn't exist yet
5752
return React.createElement(
@@ -60,6 +55,6 @@ export default function BlockRenderer({
6055
A &ldquo;{block._type}&rdquo; block hasn&apos;t been created
6156
</div>
6257
),
63-
{ key: block._key },
64-
);
58+
{key: block._key},
59+
)
6560
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { stegaClean } from "@sanity/client/stega";
2-
import { Image } from "next-sanity/image";
3-
import { getImageDimensions } from "@sanity/asset-utils";
4-
import { urlForImage } from "@/sanity/lib/utils";
1+
import {stegaClean} from '@sanity/client/stega'
2+
import {Image} from 'next-sanity/image'
3+
import {getImageDimensions} from '@sanity/asset-utils'
4+
import {urlForImage} from '@/sanity/lib/utils'
55

66
interface CoverImageProps {
7-
image: any;
8-
priority?: boolean;
7+
image: any
8+
priority?: boolean
99
}
1010

1111
export default function CoverImage(props: CoverImageProps) {
12-
const { image: source, priority } = props;
12+
const {image: source, priority} = props
1313
const image = source?.asset?._ref ? (
1414
<Image
1515
className="object-cover"
1616
width={getImageDimensions(source).width}
1717
height={getImageDimensions(source).height}
18-
alt={stegaClean(source?.alt) || ""}
18+
alt={stegaClean(source?.alt) || ''}
1919
src={urlForImage(source)?.url() as string}
2020
priority={priority}
2121
/>
22-
) : null;
22+
) : null
2323

24-
return <div className="relative">{image}</div>;
24+
return <div className="relative">{image}</div>
2525
}

‎frontend/app/components/Cta.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Suspense } from "react";
1+
import {Suspense} from 'react'
22

3-
import ResolvedLink from "@/app/components/ResolvedLink";
4-
import { CallToAction } from "@/sanity.types";
3+
import ResolvedLink from '@/app/components/ResolvedLink'
4+
import {CallToAction} from '@/sanity.types'
55

66
type CtaProps = {
7-
block: CallToAction;
8-
index: number;
9-
};
7+
block: CallToAction
8+
index: number
9+
}
1010

11-
export default function CTA({ block }: CtaProps) {
11+
export default function CTA({block}: CtaProps) {
1212
return (
1313
<div className="container my-12">
1414
<div className="bg-gray-50 border border-gray-100 rounded-2xl max-w-3xl">
@@ -33,5 +33,5 @@ export default function CTA({ block }: CtaProps) {
3333
</div>
3434
</div>
3535
</div>
36-
);
36+
)
3737
}

0 commit comments

Comments
 (0)