diff --git a/src/templates/LandingPage.js b/src/templates/LandingPage.js index 944cbc5..f5e5e13 100644 --- a/src/templates/LandingPage.js +++ b/src/templates/LandingPage.js @@ -1,14 +1,48 @@ 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, @@ -16,11 +50,24 @@ const LandingPage = ({ data, location }) => { ref: wrapperRef, } - const {pageTitle, pageKeywords, pageDescription } = seo || {} - return ( - + + + + {faqLd && ( + + )} + + {body?.length > 0 && navigation ? ( <> @@ -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, }), @@ -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 }