Skip to content

Commit 89545fc

Browse files
committed
studio working
1 parent a33af79 commit 89545fc

File tree

5 files changed

+278
-54
lines changed

5 files changed

+278
-54
lines changed

apps/sanity/components/YouTubePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useCallback, useState } from "react";
44
import { Box, Stack, TextInput } from "@sanity/ui";
55
import { type ObjectInputProps, set, unset } from "sanity";
6-
import { youtubeParser } from "@/lib/utils";
6+
import { youtubeParser } from "../lib/utils";
77

88
export function VideoPreview(props: { youtube: string }) {
99
const [loadEmbed, setLoadEmbed] = useState(false);

apps/sanity/lib/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Extract YouTube video ID from various URL formats
3+
*/
4+
export function youtubeParser(url: string): string | null {
5+
if (!url || typeof url !== "string") return null;
6+
const regExp =
7+
/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
8+
const match = url.match(regExp);
9+
return match && match[2].length === 11 ? match[2] : null;
10+
}

apps/sanity/package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
},
1111
"dependencies": {
1212
"@codingcatdev/sanity-plugin-podcast-rss": "^1.0.0",
13+
"@portabletext/block-tools": "^5.1.0",
14+
"@portabletext/react": "^6.0.3",
15+
"@sanity/assist": "^6.0.3",
1316
"@sanity/code-input": "^5.0.0",
17+
"@sanity/icons": "^3.7.4",
18+
"@sanity/ui": "^3.1.14",
1419
"@sanity/vision": "^3.0.0",
20+
"date-fns": "^4.1.0",
21+
"lucide-react": "^0.577.0",
22+
"micromark": "^4.0.2",
23+
"micromark-extension-gfm-table": "^2.1.1",
1524
"react": "^19.0.0",
1625
"react-dom": "^19.0.0",
26+
"react-icons": "^5.6.0",
27+
"react-twitter-embed": "^4.0.4",
1728
"sanity": "^3.0.0",
1829
"sanity-plugin-media": "^2.0.0",
19-
"styled-components": "^6.0.0"
30+
"styled-components": "^6.1.15"
2031
},
2132
"devDependencies": {
2233
"@types/react": "^19.0.0",

apps/sanity/sanity.config.ts

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const projectId = process.env.SANITY_STUDIO_PROJECT_ID || "hfh83o0w";
4848
const dataset = process.env.SANITY_STUDIO_DATASET || "production";
4949
const apiVersion = process.env.SANITY_STUDIO_API_VERSION || "2025-09-30";
5050
const studioUrl = "/";
51+
// Set SANITY_STUDIO_DISABLE_PRESENTATION=true if you get network errors to api.sanity.io (e.g. firewall/VPN)
52+
const presentationEnabled =
53+
process.env.SANITY_STUDIO_DISABLE_PRESENTATION !== "true";
5154

5255
function resolveHref(type: string, slug?: string): string | undefined {
5356
switch (type) {
@@ -171,45 +174,49 @@ export default defineConfig({
171174
},
172175
},
173176
plugins: [
174-
presentationTool({
175-
resolve: {
176-
mainDocuments: defineDocuments([
177-
{
178-
route: "/post/:slug",
179-
filter: `_type == "post" && slug.current == $slug`,
180-
},
181-
]),
182-
locations: {
183-
settings: defineLocations({
184-
locations: [homeLocation],
185-
message: "This document is used on all pages",
186-
tone: "caution",
187-
}),
188-
post: defineLocations({
189-
select: {
190-
title: "title",
191-
slug: "slug.current",
192-
},
193-
resolve: (doc) => ({
194-
locations: [
177+
...(presentationEnabled
178+
? [
179+
presentationTool({
180+
resolve: {
181+
mainDocuments: defineDocuments([
195182
{
196-
title: doc?.title || "Untitled",
197-
// biome-ignore lint/style/noNonNullAssertion: resolveHref returns string for known types
198-
href: resolveHref("post", doc?.slug)!,
183+
route: "/post/:slug",
184+
filter: `_type == "post" && slug.current == $slug`,
199185
},
200-
homeLocation,
201-
],
202-
}),
186+
]),
187+
locations: {
188+
settings: defineLocations({
189+
locations: [homeLocation],
190+
message: "This document is used on all pages",
191+
tone: "caution",
192+
}),
193+
post: defineLocations({
194+
select: {
195+
title: "title",
196+
slug: "slug.current",
197+
},
198+
resolve: (doc) => ({
199+
locations: [
200+
{
201+
title: doc?.title || "Untitled",
202+
// biome-ignore lint/style/noNonNullAssertion: resolveHref returns string for known types
203+
href: resolveHref("post", doc?.slug)!,
204+
},
205+
homeLocation,
206+
],
207+
}),
208+
}),
209+
},
210+
},
211+
previewUrl: {
212+
previewMode: {
213+
enable: "/api/draft-mode/enable",
214+
disable: "/api/draft-mode/disable",
215+
},
216+
},
203217
}),
204-
},
205-
},
206-
previewUrl: {
207-
previewMode: {
208-
enable: "/api/draft-mode/enable",
209-
disable: "/api/draft-mode/disable",
210-
},
211-
},
212-
}),
218+
]
219+
: []),
213220
structureTool({ structure: podcastStructure() }),
214221
// Configures the global "new document" button, and document actions, to suit the Settings document singleton
215222
singletonPlugin([

0 commit comments

Comments
 (0)