singleAuthorTemplate.js (2663B)
1 import React from 'react'; 2 import { Link } from 'gatsby'; 3 import Layout from '../components/layout'; 4 import SEO from '../components/seo'; 5 import { siteMetadata } from '../../gatsby-config'; 6 7 const { repo } = siteMetadata; 8 9 function SingleAuthorTemplate({ pageContext }) { 10 const { author, posts } = pageContext; 11 return ( 12 <Layout 13 heading={`Author: ${author} (${posts.length})`} 14 link={`/${repo}/authors`} 15 slug="authors" 16 > 17 <SEO title={`Author: ${author}`} /> 18 <div className="list-container"> 19 <ul className="list"> 20 {posts.map(post => { 21 const { 22 attributed, 23 author, 24 misattributed, 25 path, 26 title, 27 unverified, 28 } = post.frontmatter; 29 return ( 30 <li key={path} className="list-item"> 31 <article> 32 <div className="meta"> 33 <span> 34 <span className="screen-reader">Quote by </span> 35 <span> 36 <Link to={`/${repo}/authors/${author}`}>{author}</Link> 37 {attributed ? ( 38 <span> 39 <sup> 40 <em> 41 <abbr title="Attributed">!</abbr> 42 </em> 43 </sup> 44 </span> 45 ) : null} 46 {misattributed ? ( 47 <span> 48 <sup> 49 <em> 50 <abbr title="Misattributed">?</abbr> 51 </em> 52 </sup> 53 </span> 54 ) : null} 55 {unverified ? ( 56 <span> 57 <sup> 58 <em> 59 <abbr title="Unverified">#</abbr> 60 </em> 61 </sup> 62 </span> 63 ) : null} 64 </span> 65 </span> 66 </div> 67 <header className="list-item-header"> 68 <h3 className="list-item-title"> 69 <Link to={`/${repo}/quote${path}`}>{title}</Link> 70 </h3> 71 </header> 72 </article> 73 </li> 74 ); 75 })} 76 </ul> 77 </div> 78 </Layout> 79 ); 80 } 81 82 export default SingleAuthorTemplate;