Skip to content

Commit 1e342df

Browse files
Merge pull request #349 from bitlogic/dev
Merge dev to main
2 parents 6072c13 + de43384 commit 1e342df

File tree

22 files changed

+7355
-2566
lines changed

22 files changed

+7355
-2566
lines changed

gatsby-config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
module.exports = {
24
trailingSlash: "always",
35
siteMetadata: {
@@ -169,4 +171,4 @@ module.exports = {
169171
"gatsby-plugin-webpack-bundle-analyser-v2",
170172
"gatsby-plugin-react-helmet"
171173
],
172-
}
174+
}

gatsby-node.js

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ exports.onCreateWebpackConfig = ({ actions }) => {
88
exclude: /mini-css-extract-plugin[^]*Conflicting order. Following module has been added:/,
99
}),
1010
],
11+
12+
resolve: {
13+
extensions: ['.mjs', '.js'],
14+
},
15+
module: {
16+
rules: [
17+
{
18+
test: /\.mjs$/,
19+
include: /node_modules/,
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
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"react-dom": "^17.0.1",
3838
"react-flip-toolkit": "^7.0.13",
3939
"react-helmet": "^6.1.0",
40-
"react-icons": "^4.2.0",
40+
"react-icons": "^2.2.7",
4141
"react-lottie": "1.2.4",
4242
"react-multi-carousel": "^2.8.0",
4343
"react-showdown": "^2.3.1",

src/components/BannerRedirect/BannerRedirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect } from "react"
22
import "./BannerRedirect.scss"
3-
import { MdClose } from "react-icons/md"
3+
import MdClose from "react-icons/lib/md/close"
44

55
function BannerRedirect() {
66
const [isOpen, setIsOpen] = useState(true)
Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,66 @@
11
import React from "react"
22
import { Link } from "gatsby"
3-
// import ReactMarkdown from "react-markdown"
43
import MarkdownView from "react-showdown"
5-
import "./BlogArticle.scss"
64
import PropTypes from "prop-types"
75
import CustomImage from "../../CustomImage/CustomImage"
6+
import "./BlogArticle.scss"
7+
8+
const BlogArticle = ({
9+
title,
10+
summary,
11+
image,
12+
slug,
13+
text,
14+
destacado = false,
15+
}) => (
16+
<div
17+
className={`article__container${destacado ? ' article--destacado' : ''}`}
18+
data-nosnippet
19+
>
20+
{destacado && (
21+
<span className="article__badge">Destacado</span>
22+
)}
823

9-
const BlogArticle = ({ title, summary, image, slug, text }) => {
10-
11-
return (
12-
<div className="article__container" data-nosnippet>
13-
<CustomImage image={image}
14-
alt={image?.alternativeText || title}
15-
className="article__image"
16-
width={140}
17-
height={170}
18-
/>
19-
<div className="article__description">
20-
<h4>{title}</h4>
21-
<MarkdownView markdown={`${summary}`}
24+
<CustomImage
25+
image={image}
26+
alt={image?.alternativeText || title}
27+
className="article__image"
28+
width={140}
29+
height={170}
30+
/>
31+
32+
<div className="article__description">
33+
<h4 className="article__title">{title}</h4>
34+
<MarkdownView markdown={`${summary}`}
2235
dangerouslySetInnerHTML={{ __html: summary }}
2336
/>
24-
<div className="article__link">
25-
<Link to={slug}>
26-
<small>{text || 'Ver más'}</small>
27-
</Link>
28-
</div>
37+
<div className="article__link">
38+
<Link to={slug}>
39+
<small>{text || 'Ver más'}</small>
40+
</Link>
2941
</div>
3042
</div>
31-
)
32-
}
43+
</div>
44+
)
3345

3446
BlogArticle.propTypes = {
3547
title: PropTypes.string.isRequired,
36-
slug: PropTypes.string.isRequired,
3748
summary: PropTypes.string.isRequired,
38-
text: PropTypes.string,
3949
image: PropTypes.shape({
4050
alternativeText: PropTypes.string,
4151
url: PropTypes.string,
4252
localFile: PropTypes.shape({
4353
childImageSharp: PropTypes.shape({
44-
gatsbyImageData: PropTypes.object.isRequired
45-
})
46-
})
47-
}).isRequired
48-
};
54+
gatsbyImageData: PropTypes.object.isRequired,
55+
}),
56+
}),
57+
}).isRequired,
58+
slug: PropTypes.string.isRequired,
59+
text: PropTypes.string,
60+
destacado: PropTypes.bool,
61+
}
4962

5063
export default BlogArticle;
5164

65+
66+

src/components/BlogPage/BlogArticle/BlogArticle.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@
109109
}
110110
}
111111
}
112-
}
112+
}

0 commit comments

Comments
 (0)