-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathdocusaurus.config.js
194 lines (175 loc) · 5.18 KB
/
docusaurus.config.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
require("dotenv").config();
const { themes } = require("prism-react-renderer");
const path = require("node:path");
const gtmContainerId = process.env.GTM_CONTAINER_ID;
module.exports = {
title: "Saleor Commerce Documentation",
tagline: "High performance, composable, headless commerce API.",
url: "https://docs.saleor.io",
baseUrl: "/",
onBrokenAnchors: "throw",
// Used for publishing and more
projectName: "saleor-docs",
organizationName: "saleor",
favicon: "img/saleor-icon.png",
future: {
experimental_faster: true,
},
markdown: {
mermaid: true,
parseFrontMatter: async (params) => {
const result = await params.defaultParseFrontMatter(params);
result.frontMatter.pagination_prev = null;
result.frontMatter.pagination_next = null;
// Tweak the API Reference pages because they are affecting our SEO
// `api_reference` variable is set at the level of mdx file generations from the schema
// while this code here is run later at the build stage
if (result.frontMatter?.api_reference == true) {
// We are going to change the title, make sure to keep the sidebar_label intact
result.frontMatter.sidebar_label = result.frontMatter.title;
// Generate a custom title for each of the API Reference files based on the category
// This should generate entries like Objects: Product or Queries: Product
let category_path = path.dirname(params.filePath).split("/");
let category_name = category_path[category_path.length - 1];
let category_title_mapping = {
directives: "Directive",
enums: "Enum",
inputs: "Input Type",
interfaces: "Interface",
mutations: "Mutation",
objects: "Object",
queries: "Query",
scalars: "Scalar",
subscriptions: "Subscription",
unions: "Union",
};
let category_suffix = category_title_mapping[category_name];
result.frontMatter.title =
result.frontMatter.title + " " + category_suffix;
// For GraphQL pages that don't have description we don't want to duplicate the meta description tag
// Ideally we should make sure each element from the schema does have a description
// But for now we're just going to make sure we don't have duplicates
if (params.fileContent.includes("No description")) {
result.frontMatter.description =
result.frontMatter.title + " - no description";
}
}
return result;
},
},
themes: ["@docusaurus/theme-mermaid"],
plugins: [
[
"@graphql-markdown/docusaurus",
{
schema: "./schema.graphql",
rootPath: "./docs", // docs will be generated under rootPath/baseURL
baseURL: "api-reference",
homepage: "./template/api-reference.mdx",
linkRoot: "../../../",
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader",
},
groupByDirective: {
directive: "doc",
field: "category",
fallback: "Miscellaneous",
},
docOptions: {
frontMatter: {
api_reference: true,
},
},
printTypeOptions: {
hierarchy: "entity",
},
},
],
],
themeConfig: {
algolia: {
appId: "P1Y4DTZUZN", // cspell: disable-line
apiKey: "021901243603f49a626be6b7435a2a8d",
indexName: "saleor",
placeholder: "Search Saleor Documentation",
},
colorMode: {
respectPrefersColorScheme: true,
},
/* Colors for website */
colors: {
primaryColor: "#0c7d7b",
secondaryColor: "#5d623c",
},
docs: {
sidebar: {
autoCollapseCategories: true,
},
},
mermaid: {
theme: {
light: "neutral",
dark: "dark",
},
},
navbar: {
hideOnScroll: true,
logo: {
alt: "Saleor",
src: "img/logo.svg",
srcDark: "img/logo-white.svg",
className: "saleor-logo",
},
items: [
{
type: "search",
position: "left",
},
{
to: "https://cloud.saleor.io/signup?utm_button=Sign%20up&utm_page=docs",
label: "Sign up",
position: "right",
className: "signup-button-cta",
},
],
},
prism: {
theme: themes.oceanicNext,
additionalLanguages: [
"json",
"bash",
"graphql",
"http",
"tsx",
"typescript",
],
},
},
customFields: {
sentryDSN: process.env.SENTRY_DSN,
},
presets: [
[
"@docusaurus/preset-classic",
{
theme: {
customCss: [require.resolve("./src/css/theme.css")],
},
docs: {
breadcrumbs: false,
routeBasePath: "/",
path: "docs",
editUrl: function ({ version, versionDocsDirPath, docPath }) {
return `https://github.com/saleor/saleor-docs/edit/main/docs/${docPath}`;
},
sidebarPath: "sidebars.js",
},
...(gtmContainerId && {
googleTagManager: {
containerId: gtmContainerId,
},
}),
},
],
],
};