-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gridsome.config.js
476 lines (469 loc) · 15.4 KB
/
gridsome.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// Changes here requires a server restart.
// To restart press CTRL + C in terminal and run `gridsome develop`
const site = require("./site.json");
const { marked } = require("marked");
module.exports = {
siteName: site.name,
// siteDescription: site.description,
siteUrl: site.url,
templates: {
post: "/:permalink",
tag: "/tag/:title",
portfolio: "/:permalink",
},
plugins: [
// https://github.com/krmax44/gridsome-plugin-bundle-analyzer
{
use: "gridsome-plugin-bundle-analyzer",
options: {
onlyProduction: true,
analyzerOptions: {
analyzerMode: "static",
openAnalyzer: false,
},
},
},
// https://gridsome.org/plugins/@gridsome/plugin-critical
{
use: "@gridsome/plugin-critical",
options: {
paths: ["/*"],
width: 1300,
height: 900,
},
},
// https://gridsome.org/plugins/@gridsome/plugin-google-analytics
{
use: "@gridsome/plugin-google-analytics",
options: {
id: site.googleAnalyticsId,
},
},
// https://gridsome.org/plugins/@gridsome/plugin-sitemap
{
use: "@gridsome/plugin-sitemap",
options: {
cacheTime: 600000, // default
// exclude: ['/exclude-me'],
config: {
// '/articles/*': {
// changefreq: 'weekly',
// priority: 0.5
// },
// '/about': {
// changefreq: 'monthly',
// priority: 0.7
// }
},
},
},
// https://gridsome.org/plugins/@gridsome/source-filesystem
{
// Create posts from markdown files
use: "@gridsome/source-filesystem",
options: {
typeName: "post",
path: "content/posts/**/*.md",
refs: {
// Creates a GraphQL collection from 'tags' in front-matter and adds a reference.
tags: {
typeName: "tag",
create: true,
},
},
},
},
// https://gridsome.org/plugins/@gridsome/source-filesystem
{
// Create posts from markdown files
use: "@gridsome/source-filesystem",
options: {
typeName: "portfolio",
path: "content/portfolio/**/*.md",
refs: {
// Creates a GraphQL collection from 'tags' in front-matter and adds a reference.
tags: {
typeName: "tag",
create: true,
},
},
},
},
// https://gridsome.org/plugins/gridsome-plugin-brotli
// {
// use: "gridsome-plugin-brotli",
// options: {
// extensions: ["css", "html", "js", "svg", "json"],
// },
// },
// https://github.com/Microflash/gridsome-plugin-feed
{
use: "@microflash/gridsome-plugin-feed",
options: {
// Required: array of `GraphQL` type names you wish to include
contentTypes: ["post"],
// Optional: any properties you wish to set for `Feed()` constructor
// See https://www.npmjs.com/package/feed#example for available properties
feedOptions: {
title: site.name,
description: site.description,
id: site.url,
link: site.url,
language: site.language,
image: site.url + "/images/hero/Muhammad-Rehan-Saeed-1600x900.jpg",
favicon: site.url + "/favicon.ico",
copyright: `Copyright © ${new Date().getFullYear()} ${
site.author.name
}`,
feedLinks: {
atom: site.url + "/atom.xml",
json: site.url + "/feed.json",
rss: site.url + "/rss.xml",
},
author: {
name: site.author.name,
link: site.url,
},
},
atom: {
enabled: true,
output: "/atom.xml",
},
json: {
enabled: true,
output: "/feed.json",
},
rss: {
enabled: true,
output: "/rss.xml",
},
// Optional: the maximum number of items to include in your feed
maxItems: 300,
// Optional: an array of properties passed to `Feed.addItem()` that will be parsed for
// URLs in HTML (ensures that URLs are full `http` URLs rather than site-relative).
// To disable this functionality, set to `null`.
htmlFields: ["description", "content"],
// Optional: if you wish to enforce trailing slashes for site URLs
enforceTrailingSlashes: false,
// Optional: a method that accepts a node and returns true (include) or false (exclude)
// Example: only past-dated nodes: `filterNodes: (node) => node.date <= new Date()`
filterNodes: (node) => {
return node.published;
},
// Optional: a method that accepts a node and returns an object for `Feed.addItem()`
// See https://www.npmjs.com/package/feed#example for available properties
// NOTE: `date` field MUST be a Javascript `Date` object
nodeToFeedItem: (node) => {
return {
title: node.title,
id: site.url + node.permalink,
link: site.url + node.permalink,
description: node.description,
content: marked(node.content),
author: [
{
name: node.author.name,
link: site.url,
},
],
date: new Date(node.date),
categories: node.tags,
image: site.url + node.heroImage,
};
},
},
},
// https://gridsome.org/plugins/gridsome-plugin-flexsearch
{
use: "gridsome-plugin-flexsearch",
options: {
collections: [
{
typeName: "post",
indexName: "post",
fields: ["title", "description", "heroImage", "permalink"],
},
{
typeName: "portfolio",
indexName: "portfolio",
fields: ["title", "description", "heroImage", "permalink"],
},
],
searchFields: ["title", "description"],
},
},
// https://gridsome.org/plugins/gridsome-plugin-pwa
{
use: "gridsome-plugin-pwa",
options: {
// Service Worker
disableServiceWorker: false,
serviceWorkerPath: "service-worker.js",
cachedFileTypes: "js,json,css,html,png,jpg,jpeg,svg,gif",
disableTemplatedUrls: true,
modifyServiceWorkerConfig: (config) => {
config.globIgnores.push("images/items/**/*");
config.globIgnores.push("images/reactions/**/*");
config.globIgnores.push("images/thumbnails/**/*");
},
// Manifest
manifestPath: "manifest.webmanifest",
id: "https://rehansaeed.com/",
title: site.name,
shortName: site.shortName,
description: site.description,
categories: ["education"],
lang: "en-GB",
dir: "ltr",
startUrl: "/",
display: "minimal-ui",
statusBarStyle: "default",
backgroundColor: "#f2f4f7",
themeColor: "#6b17e8",
icon: "static/favicon.png",
maskableIcon: true,
shortcuts: [
{
name: "Blog",
short_name: "Blog",
description: "Read the latest blog posts.",
url: "/",
icons: [{ src: "/images/icons/blog.png", sizes: "192x192" }],
},
{
name: "Portfolio",
short_name: "Portfolio",
description: "View the portfolio of my projects.",
url: "/portfolio/",
icons: [{ src: "/images/icons/portfolio.png", sizes: "192x192" }],
},
{
name: "About",
short_name: "About",
description: "About Muhammad Rehan Saeed.",
url: "/about/",
icons: [{ src: "/images/icons/about.png", sizes: "192x192" }],
},
],
screenshots: [
{
src: "/images/screenshots/screenshot1-1172x1820.png",
sizes: "1172x1820",
type: "image/png",
},
{
src: "/images/screenshots/screenshot2-1172x1820.png",
sizes: "1172x1820",
type: "image/png",
},
{
src: "/images/screenshots/screenshot3-1172x1820.png",
sizes: "1172x1820",
type: "image/png",
},
],
},
},
// https://gridsome.org/plugins/gridsome-plugin-robots
{
use: "gridsome-plugin-robots",
options: {
host: site.url,
sitemap: `${site.url}/sitemap.xml`,
policy: [{ userAgent: "*", allow: "/" }],
},
},
{
use: "gridsome-source-static-meta",
options: {
path: "site.json",
},
},
],
transformers: {
remark: {
externalLinksTarget: "_blank",
externalLinksRel: ["nofollow", "noopener", "noreferrer"],
anchorClassName: "icon icon-link",
plugins: [
// https://github.com/sammndhr/gridsome-remark-embed-snippet
["gridsome-remark-embed-snippet", {}],
// https://github.com/remarkjs/remark-autolink-headings
[
"remark-autolink-headings",
{
content: {
type: "element",
tagName: "svg",
properties: {
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
viewBox: "0 0 16 16",
version: "1.1",
width: 22,
height: 22,
"aria-hidden": "true",
},
children: [
{
type: "element",
tagName: "path",
properties: {
fill: "currentColor",
"fill-rule": "evenodd",
d: "M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z",
},
},
],
},
},
],
// https://github.com/nevenall/remark-containers
[
"remark-containers",
{
default: false,
custom: [
{
type: "tip",
element: "div",
transform: function (node, config, tokenize) {
return transformContainer(node, config, "tip", "p", "Tip");
},
},
{
type: "warning",
element: "div",
transform: function (node, config, tokenize) {
return transformContainer(
node,
config,
"warning",
"p",
"Warning"
);
},
},
{
type: "danger",
element: "div",
transform: function (node, config, tokenize) {
return transformContainer(
node,
config,
"danger",
"p",
"Warning"
);
},
},
{
type: "details",
element: "details",
transform: function (node, config, tokenize) {
return transformContainer(
node,
config,
"details",
"summary",
"Details"
);
},
},
],
},
],
// https://github.com/zestedesavoir/zmarkdown/tree/master/packages/remark-kbd
["remark-kbd", {}],
// https://github.com/remarkjs/remark-toc
["remark-toc", {}],
// https://github.com/Braincoke/gridsome-plugin-remark-mermaid
[
"gridsome-plugin-remark-mermaid",
{
theme: "neutral",
},
],
// https://github.com/pchorus/gridsome-remark-katex
["gridsome-remark-katex", {}],
// https://github.com/DavidCouronne/gridsome-plugin-remark-prismjs-all
[
"gridsome-plugin-remark-prismjs-all",
{
highlightClassName: "line-highlight",
codeTitleClassName: "code-title",
// Class prefix for <pre> tags containing syntax highlighting;
// defaults to 'language-' (eg <pre class="language-js">).
// If your site loads Prism into the browser at runtime,
// (eg for use with libraries like react-live),
// you may use this to prevent Prism from re-processing syntax.
// This is an uncommon use-case though;
// If you're unsure, it's best to use the default value.
// classPrefix: "language-",
// This lets you set up language aliases. For example,
// setting this to '{ sh: "bash" }' will let you use
// the language "sh" which will highlight using the
// bash highlighter.
// aliases: {},
// This toggles the display of line numbers globally alongside the code.
// To use it, add the following line in src/layouts/index.js
// right after importing the prism color scheme:
// `require("prismjs/plugins/line-numbers/prism-line-numbers.css");`
// Defaults to false.
// If you wish to only show line numbers on certain code blocks,
// leave false and use the {numberLines: true} syntax below
showLineNumbers: false,
// If setting this to true, the parser won't handle and highlight inline
// code used in markdown i.e. single backtick code like `this`.
noInlineHighlight: false,
// This adds a new language definition to Prism or extend an already
// existing language definition. More details on this option can be
// found under the header "Add new language definition or extend an
// existing language" below.
// languageExtensions: [],
// Customize the prompt used in shell output
// Values below are default
// prompt: {
// user: "root",
// host: "localhost",
// global: false
// }
},
],
// https://github.com/noxify/gridsome-plugin-remark-embed
[
"@noxify/gridsome-plugin-remark-embed",
{
enabledProviders: ["Youtube"], // 'Twitter', 'Codepen'
Youtube: {
// margin: "25px 0 25px 0",
},
// Twitter: {
// hideMedia: false
// },
// Codepen: {
// // iframe: true
// }
},
],
// https://github.com/remarkjs/remark-validate-links
["remark-validate-links", {}],
],
},
},
};
function transformContainer(node, config, type, element, defaultTitle) {
node.data.hProperties = {
className: `custom-block ${type}`,
};
node.children.splice(0, 0, {
type: "paragraph",
data: {
hName: element,
hProperties: {
className: "custom-block-title",
},
},
children: [{ type: "text", value: config || defaultTitle }],
});
}