Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial is not compatible with Sanity V3 #47

Open
RobWattCT opened this issue Dec 27, 2022 · 9 comments
Open

Tutorial is not compatible with Sanity V3 #47

RobWattCT opened this issue Dec 27, 2022 · 9 comments

Comments

@RobWattCT
Copy link

The steps in the video do not work with the latest version of Sanity, version 3.

i.e. It's no longer possible to follow the exact steps of the video's Sanity setup and result in getting the Sanity Server up and running with the schema displaying.

There's a new prompt to setup the project for TypeScript (yes/no ?). Need clarity on that.

The project uses a schema.js file inside /schemas/, but installing the latest Sanity generates index.js file, with different code to schema.js (excluding what gets added to pull in the project's other schemas files).

It would be great if this could be addressed or if I could get some help on a workaround as I would love to build this tutorial without roadblocks.

@adrianhajdin and team, I love your work! Thank you for investing into the community.

@hasanizmir
Copy link

hasanizmir commented Dec 28, 2022

Hi @RobWattCT ,

  • I am answering "no" to the TypeScript question and using it in that manner without any issues. Because TypeScript is not used in the project.
  • You can use the " index.js " file instead of "schema.js" like this:
import works from './works'
import testimonials from './testimonials'
import brands from './brands'

export const schemaTypes = [works, testimonials, brands]

@theDevJudge
Copy link

The fact is sanity v3 and v2 has various connection process however the v2 method works for v3. The only difference for me was to use npm run dev on the backend folder instead of sanity start. Other than that everything is still the same. Good luck.

@BurningVertex
Copy link

export const schemaTypes = [works, testimonials, brands]

Just wondering if you have some steps to get this working in V3?
also where are you adding the above? in index.js? do we just delete the old schema.js? is it now unused?

@yomi3tech
Copy link

export const schemaTypes = [works, testimonials, brands]

Just wondering if you have some steps to get this working in V3? also where are you adding the above? in index.js? do we just delete the old schema.js? is it now unused?

Specifically in the index.js files and export as stated, everything should work perfectly even with version 3 but the React Tooltip is deprecated in this version to "Tooltip ", and at the backend, Sanity start is now npm run dev

@BurningVertex
Copy link

export const schemaTypes = [works, testimonials, brands]

Just wondering if you have some steps to get this working in V3? also where are you adding the above? in index.js? do we just delete the old schema.js? is it now unused?

Specifically in the index.js files and export as stated, everything should work perfectly even with version 3 but the React Tooltip is deprecated in this version to "Tooltip ", and at the backend, Sanity start is now npm run dev

Thanks, i decided to recreate the project from scratch fresh sanity install. Though I'm having the issue with the tooltip. Any chance you can post a code snippet from skills.jsx?

@Code-Parth
Copy link

The steps in the video do not work with the latest version of Sanity, version 3.

i.e. It's no longer possible to follow the exact steps of the video's Sanity setup and result in getting the Sanity Server up and running with the schema displaying.

There's a new prompt to setup the project for TypeScript (yes/no ?). Need clarity on that.

The project uses a schema.js file inside /schemas/, but installing the latest Sanity generates index.js file, with different code to schema.js (excluding what gets added to pull in the project's other schemas files).

It would be great if this could be addressed or if I could get some help on a workaround as I would love to build this tutorial without roadblocks.

@adrianhajdin and team, I love your work! Thank you for investing into the community.

You can do this schema at ./schemas/index.js for V3

export const schemaTypes = [
    {
        name: 'works',
        title: 'Works',
        type: 'document',
        fields: [
            {
                name: 'title',
                title: 'Title',
                type: 'string',
            },

            {
                name: 'description',
                title: 'Description',
                type: 'string',
            },
            {
                name: 'projectLink',
                title: 'Project Link',
                type: 'string',
            },
            {
                name: 'codeLink',
                title: 'Code Link',
                type: 'string',
            },
            {
                name: 'imgUrl',
                title: 'ImageUrl',
                type: 'image',
                options: {
                    hotspot: true,
                },
            },
            {
                name: 'tags',
                title: 'Tags',
                type: 'array',
                of: [
                    {
                        name: 'tag',
                        title: 'Tag',
                        type: 'string'
                    }
                ]
            },

        ],
    },
    {
        name: 'testimonials',
        title: 'Testimonials',
        type: 'document',
        fields: [
            {
                name: 'name',
                title: 'Name',
                type: 'string'
            },
            {
                name: 'company',
                title: 'Company',
                type: 'string'
            },
            {
                name: 'imgurl',
                title: 'ImgUrl',
                type: 'image',
                options: {
                    hotspot: true,
                },
            },
            {
                name: 'feedback',
                title: 'Feedback',
                type: 'string'
            }
        ]
    },
    {
        name: 'brands',
        title: 'Brands',
        type: 'document',
        fields: [
            {
                name: 'imgUrl',
                title: 'ImgUrl',
                type: 'image',
                options: {
                    hotspot: true,
                },
            },
            {
                name: 'name',
                title: 'Name',
                type: 'string'
            }
        ]
    },
    {
        name: 'abouts',
        title: 'Abouts',
        type: 'document',
        fields: [
            {
                name: 'title',
                title: 'Title',
                type: 'string'
            },
            {
                name: 'description',
                title: 'Description',
                type: 'string'
            },
            {
                name: 'imgUrl',
                title: 'ImgUrl',
                type: 'image',
                options: {
                    hotspot: true,
                },
            },

        ]
    },
    {
        name: 'skills',
        title: 'Skills',
        type: 'document',
        fields: [
            {
                name: 'name',
                title: 'Name',
                type: 'string'
            },
            {
                name: 'bgColor',
                title: 'BgColor',
                type: 'string'
            },
            {
                name: 'icon',
                title: 'Icon',
                type: 'image',
                options: {
                    hotspot: true,
                },
            },

        ]
    },
    {
        name: 'workExperience',
        title: 'Work Experience',
        type: 'document',
        fields: [
            {
                name: 'name',
                title: 'name',
                type: 'string'
            },
            {
                name: 'company',
                title: 'Company',
                type: 'string'
            },
            {
                name: 'desc',
                title: 'Desc',
                type: 'string'
            }
        ]
    },
    {
        name: 'experiences',
        title: 'Experiences',
        type: 'document',
        fields: [
            {
                name: 'year',
                title: 'Year',
                type: 'string'
            },
            {
                name: 'works',
                title: 'Works',
                type: 'array',
                of: [{ type: 'workExperience' }]
            },
        ]
    },
    {
        name: 'contact',
        title: 'Contact',
        type: 'document',
        fields: [
            {
                name: 'name',
                title: 'Name',
                type: 'string'
            },
            {
                name: 'email',
                title: 'Email',
                type: 'string'
            },
            {
                name: 'message',
                title: 'Message',
                type: 'text'
            }
        ]
    }
]

@AnmolChauhan123
Copy link

The prompt to use typescript is not showing anymore and it automatically installs all the files of typescript. Anyone know how to change this???]

@enith2478
Copy link

For the people having trouble with the different versions of Sanity What you have to do is to import your file name into the script.js file inside the schemas folder:

import tesstimonials from "./testimonials"
export const schemaTypes = [testimonials]

You create the "testimonials" file as instructed in the video and skip creating a chema.js file

@FredDaFed
Copy link

FredDaFed commented Aug 30, 2023

Sanity V3 -vs- V2


For what its worth, here is my input that fixed the issue when using Sanity V3 -vs- Sanity V2
CONSIDER the MIGRATION documentation for Sanity below:
SanityMigrationV2ToV3
Migration Cheat Sheet

INSTALLATION

  1. Use:
npm install openai@latest

NOTE: use SUDO if not a root user and/or have issues installing from the command.
This WILL INSTALL the latest version as V2 of Sanity is deprecated. If you want to BOOSTfreemium from JavascriptMastery2022, you can follow the tutorial but say 'Y' to install version 3.
What was seen in the tutorial were these commands:

npm install -g @sanity/cli

Select: -Y to install version 3
Then

sanity init --coupon javascriptmastery2022
  1. Do not select TypeScript if you just want to use javascript and follow the tutorial
  2. Everything else is pretty musch self explanatory.
    To Initialize: AVOID
sanity start

USE INSTEAD
@/backend_sanity directory

npm run dev

schema.js -vs- index.js

index.js is used as an entry point in V3 instead of schema.js that was used in V2

  1. In the index.js, add the following:

index.js

import works from './works'
import testimonials from "./testimonials"
import brands from './brands'
import abouts from './abouts'
import experiences from './experiences'
import skills from './skills'
import workExperience from './workExperience'
import contact from './contact'

export const schemaTypes = [testimonials, works, brands, abouts, experiences, skills, workExperience, contact]

NOTE:8 This is after you copy the assets in the schemas directory. The above syntax is demonstrating how to invoke the content added in this directory. V2 is much different:
image

RESULTS

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants