feat: embed Sanity Studio

This commit is contained in:
Dorian Niemiec 2024-09-07 14:59:43 +02:00
parent 3e2bcab3ce
commit f26e3d45a7
20 changed files with 440 additions and 15776 deletions

View file

@ -17,7 +17,7 @@ EMAIL_NEWSLETTER_ADDRESS=
EMAIL_CONTACT_ADDRESS=
EMAIL_CONTACT_DEST=
SANITY_PROJECT_ID=
NEXT_PUBLIC_SANITY_PROJECT_ID=
NEXT_PUBLIC_HCAPTCHA_SITE_KEY=
HCAPTCHA_SECRET=

View file

@ -0,0 +1,11 @@
import { NextStudio } from "next-sanity/studio";
import React from "react";
import config from "@/sanity.config";
export const dynamic = "force-static";
export { metadata, viewport } from "next-sanity/studio";
export default function StudioPage() {
return <NextStudio config={config} />;
}

View file

@ -4,7 +4,7 @@ import imageUrlBuilder from "@sanity/image-url";
const config = {
apiVersion: "2023-08-08",
dataset: "production",
projectId: `${process.env.SANITY_PROJECT_ID}`,
projectId: `${process.env.NEXT_PUBLIC_SANITY_PROJECT_ID}`,
useCdn: false // ensure fresh data
};

1575
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,7 @@
"react-hook-form": "^7.52.0",
"react-markdown": "^9.0.1",
"rss": "^1.2.2",
"sanity": "^3.57.1",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"uploadthing": "^6.12.0",

8
sanity.cli.ts Normal file
View file

@ -0,0 +1,8 @@
import { defineCliConfig } from "sanity/cli";
export default defineCliConfig({
api: {
projectId: `${process.env.NEXT_PUBLIC_SANITY_PROJECT_ID}`,
dataset: "production"
}
});

21
sanity.config.ts Normal file
View file

@ -0,0 +1,21 @@
"use client";
import { defineConfig } from "sanity";
import { structureTool } from "sanity/structure";
import { visionTool } from "@sanity/vision";
import { schemaTypes } from "./schemaTypes";
import { codeInput } from "@sanity/code-input";
export default defineConfig({
name: "default",
title: "svrjs",
projectId: `${process.env.NEXT_PUBLIC_SANITY_PROJECT_ID}`,
dataset: "production",
plugins: [structureTool(), visionTool(), codeInput()],
schema: {
types: schemaTypes
}
});

51
schemaTypes/blog.ts Normal file
View file

@ -0,0 +1,51 @@
export default {
name: "blog",
type: "document",
title: "Blog",
fields: [
{
name: "title",
type: "string",
title: "Title"
},
{
name: "slug",
type: "slug",
title: "Slug Title",
options: {
source: "title"
}
},
{
name: "titleImage",
type: "image",
title: "Title Image"
},
// {
// name: 'publishedAt',
// title: 'Published At',
// type: 'datetime',
// },
{
name: "smallDescription",
type: "text",
title: "Small Description"
},
{
name: "content",
type: "array",
title: "Content",
of: [
{
type: "block"
},
{
type: "image"
},
{
type: "code"
}
]
}
]
};

3
schemaTypes/index.ts Normal file
View file

@ -0,0 +1,3 @@
import blog from "./blog";
export const schemaTypes = [blog];

View file

@ -1,3 +0,0 @@
{
"extends": "@sanity/eslint-config-studio"
}

29
svrjs/.gitignore vendored
View file

@ -1,29 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# Dependencies
/node_modules
/.pnp
.pnp.js
# Compiled Sanity Studio
/dist
# Temporary Sanity runtime, generated by the CLI on every dev server start
/.sanity
# Logs
/logs
*.log
# Coverage directory used by testing tools
/coverage
# Misc
.DS_Store
*.pem
# Typescript
*.tsbuildinfo
# Dotenv and similar local-only files
*.local

View file

@ -1,9 +0,0 @@
# Sanity Clean Content Studio
Congratulations, you have now installed the Sanity Content Studio, an open-source real-time content editing environment connected to the Sanity backend.
Now you can do the following things:
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
- [Join the community Slack](https://slack.sanity.io/?utm_source=readme)
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)

14365
svrjs/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,37 +0,0 @@
{
"name": "svrjs",
"private": true,
"version": "1.0.0",
"main": "package.json",
"license": "UNLICENSED",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"deploy-graphql": "sanity graphql deploy"
},
"keywords": [
"sanity"
],
"dependencies": {
"@sanity/vision": "^3.53.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sanity": "^3.53.0",
"styled-components": "^6.1.8"
},
"devDependencies": {
"@sanity/eslint-config-studio": "^4.0.0",
"@types/react": "^18.0.25",
"eslint": "^8.6.0",
"prettier": "^3.0.2",
"typescript": "^5.1.6"
},
"prettier": {
"semi": false,
"printWidth": 100,
"bracketSpacing": false,
"singleQuote": true
}
}

View file

@ -1,8 +0,0 @@
import {defineCliConfig} from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: '0u8q501s',
dataset: 'production',
},
})

View file

@ -1,19 +0,0 @@
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemaTypes'
import {codeInput} from '@sanity/code-input'
export default defineConfig({
name: 'default',
title: 'svrjs',
projectId: '0u8q501s',
dataset: 'production',
plugins: [structureTool(), visionTool(), codeInput()],
schema: {
types: schemaTypes,
},
})

View file

@ -1,51 +0,0 @@
export default {
name: 'blog',
type: 'document',
title: 'Blog',
fields: [
{
name: 'title',
type: 'string',
title: 'Title',
},
{
name: 'slug',
type: 'slug',
title: 'Slug Title',
options: {
source: 'title',
},
},
{
name: 'titleImage',
type: 'image',
title: 'Title Image',
},
// {
// name: 'publishedAt',
// title: 'Published At',
// type: 'datetime',
// },
{
name: 'smallDescription',
type: 'text',
title: 'Small Description',
},
{
name: 'content',
type: 'array',
title: 'Content',
of: [
{
type: 'block',
},
{
type: 'image',
},
{
type: 'code',
},
],
},
],
}

View file

@ -1,3 +0,0 @@
import blog from './blog'
export const schemaTypes = [blog]

View file

@ -1 +0,0 @@
Files placed here will be served by the Sanity server under the `/static`-prefix

View file

@ -1,17 +0,0 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "Preserve",
"moduleDetection": "force",
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}