-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprismicio.js
More file actions
33 lines (28 loc) · 763 Bytes
/
prismicio.js
File metadata and controls
33 lines (28 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as prismic from '@prismicio/client'
import { enableAutoPreviews } from '@prismicio/next'
import sm from './sm.json'
export const endpoint = sm.apiEndpoint
export const repositoryName = prismic.getRepositoryName(endpoint)
// Update the Link Resolver to match your project's route structure
export function linkResolver(doc) {
switch (doc.type) {
case 'homepage':
return '/'
case 'page':
return `/${doc.uid}`
default:
return null
}
}
// This factory function allows smooth preview setup
export function createClient(config = {}) {
const client = prismic.createClient(endpoint, {
...config,
})
enableAutoPreviews({
client,
previewData: config.previewData,
req: config.req,
})
return client
}