-
-
-
- -
- Get started by editing{' '}
-
- src/app/page.tsx
-
- .
-
- - Save and see your changes instantly.
-
+const DEMO_QUERY = defineQuery(
+ `*[_type == "demo" && slug.current == $slug][0]{title,"fetchedAt": dateTime(now())}`,
+)
+const slug = 'next-14'
+
+export async function generateMetadata(): Promise {
+ const {data} = await sanityFetch({query: DEMO_QUERY, params: {slug}})
+ return {
+ title: data?.title || 'Next 14',
+ }
+}
-
-
-
+export default async function Home() {
+ const {data} = await sanityFetch({query: DEMO_QUERY, params: {slug}})
+
+ return (
+
+
+ {data?.title || 'Next 14'}
+
+ {data?.fetchedAt && (
+
+
+
+ )}
)
}
diff --git a/next-14/src/sanity/client.ts b/next-14/src/sanity/client.ts
new file mode 100644
index 0000000..a8438ab
--- /dev/null
+++ b/next-14/src/sanity/client.ts
@@ -0,0 +1,8 @@
+import {createClient} from '@sanity/client'
+
+export const client = createClient({
+ projectId: 'hiomol4a',
+ dataset: 'lcapi',
+ apiVersion: '2024-09-22',
+ useCdn: false,
+})
diff --git a/next-14/src/sanity/fetch.ts b/next-14/src/sanity/fetch.ts
new file mode 100644
index 0000000..5ade27d
--- /dev/null
+++ b/next-14/src/sanity/fetch.ts
@@ -0,0 +1,19 @@
+import {type QueryParams} from '@sanity/client'
+import {client} from './client'
+
+export async function sanityFetch
({
+ query,
+ params = {},
+}: {
+ query: QueryString
+ params?: QueryParams
+}) {
+ // Uncached query that fetches cache tags (on Next 15 uncached doesn't mean on every browser request, but on every ISR build)
+ const {syncTags: tags} = await client.fetch(query, params, {
+ filterResponse: false,
+ tag: 'fetch-sync-tags', // The request tag makes the fetch unique, avoids deduping with the cached query that has tags
+ next: {revalidate: 1}, // Ensure we don't opt out of ISR caching
+ })
+ const data = await client.fetch(query, params, {next: {revalidate: false, tags}})
+ return {data, tags}
+}
diff --git a/next-14/tailwind.config.ts b/next-14/tailwind.config.ts
index 226e32a..f3b29eb 100644
--- a/next-14/tailwind.config.ts
+++ b/next-14/tailwind.config.ts
@@ -1,6 +1,6 @@
import type {Config} from 'tailwindcss'
-const config: Config = {
+export default {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
@@ -8,12 +8,21 @@ const config: Config = {
],
theme: {
extend: {
- colors: {
- background: 'var(--background)',
- foreground: 'var(--foreground)',
+ backgroundColor: {
+ 'theme': 'var(--theme-background,#fff)',
+ 'theme-button': 'var(--theme-text,#fff)',
+ },
+ textColor: {
+ 'theme': 'var(--theme-text,#000)',
+ 'theme-button': 'var(--theme-background,#fff)',
+ },
+ ringColor: {
+ theme: 'var(--theme-text,#000)',
+ },
+ ringOffsetColor: {
+ theme: 'var(--theme-background,#fff)',
},
},
},
plugins: [],
-}
-export default config
+} satisfies Config