Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions src/templates/LandingPage.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,73 @@
import React, { useRef } from "react"
import { graphql } from "gatsby"
import PropTypes from "prop-types"
import { Helmet } from "react-helmet"
import Layout from "../components/layout"
import { CustomSection, Seo, Navigation } from "../components/index"
import PropTypes from "prop-types"


const LandingPage = ({ data, location }) => {
const { name, slug, parent_page, seo, body, navigation } =
data?.allStrapiLandingPage?.nodes[0] || {}

const wrapperRef = useRef(null)
const faqs = (body || [])
.filter(block => block.strapi_component === "components.banner-list")
.flatMap(block =>
(block.Card || [])
.filter(card => card.description && card.description.trim() !== "")
.map(({ id, title, description }) => ({
"@type": "Question",
name: title,
acceptedAnswer: {
"@type": "Answer",
text: description,
},
"@id": `#faq-${id}`,
}))
)

const pageLd = {
"@context": "https://schema.org",
"@type": "WebPage",
name: seo?.pageTitle || name,
description: seo?.pageDescription,
url: `https://en.bitlogic.io/${slug}`,
}

const faqLd =
faqs.length > 0
? {
"@context": "https://schema.org",
"@type": "FAQPage",
mainEntity: faqs,
}
: null

const landing = {
name,
slug,
parent_page,
ref: wrapperRef,
}

const {pageTitle, pageKeywords, pageDescription } = seo || {}

return (
<Layout location={location} options={{ hasHeader: true }}>
<Seo title={pageTitle} description={pageDescription} keywords={pageKeywords} location={location} />
<Seo
title={seo?.pageTitle || name}
description={seo?.pageDescription}
keywords={seo?.pageKeywords}
/>
<Helmet>
<script type="application/ld+json">
{JSON.stringify(pageLd)}
</script>
{faqLd && (
<script type="application/ld+json">
{JSON.stringify(faqLd)}
</script>
)}
</Helmet>

{body?.length > 0 && navigation ? (
<>
<CustomSection sections={body.slice(0, 1)} />
Expand Down Expand Up @@ -49,7 +96,7 @@ LandingPage.propTypes = {
name: PropTypes.string.isRequired,
body: PropTypes.arrayOf(PropTypes.object),
seo: PropTypes.shape({
pageTitle: PropTypes.string,
pageTitle: PropTypes.string.isRequired,
pageDescription: PropTypes.string.isRequired,
pageKeywords: PropTypes.string,
}),
Expand Down Expand Up @@ -234,14 +281,13 @@ export const query = graphql`
slug
}
}
arrayButtons {
content

english_landing_page {
id
slug
}
arrayButtons {
content
english_landing_page {
id
slug
}
}
backgroundImageDark {
url
}
Expand Down