-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprismic-configuration.js
32 lines (27 loc) · 1021 Bytes
/
prismic-configuration.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 Prismic from 'prismic-javascript'
// -- Prismic API endpoint
// Determines which repository to query and fetch data from
// Configure your site's access point here
export const apiEndpoint = 'https://project-ignite.prismic.io/api/v2'
// -- Access Token if the repository is not public
// Generate a token in your dashboard and configure it here if your repository is private
export const accessToken = ''
// -- Link resolution rules
// Manages links to internal Prismic documents
// Modify as your project grows to handle any new routes you've made
export const linkResolver = (doc) => {
if (doc.type === 'post') {
return `/blog/${doc.uid}`
}
return '/'
}
// Additional helper function for Next/Link components
export const hrefResolver = (doc) => {
if (doc.type === 'post') {
return `/post?uid=${doc.uid}`
}
return '/'
}
// -- Client method to query Prismic
// Connects to the given repository to facilitate data queries
export const client = Prismic.client(apiEndpoint, { accessToken })