Add author credits to end of post

This commit is contained in:
Hippo 2019-09-23 17:30:03 +05:30
parent f8408cbcc3
commit f4955f77c1

View file

@ -1,6 +1,7 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { graphql } from 'gatsby' import { graphql } from 'gatsby'
import { Link } from 'gatsby'
import Helmet from 'react-helmet' import Helmet from 'react-helmet'
import { Layout } from '../components/common' import { Layout } from '../components/common'
@ -40,6 +41,15 @@ const Post = ({ data, location }) => {
className="content-body load-external-scripts" className="content-body load-external-scripts"
dangerouslySetInnerHTML={{ __html: post.html }} dangerouslySetInnerHTML={{ __html: post.html }}
/> />
<section className="content-footer">
<p>
Written by { post.authors.map((author, key) => ([
<Link to={`/author/${author.slug}`}>{ author.name }</Link>,
<span>{ key == post.authors.length-1 ? '' :
key == post.authors.length-2 ? ' and ' : ', ' }</span>
]))}
</p>
</section>
</section> </section>
</article> </article>
</div> </div>