Add associations
This commit is contained in:
1 parent
47375e6400
commit
a2e5aa2e6f
6 files changed
+255
-8
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { graphql } from 'gatsby'
|
||||
import Layout from '../components/Layout'
|
||||
import AssociationList from '../components/AssociationList'
|
||||
|
||||
export default class AssociationListPage extends React.Component {
|
||||
render() {
|
||||
const { data } = this.props
|
||||
const { edges: associations } = data.allWordpressWpAssociations
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<AssociationList associations={associations} title="Foreninger" />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AssociationListPage.propTypes = {
|
||||
data: PropTypes.shape({
|
||||
allWordpressWpEvents: PropTypes.shape({
|
||||
edges: PropTypes.array,
|
||||
}),
|
||||
}),
|
||||
}
|
||||
|
||||
export const pageQuery = graphql`
|
||||
query {
|
||||
allWordpressWpAssociations(sort: { fields: title, order: ASC }) {
|
||||
edges {
|
||||
node {
|
||||
...AssociationListFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,80 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { graphql } from 'gatsby'
|
||||
import Layout from '../components/Layout'
|
||||
import Img from 'gatsby-image'
|
||||
|
||||
export const AssociationTemplate = data => {
|
||||
const {
|
||||
title,
|
||||
content,
|
||||
hasFeaturedMedia,
|
||||
featuredMedia,
|
||||
type,
|
||||
homepage,
|
||||
} = data
|
||||
return (
|
||||
<section className="association">
|
||||
<h1 className="section-title">{title}</h1>
|
||||
{hasFeaturedMedia && (
|
||||
<div className="assocation-logo">
|
||||
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
||||
</div>
|
||||
)}
|
||||
{homepage && (
|
||||
<div className="association-homepage">
|
||||
<a href="{{ homepage }}">Nettside</a>
|
||||
</div>
|
||||
)}
|
||||
<div className="association-type">Type: {type}</div>
|
||||
<div
|
||||
className="association-content"
|
||||
dangerouslySetInnerHTML={{ __html: content }}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
AssociationTemplate.propTypes = {
|
||||
title: PropTypes.string.isRequired,
|
||||
content: PropTypes.string,
|
||||
}
|
||||
|
||||
const Association = ({ data }) => {
|
||||
const { wordpressWpAssociations: association } = data
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<AssociationTemplate
|
||||
title={association.title}
|
||||
content={association.content}
|
||||
type={association.association_type}
|
||||
homepage={association.association_homepage}
|
||||
hasFeaturedMedia={!!association.featured_media.localFile}
|
||||
featuredMedia={association.featured_media}
|
||||
/>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
Association.propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
}
|
||||
|
||||
export default Association
|
||||
|
||||
export const associationQuery = graphql`
|
||||
query AssociationById($id: String!) {
|
||||
wordpressWpAssociations(id: { eq: $id }) {
|
||||
title
|
||||
content
|
||||
association_type
|
||||
association_homepage
|
||||
featured_media {
|
||||
localFile {
|
||||
...FluidImage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -94,9 +94,11 @@ export const EventTemplate = ({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="event-hero_image">
|
||||
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
||||
</div>
|
||||
{hasFeaturedMedia && (
|
||||
<div className="event-hero_image">
|
||||
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="event-body">
|
||||
<div dangerouslySetInnerHTML={{ __html: content }} />
|
||||
|
||||
Reference in new issue
Block a user