Skip to content

Commit f86b3fd

Browse files
committed
fix rest of examples
1 parent b7cf1ef commit f86b3fd

File tree

14 files changed

+63
-48
lines changed

14 files changed

+63
-48
lines changed

examples/document-field/next-env.d copy.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/document-field/next.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default {
2+
experimental: {
3+
// Experimental ESM Externals
4+
// https://nextjs.org/docs/messages/import-esm-externals
5+
// required to fix build admin ui issues related to "react-day-picker" and "date-fn"
6+
esmExternals: 'loose',
7+
// without this, 'Error: Expected Upload to be a GraphQL nullable type.'
8+
serverComponentsExternalPackages: ['graphql'],
9+
},
10+
typescript: {
11+
ignoreBuildErrors: true,
12+
},
13+
eslint: {
14+
ignoreDuringBuilds: true,
15+
},
16+
}

examples/document-field/src/app/(admin)/author/[id]/page.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ const author = data?.author
4141
)
4242
}
4343

44-
export async function getStaticPaths (): Promise<GetStaticPathsResult> {
45-
const data = await fetchGraphQL(gql`
46-
query {
47-
authors {
48-
id
49-
}
50-
}
51-
`)
52-
return {
53-
paths: data.authors.map((post: any) => ({ params: { id: post.id } })),
54-
fallback: 'blocking',
55-
}
56-
}
44+
// TODO - CAN NOT use this in app router properly
45+
// export async function getStaticPaths (): Promise<GetStaticPathsResult> {
46+
// const data = await fetchGraphQL(gql`
47+
// query {
48+
// authors {
49+
// id
50+
// }
51+
// }
52+
// `)
53+
// return {
54+
// paths: data.authors.map((post: any) => ({ params: { id: post.id } })),
55+
// fallback: 'blocking',
56+
// }
57+
// }

examples/document-field/src/app/(admin)/post/[slug]/page.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ export default async function Post ({ params }: { params: any }) {
7979
)
8080
}
8181

82-
export async function getStaticPaths (): Promise<GetStaticPathsResult> {
83-
const data = await fetchGraphQL(gql`
84-
query {
85-
posts {
86-
slug
87-
}
88-
}
89-
`)
90-
return {
91-
paths: data.posts.map((post: any) => ({ params: { slug: post.slug } })),
92-
fallback: 'blocking',
93-
}
94-
}
82+
// TODO - CAN NOT use this in app router properly
83+
// export async function getStaticPaths (): Promise<GetStaticPathsResult> {
84+
// const data = await fetchGraphQL(gql`
85+
// query {
86+
// posts {
87+
// slug
88+
// }
89+
// }
90+
// `)
91+
// return {
92+
// paths: data.posts.map((post: any) => ({ params: { slug: post.slug } })),
93+
// fallback: 'blocking',
94+
// }
95+
// }

packages/core/src/admin-ui/context.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { notFound } from 'next/navigation'
12
import React, { type ReactNode, createContext, useContext, useMemo } from 'react'
23
import { Center } from '@keystone-ui/core'
34
import { ToastProvider } from '@keystone-ui/toast'
@@ -164,6 +165,6 @@ export const useList = (key: string) => {
164165
if (lists[key]) {
165166
return lists[key]
166167
} else {
167-
throw new Error(`Invalid list key provided to useList: ${key}`)
168+
return notFound()
168169
}
169170
}

packages/core/src/admin-ui/system/generateAdminUI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export async function generateAdminUI (
6464
graphQLSchema: GraphQLSchema,
6565
adminMeta: AdminMetaRootVal,
6666
projectAdminPath: string,
67+
hasSrc: boolean,
6768
isLiveReload: boolean
6869
) {
6970
// Write out the files configured by the user
@@ -76,7 +77,7 @@ export async function generateAdminUI (
7677

7778
// Write out the built-in admin UI files. Don't overwrite any user-defined pages.
7879
const configFileExists = getDoesAdminConfigExist(projectAdminPath)
79-
let adminFiles = writeAdminFiles(config, graphQLSchema, adminMeta, configFileExists)
80+
let adminFiles = writeAdminFiles(config, graphQLSchema, adminMeta, configFileExists, hasSrc)
8081

8182
adminFiles = adminFiles.filter(
8283
x => !uniqueFiles.has(Path.normalize(Path.join(projectAdminPath, x.outputPath)))

packages/core/src/admin-ui/templates/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ export const writeAdminFiles = (
1616
config: __ResolvedKeystoneConfig,
1717
graphQLSchema: GraphQLSchema,
1818
adminMeta: AdminMetaRootVal,
19-
configFileExists: boolean
19+
configFileExists: boolean,
20+
srcExists: boolean,
2021
): AdminFileToWrite[] => {
2122
const ext = config.ui?.tsx ? 'tsx' : 'js'
2223
return [
2324
{
2425
mode: 'write',
25-
src: nextConfigTemplate(config.ui?.basePath),
26-
outputPath: '../../next.config.mjs',
26+
src: nextConfigTemplate(),
27+
outputPath: `${srcExists ? '../' : ''}../../next.config.mjs`,
2728
},
2829
{ mode: 'write', src: noAccessTemplate(config.session), outputPath: `no-access/page.${ext}` },
2930
{ mode: 'write', src: adminLayoutTemplate(), outputPath: `layout.${ext}` },

packages/core/src/admin-ui/templates/next-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const nextConfigTemplate = (basePath?: string) =>
1+
export const nextConfigTemplate = () =>
22
`export default {
33
experimental: {
44
// Experimental ESM Externals

packages/core/src/lib/createSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export function getSystemPaths (cwd: string, config: KeystoneConfig | __Resolved
6868
prisma: builtPrismaPath,
6969
graphql: builtGraphqlPath,
7070
},
71+
hasSrc,
7172
}
7273
}
7374

0 commit comments

Comments
 (0)