-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
110 lines (102 loc) · 3.42 KB
/
gatsby-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
/**
* Configure your Gatsby site with this file.
*
* See: https://www.gatsbyjs.org/docs/gatsby-config/
*/
const sanitizeHtml = require("sanitize-html")
const cyrillicToLatin = require("./config/cyrillic-to-latin")
if (process.env.WORDPRESS_USER == null) require("dotenv").config()
// In your gatsby-config.js
module.exports = {
siteMetadata: {
schoolType: "Математическа Гимназия",
schoolName: "Академик Кирил Попов",
},
plugins: [
{
resolve: "gatsby-plugin-material-ui",
options: {
stylesProvider: {
injectFirst: true,
},
},
},
{
resolve: "gatsby-plugin-layout",
options: {
component: require.resolve("./src/layouts/Main/index.ts"),
},
},
"gatsby-plugin-react-helmet",
"gatsby-plugin-typescript",
"gatsby-plugin-sass",
"gatsby-plugin-svgr",
{
resolve: "gatsby-source-filesystem",
options: {
name: "data",
path: `${__dirname}/data/`,
},
},
"gatsby-transformer-json",
{
resolve: "gatsby-plugin-google-analytics",
options: {
trackingId: "UA-142035935-1",
},
},
/*
* Gatsby's data processing layer begins with “source”
* plugins. Here the site sources its data from Wordpress.
*/
{
resolve: "gatsby-source-wordpress",
options: {
/*
* The base URL of the Wordpress site without the trailingslash and the protocol. This is required.
* Example : 'gatsbyjsexamplewordpress.wordpress.com' or 'www.example-site.com'
*/
baseUrl: "megeto1.school.blog",
// The protocol. This can be http or https.
protocol: "https",
// Indicates whether the site is hosted on wordpress.com.
// If false, then the assumption is made that the site is self hosted.
// If true, then the plugin will source its content on wordpress.com using the JSON REST API V2.
// If your site is hosted on wordpress.org, then set this to false.
hostingWPCOM: true,
// If useACF is true, then the source plugin will try to import the Wordpress ACF Plugin contents.
// This feature is untested for sites hosted on wordpress.com.
// Defaults to true.
useACF: true,
auth: {
wpcom_app_clientSecret: process.env.WORDPRESS_CLIENT_SECRET,
wpcom_app_clientId: "65941",
wpcom_user: "qwerty131131",
wpcom_pass: process.env.WORDPRESS_PASSWORD,
},
normalizer: ({ entities }) => {
const paragraphRgx = /<p>(.+?)<\/p>/g
const transformed = entities.map(e => {
if (e.__type === "wordpress__POST") {
e.excerpt = sanitizeHtml(e.excerpt, {
allowedTags: [],
})
// Split content to an array of paragraphs
e.paragraphs = sanitizeHtml(e.content, { allowedTags: ["p"] })
.match(paragraphRgx)
.map(m => m.slice(3, -4))
e.content = sanitizeHtml(e.content, { allowedTags: [] })
e.title = e.title
.replace(" ", " ")
.replace(/̶[01];/g, '"')
e.path = cyrillicToLatin(decodeURIComponent(e.path))
e.slug = cyrillicToLatin(decodeURIComponent(e.slug))
}
return e
})
return transformed
},
},
},
],
}