Skip to content

Commit 541dbfa

Browse files
author
Alex Patterson
committed
stega clean top-level
1 parent 8cc6f6d commit 541dbfa

6 files changed

Lines changed: 22 additions & 31 deletions

File tree

‎components/avatar.tsx‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22

33
import { CldImage } from "next-cloudinary";
4-
import { stegaClean } from "@sanity/client/stega";
54
import type { Author } from "@/sanity.types";
65
import Link from "next/link";
76

@@ -22,17 +21,16 @@ export default function Avatar({
2221
width,
2322
height,
2423
}: Props) {
25-
const source = stegaClean(coverImage);
2624

27-
if (!href && source?.public_id) {
25+
if (!href && coverImage?.public_id) {
2826
return (
2927
<div className={`${imgSize ? imgSize : "w-12 h-12 mr-4"}`}>
3028
<CldImage
3129
className="w-full h-auto"
3230
width={width || 48}
3331
height={height || 48}
34-
alt={source?.context?.custom?.alt || ""}
35-
src={source.public_id}
32+
alt={coverImage?.context?.custom?.alt || ""}
33+
src={coverImage.public_id}
3634
config={{
3735
url: {
3836
secureDistribution: "media.codingcat.dev",
@@ -43,17 +41,17 @@ export default function Avatar({
4341
</div>
4442
);
4543
}
46-
if (href && source?.public_id) {
44+
if (href && coverImage?.public_id) {
4745
return (
4846
<Link className="flex items-center text-xl" href={href}>
49-
{source?.public_id && (
47+
{coverImage?.public_id && (
5048
<div className={`${imgSize ? imgSize : "w-12 h-12 mr-4"}`}>
5149
<CldImage
5250
className="w-full h-auto"
5351
width={width || 48}
5452
height={height || 48}
55-
alt={source?.context?.custom?.alt || ""}
56-
src={source.public_id}
53+
alt={coverImage?.context?.custom?.alt || ""}
54+
src={coverImage.public_id}
5755
config={{
5856
url: {
5957
secureDistribution: "media.codingcat.dev",

‎components/block-image.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CloudinaryAsset } from "@/sanity.types";
22
import CloudinaryImage from "@/components/cloudinary-image";
3-
import { stegaClean } from "@sanity/client/stega";
43

54
import { getCldImageUrl } from "next-cloudinary";
65

@@ -11,11 +10,10 @@ interface CoverImageProps {
1110
export default async function BlockImage(props: CoverImageProps) {
1211
const { image: originalImage } = props;
1312

14-
const source = stegaClean(originalImage);
1513
let image;
16-
if (source?.public_id) {
14+
if (originalImage?.public_id) {
1715
const imageUrl = getCldImageUrl({
18-
src: source.public_id,
16+
src: originalImage.public_id,
1917
width: 100,
2018
});
2119
const response = await fetch(imageUrl);
@@ -30,8 +28,8 @@ export default async function BlockImage(props: CoverImageProps) {
3028
width={1920}
3129
height={1080}
3230
sizes="100vw"
33-
alt={source?.context?.custom?.alt || ""}
34-
src={source?.public_id}
31+
alt={originalImage?.context?.custom?.alt || ""}
32+
src={originalImage?.public_id}
3533
placeholder="blur"
3634
blurDataURL={dataUrl}
3735
config={{

‎components/cover-image.tsx‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22
import { CloudinaryAsset } from "@/sanity.types";
33
import CloudinaryImage from "@/components/cloudinary-image";
4-
import { stegaClean } from "@sanity/client/stega";
54
import { getCldImageUrl } from "next-cloudinary";
65
import { useEffect, useState } from "react";
76

@@ -23,13 +22,12 @@ export default function CoverImage(props: CoverImageProps) {
2322
height,
2423
quality,
2524
} = props;
26-
const source = stegaClean(originalImage);
2725
const [dataUrl, setDataUrl] = useState("");
2826

2927
useEffect(() => {
30-
if (!source?.public_id) return;
31-
getImageUrl(source?.public_id);
32-
}, [source?.public_id]);
28+
if (!originalImage?.public_id) return;
29+
getImageUrl(originalImage?.public_id);
30+
}, [originalImage?.public_id]);
3331

3432
const getImageUrl = async (src: string) => {
3533
const imageUrl = getCldImageUrl({
@@ -44,7 +42,7 @@ export default function CoverImage(props: CoverImageProps) {
4442
};
4543

4644
let image;
47-
if (source?.public_id && dataUrl) {
45+
if (originalImage?.public_id && dataUrl) {
4846
image = (
4947
<CloudinaryImage
5048
className={className || "w-full h-auto aspect-video"}
@@ -55,8 +53,8 @@ export default function CoverImage(props: CoverImageProps) {
5553
sizes="(max-width: 768px) 100vw,
5654
(max-width: 1200px) 50vw,
5755
33vw"
58-
alt={source?.context?.custom?.alt || ""}
59-
src={source?.public_id}
56+
alt={originalImage?.context?.custom?.alt || ""}
57+
src={originalImage?.public_id}
6058
placeholder="blur"
6159
blurDataURL={dataUrl}
6260
config={{

‎components/cover-video.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CloudinaryAsset } from "@/sanity.types";
22
import CloudinaryVideo from "@/components/cloudinary-video";
3-
import { stegaClean } from "@sanity/client/stega";
43

54
interface CoverImageProps {
65
cloudinaryVideo: CloudinaryAsset | null | undefined;
@@ -9,15 +8,13 @@ interface CoverImageProps {
98
export default function CoverVideo(props: CoverImageProps) {
109
const { cloudinaryVideo } = props;
1110

12-
const source = stegaClean(cloudinaryVideo);
13-
14-
const video = source?.public_id ? (
11+
const video = cloudinaryVideo?.public_id ? (
1512
<CloudinaryVideo
1613
id={cloudinaryVideo?.public_id}
1714
className="w-full h-auto"
1815
width={1920}
1916
height={1080}
20-
src={source?.public_id}
17+
src={cloudinaryVideo?.public_id}
2118
config={{
2219
url: {
2320
secureDistribution: "media.codingcat.dev",

‎sanity/lib/client.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const client = createClient({
1212
studioUrl,
1313
// logger: console,
1414
filter: (props) => {
15-
if (props.sourcePath.at(0) !== "content") {
15+
const type = props.sourcePath.at(0) as string;
16+
if (!["content"].includes(type)) {
1617
return false;
1718
} else {
1819
return props.filterDefault(props);

‎sanity/lib/fetch.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export async function sanityFetch<QueryResponse>({
1919
* The Sanity Presentation Tool will enable Draft Mode when loading up the live preview, and we use it as a signal for when to embed source maps.
2020
* When outside of the Sanity Studio we also support the Vercel Toolbar Visual Editing feature, which is only enabled in production when it's a Vercel Preview Deployment.
2121
*/
22-
stega = perspective === "previewDrafts" ||
23-
process.env.VERCEL_ENV === "preview",
22+
stega = perspective === "previewDrafts" || process.env.VERCEL_ENV === "preview",
2423
}: {
2524
query: string;
2625
params?: QueryParams;

0 commit comments

Comments
 (0)