-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sanity): set up
sanity
configuration
- Loading branch information
1 parent
50b8122
commit 9963ca1
Showing
15 changed files
with
4,198 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
NEXT_PUBLIC_SANITY_DATASET=production | ||
NEXT_PUBLIC_SANITY_PROJECT_ID=qy853ayl | ||
NEXT_PUBLIC_SANITY_API_VERSION=2021-10-21 | ||
|
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
NEXT_PUBLIC_SANITY_DATASET= | ||
NEXT_PUBLIC_SANITY_PROJECT_ID= | ||
NEXT_PUBLIC_SANITY_API_VERSION= |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": ["next/core-web-vitals", "@sanity/eslint-config-studio"] | ||
} |
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,16 @@ | ||
import Head from "next/head"; | ||
import { NextStudio } from "next-sanity/studio"; | ||
import { NextStudioHead } from "next-sanity/studio/head"; | ||
|
||
import config from "../../sanity.config"; | ||
|
||
export default function StudioPage() { | ||
return ( | ||
<> | ||
<Head> | ||
<NextStudioHead /> | ||
</Head> | ||
<NextStudio config={config} /> | ||
</> | ||
); | ||
} |
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 { 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,22 @@ | ||
import { defineConfig } from "sanity"; | ||
import { deskTool } from "sanity/desk"; | ||
import { visionTool } from "@sanity/vision"; | ||
import { schemaTypes } from "./schemas"; | ||
|
||
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!; | ||
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET!; | ||
|
||
export default defineConfig({ | ||
basePath: "/studio", | ||
name: "janszewczyk_github_io", | ||
title: "janszewczyk.github.io", | ||
|
||
projectId, | ||
dataset, | ||
|
||
plugins: [deskTool(), visionTool()], | ||
|
||
schema: { | ||
types: schemaTypes | ||
} | ||
}); |
File renamed without changes.
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,50 @@ | ||
import { defineField, defineType } from "sanity"; | ||
|
||
export default defineType({ | ||
name: "author", | ||
title: "Author", | ||
type: "document", | ||
fields: [ | ||
defineField({ | ||
name: "name", | ||
title: "Name", | ||
type: "string" | ||
}), | ||
defineField({ | ||
name: "slug", | ||
title: "Slug", | ||
type: "slug", | ||
options: { | ||
source: "name", | ||
maxLength: 96 | ||
} | ||
}), | ||
defineField({ | ||
name: "image", | ||
title: "Image", | ||
type: "image", | ||
options: { | ||
hotspot: true | ||
} | ||
}), | ||
defineField({ | ||
name: "bio", | ||
title: "Bio", | ||
type: "array", | ||
of: [ | ||
{ | ||
title: "Block", | ||
type: "block", | ||
styles: [{ title: "Normal", value: "normal" }], | ||
lists: [] | ||
} | ||
] | ||
}) | ||
], | ||
preview: { | ||
select: { | ||
title: "name", | ||
media: "image" | ||
} | ||
} | ||
}); |
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,68 @@ | ||
import { defineType, defineArrayMember } from "sanity"; | ||
|
||
/** | ||
* This is the schema definition for the rich text fields used for | ||
* for this blog studio. When you import it in schemas.js it can be | ||
* reused in other parts of the studio with: | ||
* { | ||
* name: 'someName', | ||
* title: 'Some title', | ||
* type: 'blockContent' | ||
* } | ||
* | ||
*/ | ||
export default defineType({ | ||
title: "Block Content", | ||
name: "blockContent", | ||
type: "array", | ||
of: [ | ||
defineArrayMember({ | ||
title: "Block", | ||
type: "block", | ||
// Styles let you set what your user can mark up blocks with. These | ||
// correspond with HTML tags, but you can set any title or value | ||
// you want and decide how you want to deal with it where you want to | ||
// use your content. | ||
styles: [ | ||
{ title: "Normal", value: "normal" }, | ||
{ title: "H1", value: "h1" }, | ||
{ title: "H2", value: "h2" }, | ||
{ title: "H3", value: "h3" }, | ||
{ title: "H4", value: "h4" }, | ||
{ title: "Quote", value: "blockquote" } | ||
], | ||
lists: [{ title: "Bullet", value: "bullet" }], | ||
// Marks let you mark up inline text in the block editor. | ||
marks: { | ||
// Decorators usually describe a single property – e.g. a typographic | ||
// preference or highlighting by editors. | ||
decorators: [ | ||
{ title: "Strong", value: "strong" }, | ||
{ title: "Emphasis", value: "em" } | ||
], | ||
// Annotations can be any object structure – e.g. a link or a footnote. | ||
annotations: [ | ||
{ | ||
title: "URL", | ||
name: "link", | ||
type: "object", | ||
fields: [ | ||
{ | ||
title: "URL", | ||
name: "href", | ||
type: "url" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}), | ||
// You can add additional types here. Note that you can't use | ||
// primitive types such as 'string' and 'number' in the same array | ||
// as a block type. | ||
defineArrayMember({ | ||
type: "image", | ||
options: { hotspot: true } | ||
}) | ||
] | ||
}); |
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,19 @@ | ||
import { defineField, defineType } from "sanity"; | ||
|
||
export default defineType({ | ||
name: "category", | ||
title: "Category", | ||
type: "document", | ||
fields: [ | ||
defineField({ | ||
name: "title", | ||
title: "Title", | ||
type: "string" | ||
}), | ||
defineField({ | ||
name: "description", | ||
title: "Description", | ||
type: "text" | ||
}) | ||
] | ||
}); |
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,7 @@ | ||
import blockContent from "./blockContent"; | ||
import category from "./category"; | ||
import post from "./post"; | ||
import author from "./author"; | ||
import picture from "./picture"; | ||
|
||
export const schemaTypes = [post, author, category, blockContent, picture]; |
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,24 @@ | ||
import { defineField, defineType } from "sanity"; | ||
|
||
export default defineType({ | ||
name: "picture", | ||
title: "Picture", | ||
type: "document", | ||
fields: [ | ||
defineField({ | ||
name: "img", | ||
title: "Image", | ||
type: "image", | ||
options: { | ||
hotspot: true | ||
}, | ||
validation: (Rule) => Rule.required() | ||
}), | ||
defineField({ | ||
name: "alt", | ||
title: "Alternative Text", | ||
type: "string", | ||
validation: (Rule) => Rule.required() | ||
}) | ||
] | ||
}); |
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,65 @@ | ||
import { defineField, defineType } from "sanity"; | ||
|
||
export default defineType({ | ||
name: "post", | ||
title: "Post", | ||
type: "document", | ||
fields: [ | ||
defineField({ | ||
name: "title", | ||
title: "Title", | ||
type: "string" | ||
}), | ||
defineField({ | ||
name: "slug", | ||
title: "Slug", | ||
type: "slug", | ||
options: { | ||
source: "title", | ||
maxLength: 96 | ||
} | ||
}), | ||
defineField({ | ||
name: "author", | ||
title: "Author", | ||
type: "reference", | ||
to: { type: "author" } | ||
}), | ||
defineField({ | ||
name: "mainImage", | ||
title: "Main image", | ||
type: "image", | ||
options: { | ||
hotspot: true | ||
} | ||
}), | ||
defineField({ | ||
name: "categories", | ||
title: "Categories", | ||
type: "array", | ||
of: [{ type: "reference", to: { type: "category" } }] | ||
}), | ||
defineField({ | ||
name: "publishedAt", | ||
title: "Published at", | ||
type: "datetime" | ||
}), | ||
defineField({ | ||
name: "body", | ||
title: "Body", | ||
type: "blockContent" | ||
}) | ||
], | ||
|
||
preview: { | ||
select: { | ||
title: "title", | ||
author: "author.name", | ||
media: "mainImage" | ||
}, | ||
prepare(selection) { | ||
const { author } = selection; | ||
return { ...selection, subtitle: author && `by ${author}` }; | ||
} | ||
} | ||
}); |
Oops, something went wrong.