Improve handling of image types not supported by gatsby-transformer-sharp
This commit is contained in:
1 parent
a66154dcc8
commit
b16eb165a4
4 files changed
+39
-21
No files matched your search
@@ -7,6 +7,12 @@ module.exports = {
|
|||||||
plugins: [
|
plugins: [
|
||||||
'gatsby-plugin-react-helmet',
|
'gatsby-plugin-react-helmet',
|
||||||
'gatsby-plugin-sass',
|
'gatsby-plugin-sass',
|
||||||
|
{
|
||||||
|
resolve: 'gatsby-source-filesystem',
|
||||||
|
options: {
|
||||||
|
path: `${__dirname}/gatsby-config.js`,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
resolve: 'gatsby-source-wordpress',
|
resolve: 'gatsby-source-wordpress',
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
+29
-18
@@ -25,38 +25,48 @@ const eventOrganizersQuery = graphql`
|
|||||||
`
|
`
|
||||||
const EventList = props => {
|
const EventList = props => {
|
||||||
const renderEvent = event => {
|
const renderEvent = event => {
|
||||||
|
const featuredMedia = event.featured_media
|
||||||
|
const hasFeaturedMedia = featuredMedia && !!featuredMedia.localFile
|
||||||
/* TODO: Make API return proper UTC datetimes */
|
/* TODO: Make API return proper UTC datetimes */
|
||||||
const startTimeNaive = event.start_time.replace("+00:00", "")
|
const startTimeNaive = event.start_time.replace('+00:00', '')
|
||||||
const utcOffset = 2;
|
const utcOffset = 2
|
||||||
const start = moment.utc(startTimeNaive).utcOffset(utcOffset)
|
const start = moment.utc(startTimeNaive).utcOffset(utcOffset)
|
||||||
return (
|
return (
|
||||||
<Link to={event.path} className="event" key={event.id}>
|
<Link to={event.path} className="event" key={event.id}>
|
||||||
<div className="event-image">
|
{hasFeaturedMedia && (
|
||||||
{event.featured_media && event.featured_media.localFile && (
|
<>
|
||||||
<Img fluid={event.featured_media.localFile.childImageSharp.fluid} />
|
<div className="event-image">
|
||||||
)}
|
{event.featured_media && event.featured_media.localFile && (
|
||||||
</div>
|
<Img
|
||||||
|
fluid={event.featured_media.localFile.childImageSharp.fluid}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{hasFeaturedMedia && featuredMedia.childImageSharp ? (
|
||||||
|
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
src={featuredMedia.localFile.publicURL}
|
||||||
|
alt={featuredMedia.caption || ''}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<header className="event-header">
|
<header className="event-header">
|
||||||
<span className="event-date">
|
<span className="event-date">
|
||||||
<span className="event-date-weekday">
|
<span className="event-date-weekday">{start.format('dddd')} </span>
|
||||||
{start.format('dddd')}{' '}
|
|
||||||
</span>
|
|
||||||
<span className="event-date-day-month">
|
<span className="event-date-day-month">
|
||||||
{start.format('D.')}{' '}
|
{start.format('D.')} {start.format('MMMM')}{' '}
|
||||||
{start.format('MMMM')}{' '}
|
|
||||||
</span>
|
</span>
|
||||||
{/* Only specify year if different. */}
|
{/* Only specify year if different. */}
|
||||||
{!start.isSame(new Date(), 'year') && (
|
{!start.isSame(new Date(), 'year') && (
|
||||||
<span className="event-date-year">
|
<span className="event-date-year">{start.format('YYYY')} </span>
|
||||||
{start.format('YYYY')}{' '}
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<h2 className="event-title">{event.title}</h2>
|
<h2 className="event-title">{event.title}</h2>
|
||||||
<div className="event-meta">
|
<div className="event-meta">
|
||||||
<span className="event-start">
|
<span className="event-start">kl. {start.format('HH:mm')}</span>
|
||||||
kl. {start.format('HH:mm')}
|
|
||||||
</span>
|
|
||||||
{event.event_types && event.event_types.length && (
|
{event.event_types && event.event_types.length && (
|
||||||
<div className="event-types">
|
<div className="event-types">
|
||||||
<ul>
|
<ul>
|
||||||
@@ -260,6 +270,7 @@ export const pageQuery = graphql`
|
|||||||
end_time
|
end_time
|
||||||
featured_media {
|
featured_media {
|
||||||
localFile {
|
localFile {
|
||||||
|
publicURL
|
||||||
...FluidImage
|
...FluidImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default class PostList extends React.Component {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
src={post.featured_media.localFile.url}
|
src={post.featured_media.localFile.publicUrl}
|
||||||
alt={post.featured_media.caption || ''}
|
alt={post.featured_media.caption || ''}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -95,6 +95,7 @@ export const pageQuery = graphql`
|
|||||||
date(formatString: "MMMM DD, YYYY")
|
date(formatString: "MMMM DD, YYYY")
|
||||||
featured_media {
|
featured_media {
|
||||||
localFile {
|
localFile {
|
||||||
|
publicURL
|
||||||
...PostListImage
|
...PostListImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export const EventTemplate = ({
|
|||||||
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
<Img fluid={featuredMedia.localFile.childImageSharp.fluid} />
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
src={featuredMedia.localFile.url}
|
src={featuredMedia.localFile.publicURL}
|
||||||
alt={featuredMedia.caption || ''}
|
alt={featuredMedia.caption || ''}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -263,7 +263,7 @@ export const eventQuery = graphql`
|
|||||||
featured_media {
|
featured_media {
|
||||||
caption
|
caption
|
||||||
localFile {
|
localFile {
|
||||||
url
|
publicURL
|
||||||
...FluidImage
|
...FluidImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user