-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprismicio.js
114 lines (109 loc) · 2.24 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import * as prismic from "@prismicio/client";
import * as prismicNext from "@prismicio/next";
import config from "./slicemachine.config.json";
/**
* The project's Prismic repository name.
*/
export const repositoryName =
process.env.NEXT_PUBLIC_PRISMIC_ENVIRONMENT || config.repositoryName;
/**
* A list of Route Resolver objects that define how a document's `url` field is resolved.
*
* {@link https://prismic.io/docs/route-resolver#route-resolver}
*
* @type {prismic.ClientConfig["routes"]}
*/
// TODO: Update the routes array to match your project's route structure.
const routes = [
{
type: "home_page",
path: "/",
},
{
type: "about_page",
path: "/about",
},
{
type: "collections_page",
path: "/collections",
},
{
type: "collection_page",
path: "/collection/:uid",
},
{
type: "categories_page",
path: "/categories",
},
{
type: "category_page",
path: "/category/:uid",
},
{
type: "deals_page",
path: "/deals",
},
{
type: "blogs_page",
path: "/blogs",
},
{
type: "blog_post",
path: "/blog/:uid",
},
{
type: "product_page",
path: "/:uid",
},
{
type: "customize_page",
path: "/customize",
},
{
type: "contact_page",
path: "/contact",
},
{
type: "shop_page",
path: "/shop",
},
{
type: "return_exchange_policy",
path: "/return-exchange-policy",
},
{
type: "shipping_policy_page",
path: "/shipping-policy",
},
{
type: "privacy_policy_page",
path: "/privacy-policy",
},
{
type: "terms_condition_page",
path: "/terms-conditions",
},
];
/**
* Creates a Prismic client for the project's repository. The client is used to
* query content from the Prismic API.
*
* @param {prismicNext.CreateClientConfig} config - Configuration for the Prismic client.
*/
export const createClient = (config = {}) => {
const client = prismic.createClient(repositoryName, {
accessToken: process.env.PRISMIC_ACCESS_TOKEN,
routes,
fetchOptions: {
// cache: "no-store",
next: { tags: ["prismic"], revalidate: 5 },
},
...config,
});
prismicNext.enableAutoPreviews({
client,
previewData: config.previewData,
req: config.req,
});
return client;
};