Newer
Older
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import Component from "./section/component"
import Button from "./core/Button"
interface ISection {
id: string
}
const GRAPHQL_QUERY = graphql`
query {
directus {
sections {
id
title
subtitle
content
actions {
actions_id {
name
url
style
id
}
components {
components_id {
id
title
subtitle
content
url_dataviz
url_map
type
mapdid
layout
length
size
actions {
actions_id {
name
url
style
id
}
services {
services_id {
name
url
description
id
image {
imageFile {
publicURL
}
images {
directus_files_id {
imageFile {
childImageSharp {
gatsbyImageData
}
const Section = (props: ISection) => {
const { id } = props
const section = data.directus.sections.find((section) => section.id === id)
if (!section) return null
{section.title && (
<h1 className="text-3xl font-extrabold">{section.title}</h1>
{section.subtitle && (
<h4 className="text-2xl font-bold mt-2">{section.subtitle}</h4>
className={`grid grid-cols-1 lg:grid-cols-${section.components.length} gap-4`}
const dtComponent = component.components_id
return (
<React.Fragment key={dtComponent.id}>
<Component {...dtComponent} />
</React.Fragment>
)
})}
</div>
)}