Unverified Commit cb60718b authored by Cody Olsen's avatar Cody Olsen Committed by GitHub

Add TypeGen to Sanity example (#64198)

Adds support for the [newly introduced Sanity
TypeGen](https://www.sanity.io/blog/introducing-sanity-typegen)! 🥳
parent c9c074c1
......@@ -4,6 +4,7 @@ node_modules
**/.vscode/**
**/dist/**
e2e-tests/**
examples/cms-sanity/sanity.types.ts
examples/with-eslint/**
examples/with-typescript-eslint-jest/**
examples/with-kea/**
......
# Ignoring generated files
./sanity.types.ts
# Ignoring generated files
./sanity.types.ts
./schema.json
......@@ -9,6 +9,7 @@ The Studio connects to Sanity Content Lake, which gives you hosted content APIs
## Features
- A performant, static blog with editable posts, authors, and site settings
- TypeScript setup with [Sanity TypeGen](https://www.sanity.io/docs/sanity-typegen)
- A native and customizable authoring environment, accessible on `yourblog.com/studio`
- Real-time and collaborative content editing with fine-grained revision history
- Side-by-side instant content preview that works across your whole site
......@@ -44,6 +45,12 @@ yarn create next-app --example cms-sanity next-sanity-blog
pnpm create next-app --example cms-sanity next-sanity-blog
```
Whenever you edit a GROQ query you update the TypeScript types by running:
```bash
npm run typegen
```
# Configuration
- [Step 1. Set up the environment](#step-1-set-up-the-environment)
......
import { Image } from "next-sanity/image";
import { Author } from "@/sanity/lib/queries";
import type { Author } from "@/sanity.types";
import { urlForImage } from "@/sanity/lib/utils";
export default function Avatar({ name, picture }: Author) {
interface Props {
name: string;
picture: Exclude<Author["picture"], undefined> | null;
}
export default function Avatar({ name, picture }: Props) {
return (
<div className="flex items-center text-xl">
{picture?.asset?._ref ? (
......
import "../globals.css";
import { SpeedInsights } from "@vercel/speed-insights/next";
import { Metadata } from "next";
import { PortableTextBlock, VisualEditing, toPlainText } from "next-sanity";
import type { Metadata } from "next";
import {
VisualEditing,
toPlainText,
type PortableTextBlock,
} from "next-sanity";
import { Inter } from "next/font/google";
import { draftMode } from "next/headers";
import { Suspense } from "react";
......@@ -10,13 +14,14 @@ import { Suspense } from "react";
import AlertBanner from "./alert-banner";
import PortableText from "./portable-text";
import type { SettingsQueryResult } from "@/sanity.types";
import * as demo from "@/sanity/lib/demo";
import { sanityFetch } from "@/sanity/lib/fetch";
import { SettingsQueryResponse, settingsQuery } from "@/sanity/lib/queries";
import { settingsQuery } from "@/sanity/lib/queries";
import { resolveOpenGraphImage } from "@/sanity/lib/utils";
export async function generateMetadata(): Promise<Metadata> {
const settings = await sanityFetch<SettingsQueryResponse>({
const settings = await sanityFetch<SettingsQueryResult>({
query: settingsQuery,
// Metadata should never contain stega
stega: false,
......@@ -53,10 +58,10 @@ const inter = Inter({
});
async function Footer() {
const data = await sanityFetch<SettingsQueryResponse>({
const data = await sanityFetch<SettingsQueryResult>({
query: settingsQuery,
});
const footer = data?.footer || ([] as PortableTextBlock[]);
const footer = data?.footer || [];
return (
<footer className="bg-accent-1 border-accent-2 border-t">
......@@ -64,7 +69,7 @@ async function Footer() {
{footer.length > 0 ? (
<PortableText
className="prose-sm text-pretty bottom-0 w-full max-w-none bg-white py-12 text-center md:py-20"
value={footer}
value={footer as PortableTextBlock[]}
/>
) : (
<div className="flex flex-col items-center py-28 lg:flex-row">
......
......@@ -4,17 +4,15 @@ import Avatar from "./avatar";
import CoverImage from "./cover-image";
import DateComponent from "./date";
import type { MoreStoriesQueryResult } from "@/sanity.types";
import { sanityFetch } from "@/sanity/lib/fetch";
import {
MoreStoriesQueryResponse,
moreStoriesQuery,
} from "@/sanity/lib/queries";
import { moreStoriesQuery } from "@/sanity/lib/queries";
export default async function MoreStories(params: {
skip: string;
limit: number;
}) {
const data = await sanityFetch<MoreStoriesQueryResponse>({
const data = await sanityFetch<MoreStoriesQueryResult>({
query: moreStoriesQuery,
params,
});
......
......@@ -8,15 +8,10 @@ import MoreStories from "./more-stories";
import Onboarding from "./onboarding";
import PortableText from "./portable-text";
import type { HeroQueryResult, SettingsQueryResult } from "@/sanity.types";
import * as demo from "@/sanity/lib/demo";
import { sanityFetch } from "@/sanity/lib/fetch";
import {
HeroQueryResponse,
Post,
SettingsQueryResponse,
heroQuery,
settingsQuery,
} from "@/sanity/lib/queries";
import { heroQuery, settingsQuery } from "@/sanity/lib/queries";
function Intro(props: { title: string | null | undefined; description: any }) {
const title = props.title || demo.title;
......@@ -46,7 +41,7 @@ function HeroPost({
date,
author,
}: Pick<
Post,
Exclude<HeroQueryResult, null>,
"title" | "coverImage" | "date" | "excerpt" | "author" | "slug"
>) {
return (
......@@ -80,10 +75,10 @@ function HeroPost({
export default async function Page() {
const [settings, heroPost] = await Promise.all([
sanityFetch<SettingsQueryResponse>({
sanityFetch<SettingsQueryResult>({
query: settingsQuery,
}),
sanityFetch<HeroQueryResponse>({ query: heroQuery }),
sanityFetch<HeroQueryResult>({ query: heroQuery }),
]);
return (
......
import type { Metadata, ResolvingMetadata } from "next";
import { groq } from "next-sanity";
import { groq, type PortableTextBlock } from "next-sanity";
import Link from "next/link";
import { notFound } from "next/navigation";
import { Suspense } from "react";
......@@ -10,33 +10,36 @@ import DateComponent from "../../date";
import MoreStories from "../../more-stories";
import PortableText from "../../portable-text";
import type {
PostQueryResult,
PostSlugsResult,
SettingsQueryResult,
} from "@/sanity.types";
import * as demo from "@/sanity/lib/demo";
import { sanityFetch } from "@/sanity/lib/fetch";
import {
PostQueryResponse,
SettingsQueryResponse,
postQuery,
settingsQuery,
} from "@/sanity/lib/queries";
import { postQuery, settingsQuery } from "@/sanity/lib/queries";
import { resolveOpenGraphImage } from "@/sanity/lib/utils";
import * as demo from "@/sanity/lib/demo";
type Props = {
params: { slug: string };
};
const postSlugs = groq`*[_type == "post"]{slug}`;
export async function generateStaticParams() {
return sanityFetch<{ slug: string }[]>({
query: groq`*[_type == "post" && defined(slug.current)]{"slug": slug.current}`,
const params = await sanityFetch<PostSlugsResult>({
query: postSlugs,
perspective: "published",
stega: false,
});
return params.map(({ slug }) => ({ slug: slug?.current }));
}
export async function generateMetadata(
{ params }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const post = await sanityFetch<PostQueryResponse>({
const post = await sanityFetch<PostQueryResult>({
query: postQuery,
params,
stega: false,
......@@ -56,11 +59,11 @@ export async function generateMetadata(
export default async function PostPage({ params }: Props) {
const [post, settings] = await Promise.all([
sanityFetch<PostQueryResponse>({
sanityFetch<PostQueryResult>({
query: postQuery,
params,
}),
sanityFetch<SettingsQueryResponse>({
sanityFetch<SettingsQueryResult>({
query: settingsQuery,
}),
]);
......@@ -101,7 +104,10 @@ export default async function PostPage({ params }: Props) {
</div>
</div>
{post.content?.length && (
<PortableText className="mx-auto max-w-2xl" value={post.content} />
<PortableText
className="mx-auto max-w-2xl"
value={post.content as PortableTextBlock[]}
/>
)}
</article>
<aside>
......
{
"private": true,
"scripts": {
"predev": "npm run typegen",
"dev": "next",
"prebuild": "npm run typegen",
"build": "next build",
"start": "next start",
"lint": "next lint",
"presetup": "echo 'about to setup env variables, follow the guide here: https://github.com/vercel/next.js/tree/canary/examples/cms-sanity#using-the-sanity-cli'",
"setup": "npx sanity@latest init --env .env.local",
"postsetup": "echo 'create the read token by following the rest of the guide: https://github.com/vercel/next.js/tree/canary/examples/cms-sanity#creating-a-read-token'"
"postsetup": "echo 'create the read token by following the rest of the guide: https://github.com/vercel/next.js/tree/canary/examples/cms-sanity#creating-a-read-token'",
"typegen": "sanity schema extract && sanity typegen generate"
},
"dependencies": {
"@sanity/assist": "^2.0.4",
"@sanity/icons": "^2.11.2",
"@sanity/image-url": "^1.0.2",
"@sanity/preview-url-secret": "^1.6.5",
"@sanity/vision": "^3.35.0",
"@tailwindcss/typography": "^0.5.10",
"@types/node": "^20.11.30",
"@types/react": "^18.2.67",
"@types/react-dom": "^18.2.22",
"@sanity/assist": "3.0.3",
"@sanity/icons": "2.11.8",
"@sanity/image-url": "1.0.2",
"@sanity/preview-url-secret": "1.6.7",
"@sanity/vision": "3.37.2",
"@tailwindcss/typography": "^0.5.12",
"@types/node": "^20.12.7",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"@vercel/speed-insights": "^1.0.10",
"autoprefixer": "^10.4.18",
"autoprefixer": "^10.4.19",
"date-fns": "^3.6.0",
"next": "latest",
"next-sanity": "^8.4.4",
"postcss": "^8.4.37",
"next-sanity": "9.0.0",
"postcss": "^8.4.38",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.8.1",
"sanity": "^3.35.0",
"sanity-plugin-asset-source-unsplash": "^2.0.1",
"sanity": "3.37.2",
"sanity-plugin-asset-source-unsplash": "3.0.0",
"server-only": "^0.0.1",
"styled-components": "^6.1.8",
"tailwindcss": "^3.4.1",
"typescript": "5.4.2"
"styled-components": "6.1.8",
"tailwindcss": "^3.4.3",
"typescript": "5.4.5"
},
"devDependencies": {
"@next/env": "latest",
......
{
"path": "'./{app,sanity}/**/*.{ts,tsx,js,jsx}'"
}
/**
* ---------------------------------------------------------------------------------
* This file has been generated by Sanity TypeGen.
* Command: `sanity typegen generate`
*
* Any modifications made directly to this file will be overwritten the next time
* the TypeScript definitions are generated. Please make changes to the Sanity
* schema definitions and/or GROQ queries if you need to update these types.
*
* For more information on how to use Sanity TypeGen, visit the official documentation:
* https://www.sanity.io/docs/sanity-typegen
* ---------------------------------------------------------------------------------
*/
// Source: schema.json
export type SanityImagePaletteSwatch = {
_type: "sanity.imagePaletteSwatch";
background?: string;
foreground?: string;
population?: number;
title?: string;
};
export type SanityImagePalette = {
_type: "sanity.imagePalette";
darkMuted?: SanityImagePaletteSwatch;
lightVibrant?: SanityImagePaletteSwatch;
darkVibrant?: SanityImagePaletteSwatch;
vibrant?: SanityImagePaletteSwatch;
dominant?: SanityImagePaletteSwatch;
lightMuted?: SanityImagePaletteSwatch;
muted?: SanityImagePaletteSwatch;
};
export type SanityImageDimensions = {
_type: "sanity.imageDimensions";
height?: number;
width?: number;
aspectRatio?: number;
};
export type SanityFileAsset = {
_id: string;
_type: "sanity.fileAsset";
_createdAt: string;
_updatedAt: string;
_rev: string;
originalFilename?: string;
label?: string;
title?: string;
description?: string;
altText?: string;
sha1hash?: string;
extension?: string;
mimeType?: string;
size?: number;
assetId?: string;
uploadId?: string;
path?: string;
url?: string;
source?: SanityAssetSourceData;
};
export type Geopoint = {
_type: "geopoint";
lat?: number;
lng?: number;
alt?: number;
};
export type Post = {
_id: string;
_type: "post";
_createdAt: string;
_updatedAt: string;
_rev: string;
title?: string;
slug?: Slug;
content?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "normal" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote";
listItem?: "bullet" | "number";
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}>;
excerpt?: string;
coverImage?: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
};
date?: string;
author?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "author";
};
};
export type Author = {
_id: string;
_type: "author";
_createdAt: string;
_updatedAt: string;
_rev: string;
name?: string;
picture?: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
};
};
export type Slug = {
_type: "slug";
current?: string;
source?: string;
};
export type Settings = {
_id: string;
_type: "settings";
_createdAt: string;
_updatedAt: string;
_rev: string;
title?: string;
description?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "normal";
listItem?: never;
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}>;
footer?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "normal" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote";
listItem?: "bullet" | "number";
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}>;
ogImage?: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
metadataBase?: string;
_type: "image";
};
};
export type SanityImageCrop = {
_type: "sanity.imageCrop";
top?: number;
bottom?: number;
left?: number;
right?: number;
};
export type SanityImageHotspot = {
_type: "sanity.imageHotspot";
x?: number;
y?: number;
height?: number;
width?: number;
};
export type SanityImageAsset = {
_id: string;
_type: "sanity.imageAsset";
_createdAt: string;
_updatedAt: string;
_rev: string;
originalFilename?: string;
label?: string;
title?: string;
description?: string;
altText?: string;
sha1hash?: string;
extension?: string;
mimeType?: string;
size?: number;
assetId?: string;
uploadId?: string;
path?: string;
url?: string;
metadata?: SanityImageMetadata;
source?: SanityAssetSourceData;
};
export type SanityAssetSourceData = {
_type: "sanity.assetSourceData";
name?: string;
id?: string;
url?: string;
};
export type SanityImageMetadata = {
_type: "sanity.imageMetadata";
location?: Geopoint;
dimensions?: SanityImageDimensions;
palette?: SanityImagePalette;
lqip?: string;
blurHash?: string;
hasAlpha?: boolean;
isOpaque?: boolean;
};
export type SanityAssistInstructionTask = {
_type: "sanity.assist.instructionTask";
path?: string;
instructionKey?: string;
started?: string;
updated?: string;
info?: string;
};
export type SanityAssistTaskStatus = {
_type: "sanity.assist.task.status";
tasks?: Array<
{
_key: string;
} & SanityAssistInstructionTask
>;
};
export type SanityAssistSchemaTypeAnnotations = {
_type: "sanity.assist.schemaType.annotations";
title?: string;
fields?: Array<
{
_key: string;
} & SanityAssistSchemaTypeField
>;
};
export type SanityAssistOutputType = {
_type: "sanity.assist.output.type";
type?: string;
};
export type SanityAssistOutputField = {
_type: "sanity.assist.output.field";
path?: string;
};
export type SanityAssistInstructionContext = {
_type: "sanity.assist.instruction.context";
reference?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "assist.instruction.context";
};
};
export type AssistInstructionContext = {
_id: string;
_type: "assist.instruction.context";
_createdAt: string;
_updatedAt: string;
_rev: string;
title?: string;
context?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "normal";
listItem?: never;
markDefs?: null;
level?: number;
_type: "block";
_key: string;
}>;
};
export type SanityAssistInstructionUserInput = {
_type: "sanity.assist.instruction.userInput";
message?: string;
description?: string;
};
export type SanityAssistInstructionPrompt = Array<{
children?: Array<
| {
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}
| ({
_key: string;
} & SanityAssistInstructionFieldRef)
| ({
_key: string;
} & SanityAssistInstructionContext)
| ({
_key: string;
} & SanityAssistInstructionUserInput)
>;
style?: "normal";
listItem?: never;
markDefs?: null;
level?: number;
_type: "block";
_key: string;
}>;
export type SanityAssistInstructionFieldRef = {
_type: "sanity.assist.instruction.fieldRef";
path?: string;
};
export type SanityAssistInstruction = {
_type: "sanity.assist.instruction";
prompt?: SanityAssistInstructionPrompt;
icon?: string;
title?: string;
userId?: string;
createdById?: string;
output?: Array<
| ({
_key: string;
} & SanityAssistOutputField)
| ({
_key: string;
} & SanityAssistOutputType)
>;
};
export type SanityAssistSchemaTypeField = {
_type: "sanity.assist.schemaType.field";
path?: string;
instructions?: Array<
{
_key: string;
} & SanityAssistInstruction
>;
};
export declare const internalGroqTypeReferenceTo: unique symbol;
// Source: sanity/lib/queries.ts
// Variable: settingsQuery
// Query: *[_type == "settings"][0]
export type SettingsQueryResult = {
_id: string;
_type: "settings";
_createdAt: string;
_updatedAt: string;
_rev: string;
title?: string;
description?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "normal";
listItem?: never;
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}>;
footer?: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "normal";
listItem?: "bullet" | "number";
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}>;
ogImage?: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
metadataBase?: string;
_type: "image";
};
} | null;
// Variable: heroQuery
// Query: *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},}
export type HeroQueryResult = {
content: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "normal";
listItem?: "bullet" | "number";
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}> | null;
_id: string;
status: "draft" | "published";
title: string | "Untitled";
slug: string | null;
excerpt: string | null;
coverImage: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
date: string;
author: {
name: string | "Anonymous";
picture: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
} | null;
} | null;
// Variable: moreStoriesQuery
// Query: *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},}
export type MoreStoriesQueryResult = Array<{
_id: string;
status: "draft" | "published";
title: string | "Untitled";
slug: string | null;
excerpt: string | null;
coverImage: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
date: string;
author: {
name: string | "Anonymous";
picture: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
} | null;
}>;
// Variable: postQuery
// Query: *[_type == "post" && slug.current == $slug] [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},}
export type PostQueryResult = {
content: Array<{
children?: Array<{
marks?: Array<string>;
text?: string;
_type: "span";
_key: string;
}>;
style?: "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "normal";
listItem?: "bullet" | "number";
markDefs?: Array<{
href?: string;
_type: "link";
_key: string;
}>;
level?: number;
_type: "block";
_key: string;
}> | null;
_id: string;
status: "draft" | "published";
title: string | "Untitled";
slug: string | null;
excerpt: string | null;
coverImage: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
date: string;
author: {
name: string | "Anonymous";
picture: {
asset?: {
_ref: string;
_type: "reference";
_weak?: boolean;
[internalGroqTypeReferenceTo]?: "sanity.imageAsset";
};
hotspot?: SanityImageHotspot;
crop?: SanityImageCrop;
alt?: string;
_type: "image";
} | null;
} | null;
} | null;
// Source: app/(blog)/posts/[slug]/page.tsx
// Variable: postSlugs
// Query: *[_type == "post"]{slug}
export type PostSlugsResult = Array<{
slug: Slug | null;
}>;
import { groq, type PortableTextBlock } from "next-sanity";
import type { Image } from "sanity";
import { groq } from "next-sanity";
export const settingsQuery = groq`*[_type == "settings"][0]`;
export interface SettingsQueryResponse {
title?: string;
description?: PortableTextBlock[];
footer?: PortableTextBlock[];
ogImage?: (Image & { alt?: string; metadataBase?: string }) | null;
}
export interface Author {
name: string;
picture?: (Image & { alt?: string | null }) | null;
}
export interface Post {
_id: string;
status: "draft" | "published";
title: string;
slug: string;
excerpt?: string | null;
coverImage?: (Image & { alt?: string }) | null;
date: string;
author?: Author | null;
}
const postFields = groq`
const postFields = /* groq */ `
_id,
"status": select(_originalId in path("drafts.**") => "draft", "published"),
"title": coalesce(title, "Untitled"),
......@@ -39,23 +17,12 @@ export const heroQuery = groq`*[_type == "post" && defined(slug.current)] | orde
content,
${postFields}
}`;
export type HeroQueryResponse =
| (Post & {
content?: PortableTextBlock[] | null;
})
| null;
export const moreStoriesQuery = groq`*[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {
${postFields}
}`;
export type MoreStoriesQueryResponse = Post[] | null;
export const postQuery = groq`*[_type == "post" && slug.current == $slug] [0] {
content,
${postFields}
}`;
export type PostQueryResponse =
| (Post & {
content?: PortableTextBlock[] | null;
})
| null;
[
{
"name": "sanity.imagePaletteSwatch",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imagePaletteSwatch"
}
},
"background": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"foreground": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"population": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.imagePalette",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imagePalette"
}
},
"darkMuted": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"lightVibrant": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"darkVibrant": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"vibrant": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"dominant": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"lightMuted": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
},
"muted": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePaletteSwatch"
},
"optional": true
}
}
}
},
{
"name": "sanity.imageDimensions",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imageDimensions"
}
},
"height": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"width": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"aspectRatio": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
}
}
}
},
{
"name": "sanity.fileAsset",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.fileAsset"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"originalFilename": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"label": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"description": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"altText": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"sha1hash": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"extension": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"mimeType": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"size": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"assetId": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"uploadId": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"url": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"source": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.assetSourceData"
},
"optional": true
}
}
},
{
"name": "geopoint",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "geopoint"
}
},
"lat": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"lng": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"alt": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
}
}
}
},
{
"name": "post",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "post"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"slug": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "slug"
},
"optional": true
},
"content": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"children": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"marks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "string"
}
},
"optional": true
},
"text": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "span"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"style": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "normal"
},
{
"type": "string",
"value": "h1"
},
{
"type": "string",
"value": "h2"
},
{
"type": "string",
"value": "h3"
},
{
"type": "string",
"value": "h4"
},
{
"type": "string",
"value": "h5"
},
{
"type": "string",
"value": "h6"
},
{
"type": "string",
"value": "blockquote"
}
]
},
"optional": true
},
"listItem": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "bullet"
},
{
"type": "string",
"value": "number"
}
]
},
"optional": true
},
"markDefs": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"href": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "link"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"level": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "block"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"excerpt": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"coverImage": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"asset": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"_ref": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "reference"
}
},
"_weak": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
},
"dereferencesTo": "sanity.imageAsset"
},
"optional": true
},
"hotspot": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageHotspot"
},
"optional": true
},
"crop": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageCrop"
},
"optional": true
},
"alt": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "image"
}
}
}
},
"optional": true
},
"date": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"author": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"_ref": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "reference"
}
},
"_weak": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
},
"dereferencesTo": "author"
},
"optional": true
}
}
},
{
"name": "author",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "author"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"name": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"picture": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"asset": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"_ref": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "reference"
}
},
"_weak": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
},
"dereferencesTo": "sanity.imageAsset"
},
"optional": true
},
"hotspot": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageHotspot"
},
"optional": true
},
"crop": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageCrop"
},
"optional": true
},
"alt": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "image"
}
}
}
},
"optional": true
}
}
},
{
"name": "slug",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "slug"
}
},
"current": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"source": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "settings",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "settings"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"description": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"children": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"marks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "string"
}
},
"optional": true
},
"text": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "span"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"style": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "normal"
}
]
},
"optional": true
},
"listItem": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": []
},
"optional": true
},
"markDefs": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"href": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "link"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"level": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "block"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"footer": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"children": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"marks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "string"
}
},
"optional": true
},
"text": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "span"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"style": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "normal"
},
{
"type": "string",
"value": "h1"
},
{
"type": "string",
"value": "h2"
},
{
"type": "string",
"value": "h3"
},
{
"type": "string",
"value": "h4"
},
{
"type": "string",
"value": "h5"
},
{
"type": "string",
"value": "h6"
},
{
"type": "string",
"value": "blockquote"
}
]
},
"optional": true
},
"listItem": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "bullet"
},
{
"type": "string",
"value": "number"
}
]
},
"optional": true
},
"markDefs": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"href": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "link"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"level": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "block"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"ogImage": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"asset": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"_ref": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "reference"
}
},
"_weak": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
},
"dereferencesTo": "sanity.imageAsset"
},
"optional": true
},
"hotspot": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageHotspot"
},
"optional": true
},
"crop": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageCrop"
},
"optional": true
},
"alt": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"metadataBase": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "image"
}
}
}
},
"optional": true
}
}
},
{
"name": "sanity.imageCrop",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imageCrop"
}
},
"top": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"bottom": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"left": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"right": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
}
}
}
},
{
"name": "sanity.imageHotspot",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imageHotspot"
}
},
"x": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"y": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"height": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"width": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
}
}
}
},
{
"name": "sanity.imageAsset",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imageAsset"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"originalFilename": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"label": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"description": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"altText": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"sha1hash": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"extension": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"mimeType": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"size": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"assetId": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"uploadId": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"url": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"metadata": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageMetadata"
},
"optional": true
},
"source": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.assetSourceData"
},
"optional": true
}
}
},
{
"name": "sanity.assetSourceData",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assetSourceData"
}
},
"name": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"id": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"url": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.imageMetadata",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.imageMetadata"
}
},
"location": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "geopoint"
},
"optional": true
},
"dimensions": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imageDimensions"
},
"optional": true
},
"palette": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.imagePalette"
},
"optional": true
},
"lqip": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"blurHash": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"hasAlpha": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
},
"isOpaque": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.instructionTask",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.instructionTask"
}
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"instructionKey": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"started": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"updated": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"info": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.task.status",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.task.status"
}
},
"tasks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.instructionTask"
}
}
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.schemaType.annotations",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.schemaType.annotations"
}
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"fields": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.schemaType.field"
}
}
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.output.type",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.output.type"
}
},
"type": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.output.field",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.output.field"
}
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.instruction.context",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.instruction.context"
}
},
"reference": {
"type": "objectAttribute",
"value": {
"type": "object",
"attributes": {
"_ref": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "reference"
}
},
"_weak": {
"type": "objectAttribute",
"value": {
"type": "boolean"
},
"optional": true
}
},
"dereferencesTo": "assist.instruction.context"
},
"optional": true
}
}
}
},
{
"name": "assist.instruction.context",
"type": "document",
"attributes": {
"_id": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "assist.instruction.context"
}
},
"_createdAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_updatedAt": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"_rev": {
"type": "objectAttribute",
"value": {
"type": "string"
}
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"context": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"children": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"marks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "string"
}
},
"optional": true
},
"text": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "span"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
},
"style": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "normal"
}
]
},
"optional": true
},
"listItem": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": []
},
"optional": true
},
"markDefs": {
"type": "objectAttribute",
"value": {
"type": "null"
},
"optional": true
},
"level": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "block"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
},
"optional": true
}
}
},
{
"name": "sanity.assist.instruction.userInput",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.instruction.userInput"
}
},
"message": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"description": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.instruction.prompt",
"type": "type",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"children": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "union",
"of": [
{
"type": "object",
"attributes": {
"marks": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "string"
}
},
"optional": true
},
"text": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "span"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.instruction.fieldRef"
}
},
{
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.instruction.context"
}
},
{
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.instruction.userInput"
}
}
]
}
},
"optional": true
},
"style": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": [
{
"type": "string",
"value": "normal"
}
]
},
"optional": true
},
"listItem": {
"type": "objectAttribute",
"value": {
"type": "union",
"of": []
},
"optional": true
},
"markDefs": {
"type": "objectAttribute",
"value": {
"type": "null"
},
"optional": true
},
"level": {
"type": "objectAttribute",
"value": {
"type": "number"
},
"optional": true
},
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "block"
}
}
},
"rest": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
}
}
}
}
},
{
"name": "sanity.assist.instruction.fieldRef",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.instruction.fieldRef"
}
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.instruction",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.instruction"
}
},
"prompt": {
"type": "objectAttribute",
"value": {
"type": "inline",
"name": "sanity.assist.instruction.prompt"
},
"optional": true
},
"icon": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"title": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"userId": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"createdById": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"output": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "union",
"of": [
{
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.output.field"
}
},
{
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.output.type"
}
}
]
}
},
"optional": true
}
}
}
},
{
"name": "sanity.assist.schemaType.field",
"type": "type",
"value": {
"type": "object",
"attributes": {
"_type": {
"type": "objectAttribute",
"value": {
"type": "string",
"value": "sanity.assist.schemaType.field"
}
},
"path": {
"type": "objectAttribute",
"value": {
"type": "string"
},
"optional": true
},
"instructions": {
"type": "objectAttribute",
"value": {
"type": "array",
"of": {
"type": "object",
"attributes": {
"_key": {
"type": "objectAttribute",
"value": {
"type": "string"
}
}
},
"rest": {
"type": "inline",
"name": "sanity.assist.instruction"
}
}
},
"optional": true
}
}
}
}
]
{
"compilerOptions": {
"target": "es5",
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
// Use module: preserve, and remove moduleResolution, esModuleInterop and resolveJsonModule once Next ships support
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment