mirror of
https://github.com/vercel/commerce.git
synced 2025-07-28 20:51:23 +00:00
...[[...slug]]
.github
.vscode
app
components
helpers
lib
sanity
queries.tsx
sanity.client.ts
sanity.image.ts
sanity.preview.ts
shopify
storm
constants.ts
constants.tsx
type-guards.ts
utils.ts
messages
public
.env.example
.eslintrc.js
.gitignore
.npmrc
.nvmrc
.prettierignore
README.md
components.json
i18n-config.ts
license.md
middleware.ts
next.config.js
package.json
playwright.config.ts
pnpm-lock.yaml
postcss.config.js
prettier.config.js
tailwind.config.js
tsconfig.json
20 lines
442 B
TypeScript
20 lines
442 B
TypeScript
"use client";
|
|
|
|
import { definePreview } from "next-sanity/preview";
|
|
import { dataset, projectId } from "./sanity.client";
|
|
|
|
function onPublicAccessOnly() {
|
|
throw new Error("Unable to load preview as you're not logged in");
|
|
}
|
|
|
|
if (!projectId || !dataset) {
|
|
throw new Error(
|
|
"Missing projectId or dataset. Check your sanity.json or .env"
|
|
);
|
|
}
|
|
|
|
export const usePreview = definePreview({
|
|
projectId,
|
|
dataset,
|
|
onPublicAccessOnly,
|
|
}); |