diff --git a/gatsby-config.js b/gatsby-config.js index d058e69..0710001 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -7,6 +7,12 @@ module.exports = { plugins: [ 'gatsby-plugin-react-helmet', 'gatsby-plugin-sass', + { + resolve: 'gatsby-source-filesystem', + options: { + path: `${__dirname}/gatsby-config.js`, + }, + }, { resolve: 'gatsby-source-wordpress', options: { diff --git a/src/components/EventList.js b/src/components/EventList.js index 1030b25..ef0b2e9 100644 --- a/src/components/EventList.js +++ b/src/components/EventList.js @@ -25,38 +25,48 @@ const eventOrganizersQuery = graphql` ` const EventList = props => { const renderEvent = event => { + const featuredMedia = event.featured_media + const hasFeaturedMedia = featuredMedia && !!featuredMedia.localFile /* TODO: Make API return proper UTC datetimes */ - const startTimeNaive = event.start_time.replace("+00:00", "") - const utcOffset = 2; + const startTimeNaive = event.start_time.replace('+00:00', '') + const utcOffset = 2 const start = moment.utc(startTimeNaive).utcOffset(utcOffset) return ( -
- {event.featured_media && event.featured_media.localFile && ( - - )} -
+ {hasFeaturedMedia && ( + <> +
+ {event.featured_media && event.featured_media.localFile && ( + + )} + + {hasFeaturedMedia && featuredMedia.childImageSharp ? ( + + ) : ( + {featuredMedia.caption + )} +
+ + )}
- - {start.format('dddd')}{' '} - + {start.format('dddd')} - {start.format('D.')}{' '} - {start.format('MMMM')}{' '} + {start.format('D.')} {start.format('MMMM')}{' '} {/* Only specify year if different. */} {!start.isSame(new Date(), 'year') && ( - - {start.format('YYYY')}{' '} - + {start.format('YYYY')} )}

{event.title}

- - kl. {start.format('HH:mm')} - + kl. {start.format('HH:mm')} {event.event_types && event.event_types.length && (
    @@ -260,6 +270,7 @@ export const pageQuery = graphql` end_time featured_media { localFile { + publicURL ...FluidImage } } diff --git a/src/components/PostList.js b/src/components/PostList.js index 50ce3df..9273a05 100644 --- a/src/components/PostList.js +++ b/src/components/PostList.js @@ -31,7 +31,7 @@ export default class PostList extends React.Component { /> ) : ( {post.featured_media.caption )} @@ -95,6 +95,7 @@ export const pageQuery = graphql` date(formatString: "MMMM DD, YYYY") featured_media { localFile { + publicURL ...PostListImage } } diff --git a/src/templates/event.js b/src/templates/event.js index bc7ec65..e47bdea 100644 --- a/src/templates/event.js +++ b/src/templates/event.js @@ -138,7 +138,7 @@ export const EventTemplate = ({ ) : ( {featuredMedia.caption )} @@ -263,7 +263,7 @@ export const eventQuery = graphql` featured_media { caption localFile { - url + publicURL ...FluidImage } }