Real post images on front page
This commit is contained in:
1 parent
5b7be71210
commit
fd6f93660e
1 file changed
+13
-4
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Link, graphql } from 'gatsby'
|
import { Link, graphql } from 'gatsby'
|
||||||
|
import Img from 'gatsby-image'
|
||||||
|
|
||||||
export default class PostList extends React.Component {
|
export default class PostList extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
@@ -12,10 +13,13 @@ export default class PostList extends React.Component {
|
|||||||
<div className="post-list">
|
<div className="post-list">
|
||||||
{posts.map(({ node: post }) => (
|
{posts.map(({ node: post }) => (
|
||||||
<Link to={post.fields.link} className="post" key={post.id}>
|
<Link to={post.fields.link} className="post" key={post.id}>
|
||||||
<img
|
{post.featured_media && post.featured_media.localFile && (
|
||||||
className="post-image"
|
<div className="post-image">
|
||||||
src="https://studentersamfundet.no/wp-content/uploads/2018/10/Fjor%C3%A5rets-festival_Fotograf-Karin-Kaczykowski-i-Studentenes-Fotoklubb-1280x720.jpg"
|
<Img
|
||||||
/>
|
fluid={post.featured_media.localFile.childImageSharp.fluid}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="post-text">
|
<div className="post-text">
|
||||||
<header className="post-header">
|
<header className="post-header">
|
||||||
<h2 className="post-title">{post.title}</h2>
|
<h2 className="post-title">{post.title}</h2>
|
||||||
@@ -58,5 +62,10 @@ export const pageQuery = graphql`
|
|||||||
fields {
|
fields {
|
||||||
link
|
link
|
||||||
}
|
}
|
||||||
|
featured_media {
|
||||||
|
localFile {
|
||||||
|
...FluidImage
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
Reference in new issue
Block a user