(Examples) update Grafbase example (#54705)
Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
This commit is contained in:
parent
f0f87629c3
commit
638cc931be
4 changed files with 10 additions and 18 deletions
|
@ -1,14 +1,14 @@
|
|||
import './globals.css'
|
||||
|
||||
import Link from 'next/link'
|
||||
|
||||
import { graphql } from '../gql'
|
||||
import { grafbase } from '../lib/grafbase'
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
export const revalidate = 0
|
||||
|
||||
export const metadata = {
|
||||
export const metadata: Metadata = {
|
||||
title: 'Grafbase + Next.js',
|
||||
description: 'Grafbase + Next.js',
|
||||
}
|
||||
|
||||
const GetAllPostsDocument = graphql(/* GraphQL */ `
|
||||
|
@ -25,16 +25,17 @@ const GetAllPostsDocument = graphql(/* GraphQL */ `
|
|||
}
|
||||
`)
|
||||
|
||||
const RootLayout = async ({ children }: { children: React.ReactNode }) => {
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const { postCollection } = await grafbase.request(GetAllPostsDocument, {
|
||||
first: 50,
|
||||
})
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Grafbase + Next.js 13</title>
|
||||
</head>
|
||||
<body>
|
||||
<div className="flex">
|
||||
<nav className="w-[350px] flex flex-col justify-between h-screen overflow-y-auto bg-gray-100">
|
||||
|
@ -82,5 +83,3 @@ const RootLayout = async ({ children }: { children: React.ReactNode }) => {
|
|||
</html>
|
||||
)
|
||||
}
|
||||
|
||||
export default RootLayout
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const Page = async () => {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<h1>Next.js 13 + Grafbase</h1>
|
||||
|
@ -9,5 +9,3 @@ const Page = async () => {
|
|||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Page
|
||||
|
|
|
@ -11,7 +11,7 @@ const GetPostBySlugDocument = graphql(/* GraphQL */ `
|
|||
}
|
||||
`)
|
||||
|
||||
const Page = async ({ params }: { params: { slug: string } }) => {
|
||||
export default async function Page({ params }: { params: { slug: string } }) {
|
||||
const { post } = await grafbase.request(GetPostBySlugDocument, {
|
||||
slug: params.slug,
|
||||
})
|
||||
|
@ -28,5 +28,3 @@ const Page = async ({ params }: { params: { slug: string } }) => {
|
|||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Page
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
experimental: {
|
||||
runtime: 'experimental-edge',
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
|
|
Loading…
Reference in a new issue