Skip to content

Commit

Permalink
chore(deps): update dependency @sanity/prettier-config to v1.0.3 (mai…
Browse files Browse the repository at this point in the history
…n) (#1725)
  • Loading branch information
renovate[bot] authored Oct 14, 2024
1 parent 237b377 commit bd4c4f2
Show file tree
Hide file tree
Showing 36 changed files with 890 additions and 1,360 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ permissions:
jobs:
release-canary:
permissions:
contents: read # for checkout
id-token: write # to enable use of OIDC for npm provenance
contents: read # for checkout
id-token: write # to enable use of OIDC for npm provenance
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
Expand Down
12 changes: 12 additions & 0 deletions apps/mvp/app/(sanity)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '../globals.css'

export {metadata, viewport} from 'next-sanity/studio'

export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en">
<head />
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use client'

import {NextStudio} from 'next-sanity/studio'

import config from '@/sanity.config'

export default function Studio() {
export default function StudioPage() {
return <NextStudio config={config} history="hash" />
}
16 changes: 16 additions & 0 deletions apps/mvp/app/(website)/ConditionalPreviewProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {draftMode} from 'next/headers'

import PreviewProvider from './PreviewProvider'
import {token} from './sanity.fetch'

export default async function ConditionalPreviewProvider({
children,
}: {
children: React.ReactNode
}): Promise<React.JSX.Element> {
return (await draftMode()).isEnabled ? (
<PreviewProvider token={token}>{children}</PreviewProvider>
) : (
(children as JSX.Element)
)
}
File renamed without changes.
16 changes: 16 additions & 0 deletions apps/mvp/app/(website)/Posts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {draftMode} from 'next/headers'
import {LiveQuery} from 'next-sanity/preview/live-query'

import PostsLayout, {PostsLayoutProps, query} from './PostsLayout'
import PreviewPosts from './PreviewPosts'
import {sanityFetch} from './sanity.fetch'

export default async function Posts() {
const posts = await sanityFetch<PostsLayoutProps['data']>({query, tags: ['post', 'author']})

if ((await draftMode()).isEnabled) {
return <PreviewPosts data={posts} />
}

return <PostsLayout data={posts} draftMode={false} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const PostsLayout = memo(function Posts(props: PostsLayoutProps) {
})
return (
<div
key={post.title}
key={post._id}
className="relative flex flex-col overflow-hidden rounded-lg shadow-lg"
data-sanity={dataAttribute('slug')}
>
Expand Down Expand Up @@ -109,7 +109,7 @@ const PostsLayout = memo(function Posts(props: PostsLayoutProps) {
{post.publishedAt ? (
<div className="flex space-x-1 text-sm text-gray-500">
<time dateTime={post.publishedAt?.toJSON()}>
{post.publishedAt?.toLocaleDateString()}
{post.publishedAt?.toDateString()}
</time>
<span aria-hidden="true">&middot;</span>
</div>
Expand Down
10 changes: 10 additions & 0 deletions apps/mvp/app/(website)/PreviewPosts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'

import {useLiveQuery} from 'next-sanity/preview'

import PostsLayout, {PostsLayoutProps, query} from './PostsLayout'

export default function PreviewPosts(props: {data: PostsLayoutProps['data']}) {
const [posts] = useLiveQuery<PostsLayoutProps['data']>(props.data, query)
return <PostsLayout data={posts} draftMode />
}
File renamed without changes.
6 changes: 3 additions & 3 deletions apps/mvp/app/layout.tsx → apps/mvp/app/(website)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import './globals.css'
import '../globals.css'

import {draftMode} from 'next/headers'
import {VisualEditing} from 'next-sanity'

export default function RootLayout({children}: {children: React.ReactNode}) {
export default async function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en">
<head />
<body>
{children}
{draftMode().isEnabled && <VisualEditing />}
{(await draftMode()).isEnabled && <VisualEditing />}
</body>
</html>
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {client} from './sanity.client'
// eslint-disable-next-line no-process-env
export const token = process.env.SANITY_API_READ_TOKEN!

export function sanityFetch<QueryResponse>({
export async function sanityFetch<QueryResponse>({
query,
params = {},
tags,
Expand All @@ -17,7 +17,7 @@ export function sanityFetch<QueryResponse>({
params?: QueryParams
tags?: string[]
}) {
const isDraftMode = draftMode().isEnabled
const isDraftMode = (await draftMode()).isEnabled
if (isDraftMode && !token) {
throw new Error('The `SANITY_API_READ_TOKEN` environment variable is required.')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import Link from 'next/link'
import {unstable__adapter, unstable__environment} from 'next-sanity'
import {Suspense} from 'react'

import PostsLayout, {PostsLayoutProps, query} from '@/app/PostsLayout'

import PostsLayout, {PostsLayoutProps, query} from '../PostsLayout'
import {sanityFetch} from '../sanity.fetch'

export default async function IndexPage() {
const posts = await sanityFetch<PostsLayoutProps['data']>({query, tags: ['post', 'author']})

return (
<>
<div
Expand All @@ -25,9 +26,7 @@ export default async function IndexPage() {
Visual Editing Only
</h2>
</div>
<Suspense>
<Posts />
</Suspense>
<PostsLayout data={posts} draftMode={(await draftMode()).isEnabled} />
</div>
</div>
<div className="flex text-center">
Expand All @@ -47,9 +46,3 @@ export default async function IndexPage() {
</>
)
}

async function Posts() {
const posts = await sanityFetch<PostsLayoutProps['data']>({query, tags: ['post', 'author']})

return <PostsLayout data={posts} draftMode={draftMode().isEnabled} />
}
12 changes: 0 additions & 12 deletions apps/mvp/app/ConditionalPreviewProvider.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions apps/mvp/app/Posts.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions apps/mvp/app/api/disable-draft/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {draftMode} from 'next/headers'
import {redirect} from 'next/navigation'

export function GET(): void {
draftMode().disable()
export async function GET(): Promise<void> {
;(await draftMode()).disable()
redirect('/')
}
4 changes: 2 additions & 2 deletions apps/mvp/app/api/draft/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {validatePreviewUrl} from '@sanity/preview-url-secret'
import {draftMode} from 'next/headers'
import {redirect} from 'next/navigation'

import {client} from '@/app/sanity.client'
import {client} from '@/app/(website)/sanity.client'

const clientWithToken = client.withConfig({
token: process.env.SANITY_API_READ_TOKEN,
Expand All @@ -14,7 +14,7 @@ export async function GET(req: Request) {
return new Response('Invalid secret', {status: 401})
}

draftMode().enable()
;(await draftMode()).enable()

redirect(redirectTo)
}
10 changes: 0 additions & 10 deletions apps/mvp/app/previews.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions apps/mvp/app/studio/[[...tool]]/Studio.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions apps/mvp/app/studio/[[...tool]]/page.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions apps/mvp/app/studio/hash/Studio.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions apps/mvp/app/studio/hash/page.tsx

This file was deleted.

35 changes: 3 additions & 32 deletions apps/mvp/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,9 @@ const nextConfig = {
},
},
productionBrowserSourceMaps: true,

webpack(config) {
// config.resolve.alias = {
// ...config.resolve.alias,
// '@sanity/vision': requireResolve('@sanity/vision'),
// 'sanity/_singletons': requireResolve('sanity/_singletons'),
// 'sanity/desk': requireResolve('sanity/desk'),
// 'sanity/presentation': requireResolve('sanity/presentation'),
// 'sanity/router': requireResolve('sanity/router'),
// 'sanity/structure': requireResolve('sanity/structure'),
// sanity: requireResolve('sanity'),
// }

class NextEntryPlugin {
apply(compiler) {
compiler.hooks.afterEnvironment.tap('NextEntryPlugin', () => {
if (compiler.options.resolve.conditionNames.includes('browser')) {
compiler.options.resolve.conditionNames = [
...compiler.options.resolve.conditionNames.filter(
(condition) => condition !== 'browser',
),
'react-compiler',
'browser',
]
}
})
}
}

config.plugins.push(new NextEntryPlugin())

return config
env: {
// Matches the behavior of `sanity dev` which sets styled-components to use the fastest way of inserting CSS rules in both dev and production. It's default behavior is to disable it in dev mode.
SC_DISABLE_SPEEDY: 'false',
},

async headers() {
Expand Down
18 changes: 9 additions & 9 deletions apps/mvp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"build": "next build --profile",
"dev": "next --turbo",
"format": "next lint --fix .",
"lint": "next lint --max-warnings 0 .",
Expand All @@ -15,31 +15,31 @@
"@repo/sanity-config": "workspace:*",
"@sanity/image-url": "^1.0.2",
"@sanity/preview-url-secret": "^1.6.21",
"@sanity/vision": "3.57.4",
"babel-plugin-react-compiler": "0.0.0-experimental-24ec0eb-20240918",
"@sanity/vision": "3.60.0",
"babel-plugin-react-compiler": "0.0.0-experimental-fa06e2c-20241014",
"groqd": "^0.15.12",
"next": "15.0.0-rc.0",
"next-sanity": "workspace:*",
"react": "19.0.0-rc.0",
"react-dom": "19.0.0-rc.0",
"sanity": "3.57.4"
"sanity": "3.60.0"
},
"devDependencies": {
"@next/bundle-analyzer": "15.0.0-rc.0",
"@next/env": "15.0.0-rc.0",
"@repo/typescript-config": "workspace:*",
"@types/react": "^18.3.3",
"@types/react": "^18.3.11",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-next": "15.0.0-rc.0",
"eslint-config-prettier": "^9.1.0",
"eslint-gitignore": "^0.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"postcss": "^8.4.41",
"postcss": "^8.4.47",
"server-only": "^0.0.1",
"tailwindcss": "^3.4.7",
"typescript": "5.6.2"
"tailwindcss": "^3.4.13",
"typescript": "5.6.3"
},
"engines": {
"node": "20"
Expand Down
6 changes: 4 additions & 2 deletions apps/mvp/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable no-restricted-globals */
/* eslint-disable no-process-env */
'use client'

/* eslint-disable no-restricted-globals,no-process-env */

import sharedConfig from '@repo/sanity-config'
import {debugSecrets} from '@sanity/preview-url-secret/sanity-plugin-debug-secrets'
import {defineConfig} from 'sanity'
Expand Down
Loading

0 comments on commit bd4c4f2

Please sign in to comment.