-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup sanity as a cms in project (#626)
* set up sanity * update workflows * remove target from tsconfig * fix broken story * fix another story * use hash to allow ssg with studio * add files * fix workflows
- Loading branch information
1 parent
24d64ba
commit 232f120
Showing
16 changed files
with
5,040 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* This configuration file lets you run `$ sanity [command]` in this folder | ||
* Go to https://www.sanity.io/docs/cli to learn more. | ||
**/ | ||
import { defineCliConfig } from "sanity/cli" | ||
|
||
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID | ||
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET | ||
|
||
export default defineCliConfig({ api: { projectId, dataset } }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use client" | ||
|
||
/** | ||
* This configuration is used to for the Sanity Studio that’s mounted on the `\src\app\studio\[[...tool]]\page.tsx` route | ||
*/ | ||
|
||
import { visionTool } from "@sanity/vision" | ||
import { defineConfig } from "sanity" | ||
import { structureTool } from "sanity/structure" | ||
|
||
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works | ||
import { apiVersion, dataset, projectId } from "./sanity/env" | ||
import { schema } from "./sanity/schema" | ||
|
||
export default defineConfig({ | ||
basePath: "/studio", | ||
projectId, | ||
dataset, | ||
// Add and edit the content schema in the './sanity/schema' folder | ||
schema, | ||
plugins: [ | ||
structureTool(), | ||
// Vision is a tool that lets you query your content with GROQ in the studio | ||
// https://www.sanity.io/docs/the-vision-plugin | ||
visionTool({ defaultApiVersion: apiVersion }) | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const apiVersion = | ||
process.env.NEXT_PUBLIC_SANITY_API_VERSION || "2024-07-13" | ||
|
||
export const dataset = assertValue( | ||
process.env.NEXT_PUBLIC_SANITY_DATASET, | ||
"Missing environment variable: NEXT_PUBLIC_SANITY_DATASET" | ||
) | ||
|
||
export const projectId = assertValue( | ||
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, | ||
"Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID" | ||
) | ||
|
||
export const useCdn = false | ||
|
||
function assertValue<T>(v: T | undefined, errorMessage: string): T { | ||
if (v === undefined) { | ||
throw new Error(errorMessage) | ||
} | ||
|
||
return v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createClient } from "next-sanity" | ||
|
||
import { apiVersion, dataset, projectId, useCdn } from "../env" | ||
|
||
export const client = createClient({ | ||
projectId, | ||
dataset, | ||
apiVersion, | ||
useCdn, | ||
perspective: "published" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import createImageUrlBuilder from "@sanity/image-url" | ||
import type { Image } from "sanity" | ||
|
||
import { dataset, projectId } from "../env" | ||
|
||
const imageBuilder = createImageUrlBuilder({ | ||
projectId: projectId || "", | ||
dataset: dataset || "" | ||
}) | ||
|
||
export const urlForImage = (source: Image) => { | ||
return imageBuilder?.image(source).auto("format").fit("max").url() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { type SchemaTypeDefinition } from "sanity" | ||
|
||
export const schema: { types: SchemaTypeDefinition[] } = { | ||
types: [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use client" | ||
/** | ||
* This route is responsible for the built-in authoring environment using Sanity Studio. | ||
* All routes under your studio path is handled by this file using Next.js' catch-all routes: | ||
* https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes | ||
* | ||
* You can learn more about the next-sanity package here: | ||
* https://github.com/sanity-io/next-sanity | ||
*/ | ||
|
||
import { NextStudio } from "next-sanity/studio" | ||
import config from "../../../sanity.config" | ||
|
||
export default function StudioPage() { | ||
return <NextStudio config={config} history="hash" /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.