These rules can now be found in a repository:
https://github.com/sanity-io/ai-rules/blob/main/sanity-opinionated.mdc
Read more in the Sanity documentation:
These rules can now be found in a repository:
https://github.com/sanity-io/ai-rules/blob/main/sanity-opinionated.mdc
Read more in the Sanity documentation:
| // Types for the result object with discriminated union | |
| type Success<T> = { | |
| data: T; | |
| error: null; | |
| }; | |
| type Failure<E> = { | |
| data: null; | |
| error: E; | |
| }; |
| import type { ReactNode } from "react" | |
| import { useEffect, useState, useTransition } from "react" | |
| import { createSafeContext } from "@/lib/context" | |
| type TransitionRouterStage = "entering" | "leaving" | undefined | |
| type TransitionRouterStartFunction = ( | |
| callback: () => void | Promise<void> | |
| ) => void |
| import clsx from "clsx"; | |
| import { | |
| useEffect, | |
| useRef, | |
| useState, | |
| type HTMLAttributes, | |
| type ReactNode, | |
| type RefObject, | |
| } from "react"; |
| import React, { useEffect, useState } from "react"; | |
| import cn from "mxcn"; | |
| // or if using shadcn: | |
| // import { cn } from "@/lib/utils"; // https://github.com/shadcn-ui/ui/blob/main/apps/www/lib/utils.ts | |
| const AnimateIn = ({ | |
| children, | |
| delay = 0, | |
| duration = 500, | |
| className = "", |
Create a fresh new Next js project. https://nextjs.org/docs/getting-started#automatic-setup
pnpm create next-app --typescript
install prettier
| // Use with Sanity schema on your existing 'image' field, add a subfields option: | |
| // The subfield 'options.field' attribute defines which asset field we are managing | |
| // If no 'options.field' is provided, the 'title' attribute will be downcased and used (i.e. Title -> title) | |
| // | |
| // { | |
| // title: 'Image', | |
| // name: 'image', | |
| // type: 'image', | |
| // fields: [ | |
| // { |
| export function mergeRefs(refs) { | |
| return (value) => { | |
| refs.forEach((ref) => { | |
| if (typeof ref === "function") { | |
| ref(value); | |
| } else if (ref != null) { | |
| ref.current = value; | |
| } | |
| }); | |
| }; |
| const fs = require('fs'); | |
| const pseudo = ['hover', 'active', 'focus'] | |
| const prefix = ['text', 'bg']; | |
| const colors = ['primary', 'secondary' , 'success' , 'error' , 'warning']; | |
| const intensity = ['50' , '100' , '200' , '300' , '400' , '500' , '600' , '700' , '800' , '900']; | |
| const fileContent = []; | |
| const p = (str) => fileContent.push(str); |