Newer
Older
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import { Content, Button } from "@onegeo/gatsby-theme-onegeo"
import Component from "./section/component"
interface ISection {
id: string
}
directus {
sections {
id
title
subtitle
content
}
components {
components_id {
id
title
subtitle
content
url_dataviz
url_map
type
mapdid
layout
length
size
}
services {
services_id {
name
url
description
id
image {
imageFile {
publicURL
}
images {
directus_files_id {
imageFile {
childImageSharp {
gatsbyImageData
}
const sectionColumns = {
1: "lg:grid-cols-1",
2: "lg:grid-cols-2",
3: "lg:grid-cols-3",
}
const sectionSize = {
full: "max-w-full",
xl: "max-w-7xl",
lg: "max-w-4xl",
const Section = (props: ISection) => {
const { id } = props
const section = data.directus.sections.find((section) => section.id === id)
if (!section) return null
// Need style for custom color / classname at runtime
const ContentStyle = section.background
? { backgroundColor: section.background }
: undefined
<Content
className={"mb-20 " + sectionSize[section.size]}
style={ContentStyle}
>
{section.title && (
<h1 className="text-3xl font-extrabold">{section.title}</h1>
<h4 className="mt-2 text-2xl font-bold">{section.subtitle}</h4>
className="py-4 text-justify text-lg leading-8"
className={`grid grid-cols-1 ${
sectionColumns[section.components.length]
} gap-4`}
const dtComponent = component.components_id
return (
<React.Fragment key={dtComponent.id}>
<Component {...dtComponent} />
</React.Fragment>
)
})}
</div>
)}
<div className="mt-4 flex space-x-4">