forked from stefansnaerh/apiko-prismic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprismicio.js
32 lines (27 loc) · 798 Bytes
/
prismicio.js
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
import * as prismic from '@prismicio/client'
import * as prismicH from '@prismicio/helpers'
import * as prismicNext from '@prismicio/next'
import sm from './sm.json'
export const repositoryName = prismic.getRepositoryName(sm.apiEndpoint)
// Update the Link Resolver to match your project's route structure
export function linkResolver(doc) {
switch (doc.type) {
case 'homepage':
return '/'
case 'company_info':
return `/${doc.uid}`
case 'book_appointment' :
return '/bookAppointment'
default:
return null
}
}
export const createClient = (config = {}) => {
const client = prismic.createClient(sm.apiEndpoint, config)
prismicNext.enableAutoPreviews({
client,
previewData: config.previewData,
req: config.req
})
return client
}