forked from contentstack/contentstack-gatsby-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.ts
100 lines (95 loc) · 2.84 KB
/
gatsby-config.ts
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
// Module dependency
require("ts-node").register({
compilerOptions: {
module: "commonjs",
target: "es2017",
},
});
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
});
const {
CONTENTSTACK_API_KEY,
CONTENTSTACK_DELIVERY_TOKEN,
CONTENTSTACK_ENVIRONMENT,
CONTENTSTACK_BRANCH,
CONTENTSTACK_REGION,
CONTENTSTACK_API_HOST,
CONTENTSTACK_HOSTED_URL,
CONTENTSTACK_JSON_RTE_TO_HTML,
} = process.env;
const hostedUrl = CONTENTSTACK_HOSTED_URL || "http://localhost:9000";
const cdnHost = CONTENTSTACK_API_HOST?.replace(/api/g, "cdn");
module.exports = {
siteMetadata: {
title: "Gatsby Sample App",
description: "This is a sample app build using Gatsby and Contentstack",
author: "Contentstack",
siteUrl: hostedUrl,
},
plugins: [
"gatsby-plugin-sitemap",
"gatsby-plugin-offline",
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: "gatsby-plugin-robots-txt",
options: {
host: hostedUrl,
sitemap: `${hostedUrl}/sitemap.xml`,
policy: [{ userAgent: "*" }],
},
},
{
resolve: "gatsby-plugin-manifest",
options: {
name: "Contentstack-Gatsby-Starter-App",
short_name: "starter",
start_url: "/",
background_color: "#663399",
theme_color: "#663399",
display: "minimal-ui",
icon: "src/images/contentstack.png", // This path is relative to the root of the site.
icon_options: {
purpose: `any maskable`,
},
},
},
{
resolve: "gatsby-source-contentstack",
options: {
api_key: CONTENTSTACK_API_KEY,
delivery_token: CONTENTSTACK_DELIVERY_TOKEN,
environment: CONTENTSTACK_ENVIRONMENT,
branch: CONTENTSTACK_BRANCH ? CONTENTSTACK_BRANCH : "main",
cdn: `https://${cdnHost}/v3`,
// Specify whether to convert RTE Json to HTML
jsonRteToHtml: true,
// Optional: expediteBuild set this to either true or false
expediteBuild: true,
// Optional: Specify true if you want to generate custom schema
enableSchemaGeneration: true,
// Optional: Specify a different prefix for types. This is useful in cases where you have multiple instances of the plugin to be connected to different stacks.
type_prefix: "Contentstack", // (default),
},
},
{
resolve: `gatsby-plugin-env-variables`,
options: {
allowList: [
"CONTENTSTACK_API_KEY",
"CONTENTSTACK_DELIVERY_TOKEN",
"CONTENTSTACK_ENVIRONMENT",
"CONTENTSTACK_BRANCH",
"CONTENTSTACK_REGION",
"CONTENTSTACK_MANAGEMENT_TOKEN",
"CONTENTSTACK_API_HOST",
"CONTENTSTACK_APP_HOST",
"CONTENTSTACK_LIVE_PREVIEW",
"CONTENTSTACK_JSON_RTE_TO_HTML"
],
},
},
],
};