@@ -8,6 +8,20 @@ exports.onCreateWebpackConfig = ({ actions }) => {
88 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 : / ,
99 } ) ,
1010 ] ,
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+
1125 } )
1226}
1327
@@ -19,9 +33,8 @@ exports.createSchemaCustomization = ({ actions }) => {
1933 const iconSchema = require ( "./src/schema/iconSchema" )
2034 const landingSchema = require ( "./src/schema/landingSchema" )
2135 const layoutSchema = require ( "./src/schema/layoutSchema" )
22- const generalSchema = require ( "./src/schema/generalSchema" )
2336 const professionalsSchema = require ( "./src/schema/professionalsSchema" )
24-
37+ const generalSchema = require ( "./src/schema/generalSchema" )
2538 const { createTypes } = actions
2639 const typeDefs =
2740 blogSchema . value +
@@ -33,15 +46,25 @@ exports.createSchemaCustomization = ({ actions }) => {
3346 layoutSchema . value +
3447 professionalsSchema . value +
3548 generalSchema . value
49+
50+ // Core type definitions from schema files
3651 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+ ` )
3760}
3861
39- exports . createPages = async ( { graphql, actions } ) => {
62+ exports . createPages = async ( { graphql, actions, reporter } ) => {
4063 const { createPage } = actions
4164
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+ {
4568 allStrapiArticle {
4669 nodes {
4770 slug
@@ -50,26 +73,24 @@ exports.createPages = async ({ graphql, actions }) => {
5073 }
5174 }
5275 ` )
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 )
5678 }
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 => {
6081 createPage ( {
61- path : " /blog/" + node . slug ,
62- component : BlogDetail ,
82+ path : ` /blog/${ node . slug } ` ,
83+ component : blogTemplate ,
6384 context : {
6485 slug : node . slug ,
6586 lastmod : node . updated_at ,
6687 } ,
6788 } )
6889 } )
6990
70- // CREACION DE LANDING PAGES
71- const { data : LandingQueryData } = await graphql ( `
72- query Landings {
91+ // 2) Landing pages
92+ const landingResult = await graphql ( `
93+ {
7394 allStrapiLandingPage {
7495 nodes {
7596 slug
@@ -81,38 +102,56 @@ exports.createPages = async ({ graphql, actions }) => {
81102 }
82103 }
83104 ` )
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 )
87107 }
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 => {
92111 if ( ! node ) return ""
93-
94112 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 } `
100115 }
101-
102116 return `/${ node . slug } `
103117 }
104-
105118 landings . forEach ( node => {
106- const LandingPage = path . resolve ( "./src/templates/LandingPage.js" )
107- const url = getUrl ( node )
108-
109119 createPage ( {
110- path : url ,
111- component : LandingPage ,
120+ path : buildLandingUrl ( node ) ,
121+ component : landingTemplate ,
112122 context : {
113123 slug : node . slug ,
114124 lastmod : node . updated_at ,
115125 } ,
116126 } )
117127 } )
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+ } )
118157}
0 commit comments