1+ const path = require ( 'path' ) ;
2+
13require ( 'dotenv' ) . config ( ) ;
24
35const config = require ( './src/config.json' ) ;
@@ -21,7 +23,6 @@ const gatsbyConfig = {
2123 'gatsby-plugin-catch-links' ,
2224 '@skagami/gatsby-plugin-dark-mode' ,
2325 'gatsby-transformer-yaml' ,
24- 'gatsby-remark-images' ,
2526 'gatsby-plugin-sharp' ,
2627 {
2728 resolve : 'gatsby-plugin-canonical-urls' ,
@@ -44,68 +45,65 @@ const gatsbyConfig = {
4445 resolve : 'gatsby-source-filesystem' ,
4546 options : {
4647 name : 'learn' ,
47- path : ` ${ __dirname } /content/learn` ,
48+ path : path . resolve ( '. /content/learn' ) ,
4849 } ,
4950 } ,
5051 {
5152 resolve : 'gatsby-source-filesystem' ,
5253 options : {
5354 name : 'sites' ,
54- path : ` ${ __dirname } /src/pages/` ,
55+ path : path . resolve ( '. /src/pages' ) ,
5556 } ,
5657 } ,
5758 {
5859 resolve : 'gatsby-source-filesystem' ,
5960 options : {
6061 name : 'homepage' ,
61- path : ` ${ __dirname } /content/homepage` ,
62+ path : path . resolve ( '. /content/homepage' ) ,
6263 } ,
6364 } ,
6465 {
6566 resolve : 'gatsby-source-filesystem' ,
6667 options : {
6768 name : 'community' ,
68- path : ` ${ __dirname } /content/community` ,
69+ path : path . resolve ( '. /content/community' ) ,
6970 } ,
7071 } ,
7172 {
7273 resolve : 'gatsby-source-filesystem' ,
7374 options : {
7475 name : 'blog' ,
75- path : ` ${ __dirname } /content/blog` ,
76+ path : path . resolve ( '. /content/blog' ) ,
7677 } ,
7778 } ,
7879 {
7980 resolve : 'gatsby-source-filesystem' ,
8081 options : {
8182 name : 'data' ,
82- path : ` ${ __dirname } /src/data` ,
83+ path : path . resolve ( '. /src/data' ) ,
8384 } ,
8485 } ,
8586 {
8687 resolve : 'gatsby-source-filesystem' ,
8788 options : {
8889 name : 'about' ,
89- path : ` ${ __dirname } /content/about` ,
90+ path : path . resolve ( '. /content/about' ) ,
9091 } ,
9192 } ,
9293 {
9394 resolve : 'gatsby-source-filesystem' ,
9495 options : {
9596 name : 'download' ,
96- path : ` ${ __dirname } /content/download` ,
97+ path : path . resolve ( '. /content/download' ) ,
9798 } ,
9899 } ,
99100 'gatsby-plugin-typescript' ,
100101 {
101102 resolve : 'gatsby-plugin-mdx' ,
102103 options : {
103104 extensions : [ '.mdx' , '.md' ] ,
104- defaultLayouts : {
105- default : require . resolve ( `./src/components/Layout/index.tsx` ) ,
106- } ,
107105 gatsbyRemarkPlugins : [
108- 'gatsby-remark-copy-linked-files' ,
106+ { resolve : 'gatsby-remark-copy-linked-files' } ,
109107 {
110108 resolve : 'gatsby-remark-autolink-headers' ,
111109 options : {
@@ -138,17 +136,30 @@ const gatsbyConfig = {
138136 {
139137 resolve : `@gatsby-contrib/gatsby-plugin-elasticlunr-search` ,
140138 options : {
141- fields : [ `title` , `body` , `description` , `slug` ] ,
139+ fields : [
140+ 'slug' ,
141+ 'title' ,
142+ 'displayTitle' ,
143+ 'description' ,
144+ 'category' ,
145+ 'tableOfContents' ,
146+ ] ,
142147 resolvers : {
143148 Mdx : {
144149 id : node => node . id ,
145150 title : node => node . frontmatter . title ,
146- body : node => node . rawBody ,
151+ displayTitle : node => node . frontmatter . displayTitle ,
147152 description : node => node . frontmatter . description ,
148153 slug : node => node . fields . slug ,
154+ category : node => node . fields . categoryName ,
155+ tableOfContents : node => {
156+ return [ ...node . rawBody . matchAll ( / ^ # { 2 , 5 } .* / gm) ]
157+ . map ( match => match [ 0 ] . replace ( / ^ # { 2 , 5 } / , '' ) )
158+ . join ( '\n' ) ;
159+ } ,
149160 } ,
150161 } ,
151- filter : node => node . frontmatter . category === 'learn' ,
162+ filter : node => [ 'api' , 'learn' ] . includes ( node . frontmatter . category ) ,
152163 } ,
153164 } ,
154165 {
@@ -158,11 +169,39 @@ const gatsbyConfig = {
158169 resolve : `gatsby-theme-i18n` ,
159170 options : {
160171 defaultLang : defaultLanguage ,
161- configPath : ` ${ __dirname } /src/i18n/config.json` ,
172+ configPath : path . resolve ( '. /src/i18n/config.json' ) ,
162173 prefixDefault : true ,
163174 locales : localesAsString ,
164175 } ,
165176 } ,
177+ {
178+ resolve : `gatsby-plugin-webfonts` ,
179+ options : {
180+ fonts : {
181+ google : [
182+ {
183+ family : 'Open Sans' ,
184+ variants : [
185+ '300' ,
186+ '300i' ,
187+ '400' ,
188+ '400i' ,
189+ '600' ,
190+ '600i' ,
191+ '900' ,
192+ '900i' ,
193+ ] ,
194+ fontDisplay : 'swap' ,
195+ strategy : 'selfHosted' ,
196+ } ,
197+ ] ,
198+ } ,
199+ formats : [ 'woff2' ] ,
200+ useMinify : true ,
201+ usePreload : true ,
202+ usePreconnect : true ,
203+ } ,
204+ } ,
166205 {
167206 resolve : 'gatsby-plugin-manifest' ,
168207 options : {
@@ -191,13 +230,6 @@ if (!gatsbyConfig.pathPrefix) {
191230 // So we are able to use the official service worker again. This service worker supports latest Workbox
192231 resolve : 'gatsby-plugin-offline-next' ,
193232 options : {
194- precachePages : [
195- '/' ,
196- '/*/learn/*' ,
197- '/*/about/*' ,
198- '/*/download/*' ,
199- '/*/blog/*' ,
200- ] ,
201233 globPatterns : [ '**/icon-path*' ] ,
202234 } ,
203235 } ) ;
0 commit comments