From 6e0f8f2783cd1fb588bf680c72fee1371c802a3c Mon Sep 17 00:00:00 2001 From: ekachxaidze98 <65679299+ekachxaidze98@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:32:31 +0400 Subject: [PATCH] CORE-4674: faq to netlify (#1052) (#1053) --- design-v2/benefits/index.jsx | 8 +++----- pages/benefits.jsx | 27 ++++++++++++++++++++++++-- pages/faq.jsx | 37 ++++++++++++++++++++++++++---------- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/design-v2/benefits/index.jsx b/design-v2/benefits/index.jsx index 7a346b4a8..762516bee 100644 --- a/design-v2/benefits/index.jsx +++ b/design-v2/benefits/index.jsx @@ -9,7 +9,6 @@ import { Layout, Section } from '../components' // TODO: REPLACE OLD COMPONENT import { Accordion, Content, Markdown } from 'components' import benefitsData from 'data/benefits.yml' -import faqData from 'data/faq.yml' import { patchStats } from 'components/utils' const itemToURL = (id) => { @@ -50,16 +49,15 @@ const JoinSectionItem = ({ title, picture, description, additional }) => { ) } -const BenefitsPageTemplate = () => { +const BenefitsPageTemplate = ({ data }) => { const [showAll, setShowAll] = useState(false) - const toggleShowAll = () => { setShowAll((prev) => !prev) } const itemsToShow = showAll - ? faqData.sections[0].items - : faqData.sections[0].items.slice(0, 3) + ? data.faqs.sections[0].items + : data.faqs.sections[0].items.slice(0, 3) return ( diff --git a/pages/benefits.jsx b/pages/benefits.jsx index c2debc27c..e48df3a09 100644 --- a/pages/benefits.jsx +++ b/pages/benefits.jsx @@ -1,17 +1,40 @@ import React from 'react' import BenefitsPageTemplate from '../design-v2/benefits' +import retrieveContent from '../content' import { Page } from 'components' import benefitsData from 'data/benefits.yml' -const benefitsPage = () => ( +const getSections = async ({ ref } = {}) => { + const content = await retrieveContent('faqs', { + ref, + transform: 'object', + }) + return content +} + +export async function getStaticProps({ previewData }) { + const ref = previewData?.ref + const sections = await getSections({ ref }) + const data = { + ...sections, + } + + return { + props: { + data, + }, + } +} + +const benefitsPage = ({ data }) => ( - + ) diff --git a/pages/faq.jsx b/pages/faq.jsx index 7d985c6af..e3a5366d7 100644 --- a/pages/faq.jsx +++ b/pages/faq.jsx @@ -3,9 +3,9 @@ import { classNames } from '@oacore/design/lib/utils' import { useRouter } from 'next/router' import styles from './index.module.scss' +import retrieveContent from '../content' import { Accordion, Content, Markdown, Page, Section } from 'components' -import faqData from 'data/faq.yml' const itemToURL = (id) => { const url = new URL(window.location) @@ -111,15 +111,32 @@ const FAQsSection = ({ ) } -const FAQsPage = () => ( - -

{faqData.title}

- {faqData.sections.map((section) => ( +const getSections = async ({ ref } = {}) => { + const content = await retrieveContent('faqs', { + ref, + transform: 'object', + }) + return content +} + +export async function getStaticProps({ previewData }) { + const ref = previewData?.ref + const sections = await getSections({ ref }) + const data = { + ...sections, + } + + return { + props: { + data, + }, + } +} + +const FAQsPage = ({ data }) => ( + +

{data.faqs.title}

+ {data.faqs.sections.map((section) => ( ))}