@@ -8,6 +8,20 @@ exports.onCreateWebpackConfig = ({ actions }) => {
8
8
exclude : / m i n i - c s s - e x t r a c t - p l u g i n [ ^ ] * C o n f l i c t i n g o r d e r . F o l l o w i n g m o d u l e h a s b e e n a d d e d : / ,
9
9
} ) ,
10
10
] ,
11
+
12
+ resolve : {
13
+ extensions : [ '.mjs' , '.js' ] ,
14
+ } ,
15
+ module : {
16
+ rules : [
17
+ {
18
+ test : / \. m j s $ / ,
19
+ include : / n o d e _ m o d u l e s / ,
20
+ type : 'javascript/auto' ,
21
+ } ,
22
+ ] ,
23
+ } ,
24
+
11
25
} )
12
26
}
13
27
@@ -19,9 +33,8 @@ exports.createSchemaCustomization = ({ actions }) => {
19
33
const iconSchema = require ( "./src/schema/iconSchema" )
20
34
const landingSchema = require ( "./src/schema/landingSchema" )
21
35
const layoutSchema = require ( "./src/schema/layoutSchema" )
22
- const generalSchema = require ( "./src/schema/generalSchema" )
23
36
const professionalsSchema = require ( "./src/schema/professionalsSchema" )
24
-
37
+ const generalSchema = require ( "./src/schema/generalSchema" )
25
38
const { createTypes } = actions
26
39
const typeDefs =
27
40
blogSchema . value +
@@ -33,15 +46,25 @@ exports.createSchemaCustomization = ({ actions }) => {
33
46
layoutSchema . value +
34
47
professionalsSchema . value +
35
48
generalSchema . value
49
+
50
+ // Core type definitions from schema files
36
51
createTypes ( typeDefs )
52
+
53
+ // POSTER
54
+ createTypes ( `
55
+ type ComponentVideoBackground implements Node {
56
+ poster: File @link(from: "poster.localFile")
57
+ video: File @link(from: "video.localFile")
58
+ }
59
+ ` )
37
60
}
38
61
39
- exports . createPages = async ( { graphql, actions } ) => {
62
+ exports . createPages = async ( { graphql, actions, reporter } ) => {
40
63
const { createPage } = actions
41
64
42
- // CREACION DE PAGINAS DE BLOG
43
- const { data : blogQueryData } = await graphql ( `
44
- query Articles {
65
+ // 1) Blog detail pages
66
+ const blogResult = await graphql ( `
67
+ {
45
68
allStrapiArticle {
46
69
nodes {
47
70
slug
@@ -50,26 +73,24 @@ exports.createPages = async ({ graphql, actions }) => {
50
73
}
51
74
}
52
75
` )
53
-
54
- if ( blogQueryData . errors ) {
55
- reporter . panicOnBuild ( "Error creando paginas de blog" )
76
+ if ( blogResult . errors ) {
77
+ reporter . panicOnBuild ( "Error creating blog detail pages" , blogResult . errors )
56
78
}
57
-
58
- blogQueryData . allStrapiArticle . nodes . forEach ( node => {
59
- const BlogDetail = path . resolve ( "./src/templates/BlogItemDetail.js" )
79
+ const blogTemplate = path . resolve ( "./src/templates/BlogItemDetail.js" )
80
+ blogResult . data . allStrapiArticle . nodes . forEach ( node => {
60
81
createPage ( {
61
- path : " /blog/" + node . slug ,
62
- component : BlogDetail ,
82
+ path : ` /blog/${ node . slug } ` ,
83
+ component : blogTemplate ,
63
84
context : {
64
85
slug : node . slug ,
65
86
lastmod : node . updated_at ,
66
87
} ,
67
88
} )
68
89
} )
69
90
70
- // CREACION DE LANDING PAGES
71
- const { data : LandingQueryData } = await graphql ( `
72
- query Landings {
91
+ // 2) Landing pages
92
+ const landingResult = await graphql ( `
93
+ {
73
94
allStrapiLandingPage {
74
95
nodes {
75
96
slug
@@ -81,38 +102,56 @@ exports.createPages = async ({ graphql, actions }) => {
81
102
}
82
103
}
83
104
` )
84
-
85
- if ( LandingQueryData . errors ) {
86
- reporter . panicOnBuild ( "Error creando paginas de landing" )
105
+ if ( landingResult . errors ) {
106
+ reporter . panicOnBuild ( "Error creating landing pages" , landingResult . errors )
87
107
}
88
-
89
- const landings = LandingQueryData . allStrapiLandingPage . nodes
90
-
91
- function getUrl ( node ) {
108
+ const landings = landingResult . data . allStrapiLandingPage . nodes
109
+ const landingTemplate = path . resolve ( "./src/templates/LandingPage.js" )
110
+ const buildLandingUrl = node => {
92
111
if ( ! node ) return ""
93
-
94
112
if ( node . parent_page ) {
95
- const parentPage = landings . find (
96
- landing => landing . slug === node . parent_page . slug
97
- )
98
- const parentUrl = getUrl ( parentPage )
99
- return `${ parentUrl } /${ node . slug } `
113
+ const parent = landings . find ( l => l . slug === node . parent_page . slug )
114
+ return buildLandingUrl ( parent ) + `/${ node . slug } `
100
115
}
101
-
102
116
return `/${ node . slug } `
103
117
}
104
-
105
118
landings . forEach ( node => {
106
- const LandingPage = path . resolve ( "./src/templates/LandingPage.js" )
107
- const url = getUrl ( node )
108
-
109
119
createPage ( {
110
- path : url ,
111
- component : LandingPage ,
120
+ path : buildLandingUrl ( node ) ,
121
+ component : landingTemplate ,
112
122
context : {
113
123
slug : node . slug ,
114
124
lastmod : node . updated_at ,
115
125
} ,
116
126
} )
117
127
} )
128
+
129
+ // 3) Category pages
130
+ const categoryResult = await graphql ( `
131
+ {
132
+ allStrapiBlogCategory {
133
+ nodes {
134
+ name
135
+ slug
136
+ }
137
+ }
138
+ }
139
+ ` )
140
+ if ( categoryResult . errors ) {
141
+ reporter . panicOnBuild (
142
+ "Error creating category pages" ,
143
+ categoryResult . errors
144
+ )
145
+ }
146
+ const categoryTemplate = path . resolve ( "./src/templates/CategoryPage.js" )
147
+ categoryResult . data . allStrapiBlogCategory . nodes . forEach ( category => {
148
+ const slugLower = category . slug . toLowerCase ( )
149
+ createPage ( {
150
+ path : `/blog/${ slugLower } ` ,
151
+ component : categoryTemplate ,
152
+ context : {
153
+ name : category . name ,
154
+ } ,
155
+ } )
156
+ } )
118
157
}
0 commit comments