Skip to content

Commit 59af6e5

Browse files
Merge pull request #138 from bitlogic/fix/SBIT-cambios-del-FAQ
Fix/sbit cambios del faq
2 parents 65f591a + 9ca9ec9 commit 59af6e5

File tree

1 file changed

+59
-13
lines changed

1 file changed

+59
-13
lines changed

src/templates/LandingPage.js

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,73 @@
11
import React, { useRef } from "react"
22
import { graphql } from "gatsby"
3+
import PropTypes from "prop-types"
4+
import { Helmet } from "react-helmet"
35
import Layout from "../components/layout"
46
import { CustomSection, Seo, Navigation } from "../components/index"
5-
import PropTypes from "prop-types"
7+
68

79
const LandingPage = ({ data, location }) => {
810
const { name, slug, parent_page, seo, body, navigation } =
911
data?.allStrapiLandingPage?.nodes[0] || {}
10-
1112
const wrapperRef = useRef(null)
13+
const faqs = (body || [])
14+
.filter(block => block.strapi_component === "components.banner-list")
15+
.flatMap(block =>
16+
(block.Card || [])
17+
.filter(card => card.description && card.description.trim() !== "")
18+
.map(({ id, title, description }) => ({
19+
"@type": "Question",
20+
name: title,
21+
acceptedAnswer: {
22+
"@type": "Answer",
23+
text: description,
24+
},
25+
"@id": `#faq-${id}`,
26+
}))
27+
)
28+
29+
const pageLd = {
30+
"@context": "https://schema.org",
31+
"@type": "WebPage",
32+
name: seo?.pageTitle || name,
33+
description: seo?.pageDescription,
34+
url: `https://en.bitlogic.io/${slug}`,
35+
}
36+
37+
const faqLd =
38+
faqs.length > 0
39+
? {
40+
"@context": "https://schema.org",
41+
"@type": "FAQPage",
42+
mainEntity: faqs,
43+
}
44+
: null
45+
1246
const landing = {
1347
name,
1448
slug,
1549
parent_page,
1650
ref: wrapperRef,
1751
}
1852

19-
const {pageTitle, pageKeywords, pageDescription } = seo || {}
20-
2153
return (
2254
<Layout location={location} options={{ hasHeader: true }}>
23-
<Seo title={pageTitle} description={pageDescription} keywords={pageKeywords} location={location} />
55+
<Seo
56+
title={seo?.pageTitle || name}
57+
description={seo?.pageDescription}
58+
keywords={seo?.pageKeywords}
59+
/>
60+
<Helmet>
61+
<script type="application/ld+json">
62+
{JSON.stringify(pageLd)}
63+
</script>
64+
{faqLd && (
65+
<script type="application/ld+json">
66+
{JSON.stringify(faqLd)}
67+
</script>
68+
)}
69+
</Helmet>
70+
2471
{body?.length > 0 && navigation ? (
2572
<>
2673
<CustomSection sections={body.slice(0, 1)} />
@@ -49,7 +96,7 @@ LandingPage.propTypes = {
4996
name: PropTypes.string.isRequired,
5097
body: PropTypes.arrayOf(PropTypes.object),
5198
seo: PropTypes.shape({
52-
pageTitle: PropTypes.string,
99+
pageTitle: PropTypes.string.isRequired,
53100
pageDescription: PropTypes.string.isRequired,
54101
pageKeywords: PropTypes.string,
55102
}),
@@ -234,14 +281,13 @@ export const query = graphql`
234281
slug
235282
}
236283
}
237-
arrayButtons {
238-
content
239-
240-
english_landing_page {
241-
id
242-
slug
243-
}
284+
arrayButtons {
285+
content
286+
english_landing_page {
287+
id
288+
slug
244289
}
290+
}
245291
backgroundImageDark {
246292
url
247293
}

0 commit comments

Comments
 (0)