Created
December 19, 2023 21:29
-
-
Save saiichihashimoto/1349697a7dbc64096a89ffc7c6cee771 to your computer and use it in GitHub Desktop.
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
{ | |
"$schema": "https://json.schemastore.org/package.json", | |
"scripts": { | |
"build": "sanity build --yes", | |
"dev": "sanity dev", | |
"start": "sanity start" | |
}, | |
"dependencies": { | |
"@sanity-typed/types": "6.2.0", | |
"@sanity/vision": "3.21.3", | |
"sanity": "3.22.1", | |
"react": "18.2.0", | |
"react-dom": "18.2.0", | |
"styled-components": "6.1.1" | |
}, | |
"devDependencies": { | |
"typescript": "5.2.2" | |
} | |
} |
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
// import { defineArrayMember, defineField, defineType } from "sanity"; | |
import { | |
defineArrayMember, | |
defineField, | |
defineType, | |
} from "@sanity-typed/types"; | |
/** No changes using defineType, defineField, and defineArrayMember */ | |
export const product = defineType({ | |
name: "product", | |
type: "document", | |
title: "Product", | |
fields: [ | |
defineField({ | |
name: "productName", | |
type: "string", | |
title: "Product name", | |
validation: (Rule) => Rule.required(), | |
}), | |
defineField({ | |
name: "tags", | |
type: "array", | |
title: "Tags for item", | |
of: [ | |
defineArrayMember({ | |
type: "object", | |
name: "tag", | |
fields: [ | |
defineField({ type: "string", name: "label" }), | |
defineField({ type: "string", name: "value" }), | |
], | |
}), | |
], | |
}), | |
], | |
}); |
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
import { visionTool } from "@sanity/vision"; | |
import { deskTool } from "sanity/desk"; | |
// import { defineConfig } from "sanity"; | |
import { defineConfig } from "@sanity-typed/types"; | |
import type { InferSchemaValues } from "@sanity-typed/types"; | |
import { product } from "./schemas/product"; | |
/** No changes using defineConfig */ | |
const config = defineConfig({ | |
projectId: "59t1ed5o", | |
dataset: "production", | |
plugins: [deskTool(), visionTool()], | |
schema: { | |
types: [ | |
product, | |
// ... | |
], | |
}, | |
}); | |
export default config; | |
/** Typescript type of all types! */ | |
export type SanityValues = InferSchemaValues<typeof config>; | |
/** | |
* SanityValues === { | |
* product: { | |
* _createdAt: string; | |
* _id: string; | |
* _rev: string; | |
* _type: "product"; | |
* _updatedAt: string; | |
* productName: string; | |
* tags?: { | |
* _key: string; | |
* _type: "tag"; | |
* label?: string; | |
* value?: string; | |
* }[]; | |
* }; | |
* // ... all your 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
Show hidden characters
{ | |
"$schema": "https://json.schemastore.org/tsconfig", | |
"compilerOptions": { | |
"target": "es6", | |
"lib": ["dom", "dom.iterable", "esnext"], | |
"jsx": "react-jsx", | |
"module": "esnext", | |
"moduleResolution": "node", | |
"baseUrl": "./src", | |
"paths": { | |
"@portabletext-typed/*": ["../../*/src"], | |
"@portabletext-typed/types": ["../../pt-types/src"], | |
"@sanity-typed/*": ["../../*/src"] | |
}, | |
"resolveJsonModule": true, | |
"allowJs": true, | |
"checkJs": true, | |
"outDir": "./dist", | |
"isolatedModules": true, | |
"esModuleInterop": true, | |
"forceConsistentCasingInFileNames": true, | |
"strict": true, | |
"noImplicitReturns": true, | |
"noFallthroughCasesInSwitch": true, | |
"noUncheckedIndexedAccess": true, | |
"allowUnreachableCode": false, | |
"noErrorTruncation": true | |
}, | |
"include": [ | |
"**/*.js", | |
"**/*.jsx", | |
"**/*.ts", | |
"**/*.tsx", | |
"../../@types/**/*.d.ts" | |
], | |
"exclude": ["dist", "node_modules"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment