@@ -11,74 +11,43 @@ const slugify = require("./src/utils/slugify");
1111const { paginate } = require ( "gatsby-awesome-pagination" ) ;
1212const { createFilePath } = require ( "gatsby-source-filesystem" ) ;
1313const config = require ( "./gatsby-config" ) ;
14- const isDevelopment = process . env . NODE_ENV === "development" ;
15- const isProduction = process . env . NODE_ENV === "production" ;
16-
1714
1815const HEAVY_COLLECTIONS = new Set ( [ "members" , "integrations" ] ) ;
1916const isFullSiteBuild = process . env . BUILD_FULL_SITE !== "false" ;
20- const shouldIncludeCollection = ( collection ) => isFullSiteBuild || ! HEAVY_COLLECTIONS . has ( collection ) ;
21-
22- if ( process . env . CI === "true" ) {
23- // All process.env.CI conditionals in this file are in place for GitHub Pages, if webhost changes in the future, code may need to be modified or removed.
24- //Replacing '/' would result in empty string which is invalid
25- const replacePath = ( url ) =>
26- url === "/" || url . includes ( "/404" ) || url . endsWith ( ".html" ) ? url : `${ url } .html` ;
27-
28- exports . onCreatePage = ( { page, actions } ) => {
29- const { createPage, deletePage, createRedirect } = actions ;
30- const oldPage = Object . assign ( { } , page ) ;
31- page . matchPath = page . path ;
32- page . path = replacePath ( page . path ) ;
33-
34- if ( page . path !== oldPage . path ) {
35- // Replace new page with old page
36- deletePage ( oldPage ) ;
37- createPage ( page ) ;
38-
39- createRedirect ( {
40- fromPath : `/${ page . matchPath } /` ,
41- toPath : `/${ page . matchPath } ` ,
42- redirectInBrowser : true ,
43- isPermanent : true ,
44- } ) ;
45- }
46- } ;
47- }
48-
17+ const shouldIncludeCollection = ( collection ) =>
18+ isFullSiteBuild || ! HEAVY_COLLECTIONS . has ( collection ) ;
4919
5020const { loadRedirects } = require ( "./src/utils/redirects.js" ) ;
5121
5222exports . createPages = async ( { actions, graphql, reporter } ) => {
5323 const { createRedirect } = actions ;
5424 const redirects = loadRedirects ( ) ;
55- redirects . forEach ( redirect => createRedirect ( redirect ) ) ; // Handles all hardcoded ones dynamically
25+ redirects . forEach ( ( redirect ) => createRedirect ( redirect ) ) ; // Handles all hardcoded ones dynamically
5626 // Create Pages
5727 const { createPage } = actions ;
5828
5929 const envCreatePage = ( props ) => {
30+ const pageProps = {
31+ ...props ,
32+ matchPath : props . matchPath || props . path ,
33+ } ;
34+
6035 if ( process . env . CI === "true" ) {
61- const { path, matchPath, ...rest } = props ;
62- const isHandbookPage = path . startsWith ( "/community/handbook/" ) ;
36+ const { path } = pageProps ;
6337 createRedirect ( {
6438 fromPath : `/${ path } /` ,
6539 toPath : `/${ path } ` ,
6640 redirectInBrowser : true ,
6741 isPermanent : true ,
6842 } ) ;
69-
70- return createPage ( {
71- path : isHandbookPage ? path : `${ path } .html` ,
72- matchPath : matchPath || path ,
73- ...rest ,
74- } ) ;
7543 }
76- return createPage ( props ) ;
44+
45+ return createPage ( pageProps ) ;
7746 } ;
7847
7948 const blogPostTemplate = path . resolve ( "src/templates/blog-single.js" ) ;
8049 const blogCategoryListTemplate = path . resolve (
81- "src/templates/blog-category-list.js"
50+ "src/templates/blog-category-list.js" ,
8251 ) ;
8352 const blogTagListTemplate = path . resolve ( "src/templates/blog-tag-list.js" ) ;
8453
@@ -93,7 +62,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
9362 const ProgramPostTemplate = path . resolve ( "src/templates/program-single.js" ) ;
9463
9564 const MultiProgramPostTemplate = path . resolve (
96- "src/templates/program-multiple.js"
65+ "src/templates/program-multiple.js" ,
9766 ) ;
9867
9968 const CareerPostTemplate = path . resolve ( "src/templates/career-single.js" ) ;
@@ -108,7 +77,9 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
10877
10978 const resourcePostTemplate = path . resolve ( "src/templates/resource-single.js" ) ;
11079 const integrationTemplate = path . resolve ( "src/templates/integrations.js" ) ;
111- const LitePlaceholderTemplate = path . resolve ( "src/templates/lite-placeholder.js" ) ;
80+ const LitePlaceholderTemplate = path . resolve (
81+ "src/templates/lite-placeholder.js" ,
82+ ) ;
11283
11384 const memberBioQuery = isFullSiteBuild
11485 ? `
@@ -137,7 +108,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
137108
138109 const HandbookTemplate = path . resolve ( "src/templates/handbook-template.js" ) ;
139110
140-
141111 const res = await graphql ( `
142112 {
143113 allPosts: allMdx(filter: { frontmatter: { published: { eq: true } } }) {
@@ -277,6 +247,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
277247 } ;
278248
279249 const blogs = filterByCollection ( "blog" ) ;
250+
280251 const resources = filterByCollection ( "resources" ) ;
281252 const news = filterByCollection ( "news" ) ;
282253 const books = filterByCollection ( "service-mesh-books" ) ;
@@ -288,7 +259,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
288259
289260 const handbook = res . data . handbookPages . nodes ;
290261
291-
292262 const singleWorkshop = res . data . singleWorkshop . nodes ;
293263 const labs = res . data . labs . nodes ;
294264
@@ -460,7 +430,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
460430 } ) ;
461431 } ) ;
462432
463-
464433 programs . forEach ( ( program ) => {
465434 envCreatePage ( {
466435 path : `/programs/${ program . frontmatter . programSlug } ` ,
@@ -499,7 +468,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
499468 envCreatePage ( {
500469 ...page ,
501470 component : LitePlaceholderTemplate ,
502- } )
471+ } ) ,
503472 ) ;
504473
505474 const graphqlPlaceholderPages = [
@@ -566,19 +535,19 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
566535 sistentGroups . forEach ( ( group ) => {
567536 const componentName = group . fieldValue ;
568537 // content-learn uses different fields, sistent uses componentName.
569-
570- const availablePages = group . nodes . map ( node => node . fields . pageType ) ;
538+
539+ const availablePages = group . nodes . map ( ( node ) => node . fields . pageType ) ;
571540
572541 group . nodes . forEach ( ( node ) => {
573- createPage ( {
574- path : node . fields . slug ,
575- component : `${ sistentTemplate } ?__contentFilePath=${ node . internal . contentFilePath } ` ,
576- context : {
577- slug : node . fields . slug ,
578- componentName : componentName ,
579- availablePages : availablePages
580- }
581- } ) ;
542+ createPage ( {
543+ path : node . fields . slug ,
544+ component : `${ sistentTemplate } ?__contentFilePath=${ node . internal . contentFilePath } ` ,
545+ context : {
546+ slug : node . fields . slug ,
547+ componentName : componentName ,
548+ availablePages : availablePages ,
549+ } ,
550+ } ) ;
582551 } ) ;
583552 } ) ;
584553} ;
@@ -688,7 +657,7 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
688657 case "blog" :
689658 if ( node . frontmatter . published )
690659 slug = `/${ collection } /${ slugify (
691- node . frontmatter . category
660+ node . frontmatter . category ,
692661 ) } /${ slugify ( node . frontmatter . title ) } `;
693662 break ;
694663 case "news" :
@@ -702,7 +671,7 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
702671 case "resources" :
703672 if ( node . frontmatter . published )
704673 slug = `/${ collection } /${ slugify (
705- node . frontmatter . category
674+ node . frontmatter . category ,
706675 ) } /${ slugify ( node . frontmatter . title ) } `;
707676 break ;
708677 case "members" :
@@ -721,9 +690,9 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
721690 const componentSlug = parent . relativeDirectory . split ( "/" ) . pop ( ) ;
722691 const fileName = parent . name ;
723692 const suffix = fileName === "index" ? "" : `/${ fileName } ` ;
724-
693+
725694 slug = `/projects/sistent/components/${ componentSlug } ${ suffix } ` ;
726-
695+
727696 createNodeField ( {
728697 name : "componentName" ,
729698 node,
@@ -798,7 +767,7 @@ const createCoursesListPage = ({ envCreatePage, node }) => {
798767} ;
799768
800769const createCourseOverviewPage = ( { envCreatePage, node } ) => {
801- const { learnpath, slug, course, pageType, permalink, section } = node . fields ;
770+ const { learnpath, slug, course, pageType, permalink, section } = node . fields ;
802771
803772 envCreatePage ( {
804773 path : `${ slug } ` ,
@@ -862,11 +831,16 @@ exports.onCreateWebpackConfig = ({ actions, stage, getConfig }) => {
862831 } ) ;
863832
864833 // Reduce memory pressure by disabling sourcemaps in dev and build
865- if ( stage === "develop" || stage === "develop-html" || stage === "build-javascript" || stage === "build-html" ) {
834+ if (
835+ stage === "develop" ||
836+ stage === "develop-html" ||
837+ stage === "build-javascript" ||
838+ stage === "build-html"
839+ ) {
866840 const config = getConfig ( ) ;
867841 config . devtool = false ;
868842 const miniCssExtractPlugin = config . plugins . find (
869- ( plugin ) => plugin . constructor . name === "MiniCssExtractPlugin"
843+ ( plugin ) => plugin . constructor . name === "MiniCssExtractPlugin" ,
870844 ) ;
871845
872846 if ( miniCssExtractPlugin ) {
@@ -943,8 +917,6 @@ exports.createSchemaCustomization = ({ actions }) => {
943917 createTypes ( typeDefs ) ;
944918} ;
945919
946-
947-
948920exports . onPostBuild = async ( { graphql, reporter } ) => {
949921 const result = await graphql ( `
950922 {
@@ -973,4 +945,4 @@ exports.onPostBuild = async ({ graphql, reporter }) => {
973945 // Optionally, write the result to a file for easier inspection
974946 const outputPath = path . resolve ( __dirname , "public" , "query-result.json" ) ;
975947 fs . writeFileSync ( outputPath , JSON . stringify ( result , null , 2 ) ) ;
976- } ;
948+ } ;
0 commit comments