initialize sanity but studio on localhost not wokring

This commit is contained in:
2025-10-01 10:04:16 -04:00
parent f016b39e5c
commit 07f29c9bb6
53 changed files with 15704 additions and 41 deletions

View File

@@ -0,0 +1,57 @@
import {ComposeIcon} from '@sanity/icons'
export default {
name: 'blogs',
title: 'Blogs',
type: 'document',
icon: ComposeIcon,
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96,
},
},
{
name: 'description',
title: 'Description',
type: 'text',
description: 'Enter a short snippit of the blog'
},
{
name: 'mainImage',
title: 'Main Image',
type: 'image',
options: [
{
hotspot: true
}
]
},
{
name: 'Categories',
title: 'categories',
type: 'array',
of: [{type: 'reference', to: {type: 'categories'}}]
},
{
name: 'publishedAt',
title: 'Published at',
type: 'datetime'
},
{
name: 'body',
title: 'Body',
type: 'blockContent'
}
],
}

View File

@@ -0,0 +1,20 @@
import { defineField, defineType } from 'sanity';
export const categories = defineType({
name: 'categories',
title: 'Categories',
type: 'document',
fields: [
defineField({
name: 'name',
title: 'Name',
type: 'string',
validation: Rule => Rule.required()
}),
defineField({
name: 'description',
title: 'Description',
type: 'text'
}),
],
})

View File

@@ -0,0 +1,60 @@
import { defineField, defineType } from "sanity";
export const frontend = defineType({
name: 'frontend',
title: 'Frontend Mentor',
type: 'document',
fieldsets: [
{
name: 'options',
options: {
collapsible: true,
collapsed: false
}
}
],
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96
},
}),
defineField({
name: 'qrCode',
title: 'QR Code Component',
type: 'qrCode',
fieldset: 'options'
}),
defineField({
name: 'resultsSummary',
title: 'Results Summary',
type: 'resultsSum',
fieldset: 'options'
}),
defineField({
name: 'productPrev',
title: 'Product Preview',
type: 'productInfo',
fieldset: 'options'
}),
defineField({
name: 'news',
type: 'newsData',
fieldset: 'options'
}),
defineField({
name: 'launch',
type: 'launchDate',
fieldset: 'options'
}),
],
})

View File

@@ -0,0 +1,68 @@
import { defineField, defineType } from "sanity";
export const homepage = defineType({
name: 'homepage',
title: 'Homepage',
type: 'document',
fieldsets: [
{
name: 'seo',
title: 'Metadata & SEO',
description: 'Use these fields to override the default metadata',
options: {
collapsible: true,
collapsed: true,
}
},
{
name: 'title',
title: 'Page Title'
}
],
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
fieldset: 'title'
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96
},
fieldset: 'title'
}),
defineField({
name: 'body',
title: 'Body',
type: 'blockContent'
}),
defineField({
name: 'cta',
title: 'Call to Action',
type: 'cta',
}),
defineField({
name: 'tech',
title: "Tech",
type: 'array',
of: [
{
type: 'reference',
to: [
{type: 'technologies'}
]
}
]
}),
defineField({
name: 'seo',
type: 'seo',
fieldset: 'seo'
})
],
})

View File

@@ -0,0 +1,34 @@
import { defineField, defineType, validateBasePaths } from 'sanity';
import { ImagesIcon } from '@sanity/icons'
export const mediaLibrary = defineType({
name: 'media',
title: 'Media Library',
type: 'document',
icon: ImagesIcon,
fields: [
defineField({
name: 'image',
title: 'Image',
type: 'image',
options: {
hotspot: true
}
}),
defineField({
name: 'alt',
title: 'Alternative Text',
type: 'string',
validation: (Rule) => Rule.required().max(250),
description: 'This is used for SEO and accessibility',
}),
],
preview: {
select: {
title: 'alt',
url: 'image.asset.url',
media: 'image', //adding this makes the image show up in standard preview components
},
},
})

View File

@@ -0,0 +1,12 @@
export default {
name: 'metadata',
title: 'Metadata',
type: 'document',
fields: [
{
name: 'customTitle',
title: 'Custom Title',
type: 'string',
},
],
}

View File

@@ -0,0 +1,21 @@
export default {
name: 'navigation',
title: 'Navigation',
type: 'document',
fields: [
{
name: 'navigation',
title: 'Navigation Menu',
type: 'array',
of: [
{
type: 'reference',
to: [
{type: 'pages'},
{type: 'homepage'}
]
}
]
},
],
}

View File

@@ -0,0 +1,43 @@
import MyPreviewComponent from '../../../src/lib/components/MyPreviewComponent';
import { defineField, defineType } from 'sanity';
export const newsPost = defineType({
name: 'newsPost',
title: 'News Posts',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string'
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96
}
}),
defineField({
name: 'image',
type: 'reference',
to: {
type: 'media',
components: {
preview: MyPreviewComponent
}
},
}),
defineField({
name: 'previewText',
title: 'Preview Text',
type: 'text'
}),
defineField({
name: 'category',
type: 'string'
})
],
})

View File

@@ -0,0 +1,50 @@
import { defineField, defineType } from "sanity";
export const pages = defineType({
name: 'pages',
title: 'Pages',
type: 'document',
fieldsets: [
{
name: 'seo',
title: 'Metadata & SEO',
description: 'Use these fields to override the default metadata',
options: {
collapsible: true,
collapsed: true,
}
},
{
name: 'title',
title: 'Page Title'
}
],
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
fieldset: 'title'
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96
},
fieldset: 'title'
}),
defineField({
name: 'body',
title: 'Body',
type: 'blockContent'
}),
defineField({
name: 'seo',
type: 'seo',
fieldset: 'seo'
})
],
})

View File

@@ -0,0 +1,128 @@
import { defineField, defineType } from "sanity";
import {Stack, Card, Flex } from '@sanity/ui'
import { RocketIcon } from '@sanity/icons'
function MyPreviewComponent(props: any) {
const {title, url} = props
return (
<Flex align="center" justify="center" height="fill">
<Card border padding={3}>
<Stack space={3} marginBottom={3}>
<img src={url} alt={title} style={{width: '100%'}} />
</Stack>
</Card>
</Flex>
)
}
export const projects = defineType({
name: 'projects',
title: 'Projects',
type: 'document',
icon: RocketIcon,
fieldsets: [
{
name: 'title',
title: 'Title'
},
{
name: 'projectLinks',
title: 'Project Links'
}
],
fields: [
defineField({
name: 'title',
title: 'Project Title',
type: 'string',
fieldset: 'title'
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96
},
fieldset: 'title'
}),
defineField({
name: 'order',
title: 'Order',
type: 'number',
fieldset: 'title',
}),
defineField({
name: 'description',
title: 'Description',
type: 'text',
rows: 5
}),
defineField({
name: 'featured',
title: 'Featured',
type: 'boolean',
initialValue: false,
fieldset: 'title'
}),
defineField({
name: 'body',
title: 'Body',
type: 'blockContent',
}),
defineField({
name: 'image',
title: 'Main Image',
type: 'reference',
to: {
type: 'media',
components: {
preview: MyPreviewComponent
}
},
}),
defineField({
name: 'link',
title: 'Link to Project',
type: 'url',
fieldset: 'projectLinks'
}),
defineField({
name: 'github',
title: 'GitHub Reop',
type: 'url',
fieldset: 'projectLinks'
}),
defineField({
name: 'tags',
title: 'Tags',
type: 'array',
of: [
{
type: 'reference',
to: [
{type: 'categories'}
]
}
]
}),
defineField({
name: 'stats',
title: 'Statistics',
type: 'array',
of: [
{
type: 'stats',
}
]
}),
],
preview: {
select: {
title: 'title',
media: 'image'
}
}
})

View File

@@ -0,0 +1,27 @@
export default {
name: 'siteSettings',
title: 'Site Settings',
type: 'document',
fields: [
{
name: 'siteTitle',
title: 'Site Title',
type: 'string',
},
{
name: 'contact',
type: 'contact'
},
{
name: 'logo',
title: 'Logo',
type: 'image'
},
{
name: 'favicon',
title: 'Favicon',
type: 'image',
description: 'This is used for the tab favicon as well as the mobile menu'
},
],
}

View File

@@ -0,0 +1,26 @@
import { defineField, defineType } from "sanity";
import MyPreviewComponent from "../../../src/lib/components/MyPreviewComponent";
export const technologies = defineType({
name: 'technologies',
title: 'Technologies',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
}),
defineField({
name: 'image',
type: 'reference',
to: {
type: 'media',
components: {
preview: MyPreviewComponent
}
},
}),
],
})