quotes

My favourite quotes. (gatsbyjs)
git clone http://git.hanabi.in/repos/quotes.git
Log | Files | Refs | README | LICENSE

commit 9bfc1ba670a5a46ca5b0edd31dc733d4b093250a
parent c2fd6a18163ae942585db9dd73ff215d51ef0621
Author: Agastya Chandrakant <me@hanabi.in>
Date:   Wed, 11 Mar 2020 12:07:32 +0530

Support attributed and misattributed

Diffstat:
Msrc/pages/index.js | 26++++++++++++++++++++++++--
Msrc/pages/quote.js | 26++++++++++++++++++++++++--
Msrc/pages/random.js | 29+++++++++++++++++++++++++++--
Msrc/templates/singleAuthorTemplate.js | 30+++++++++++++++++++++++++++---
Msrc/templates/singleTagTemplate.js | 24++++++++++++++++++++++--
5 files changed, 124 insertions(+), 11 deletions(-)

diff --git a/src/pages/index.js b/src/pages/index.js @@ -6,7 +6,7 @@ import SEO from '../components/seo'; function IndexPage({ data }) { const { edges } = data.allMarkdownRemark; return ( - <Layout> + <Layout heading={`Quotes (${edges.length})`}> <SEO title="Home" /> <div className="home-sections-container"> <div className="home-sections"> @@ -17,7 +17,13 @@ function IndexPage({ data }) { <div className="list-container"> <ul className="list"> {edges.map(edge => { - const { author, path, title } = edge.node.frontmatter; + const { + author, + attributed, + misattributed, + path, + title, + } = edge.node.frontmatter; return ( <li className="list-item" key={path}> <article> @@ -26,6 +32,20 @@ function IndexPage({ data }) { <span className="screen-reader">Quote by </span> <span> <Link to={`/authors/${author}`}>{author}</Link> + {attributed ? ( + <span> + <sup> + <em>!</em> + </sup> + </span> + ) : null} + {misattributed ? ( + <span> + <sup> + <em>?</em> + </sup> + </span> + ) : null} </span> </span> </div> @@ -56,7 +76,9 @@ export const query = graphql` edges { node { frontmatter { + attributed author + misattributed path title } diff --git a/src/pages/quote.js b/src/pages/quote.js @@ -6,7 +6,7 @@ import SEO from '../components/seo'; function Blog({ data }) { const { edges } = data.allMarkdownRemark; return ( - <Layout heading="Quotes" slug="quote"> + <Layout heading={`Quotes (${edges.length})`} slug="quote"> <SEO title="Quotes" /> <div className="home-sections-container"> <div className="home-sections"> @@ -14,7 +14,13 @@ function Blog({ data }) { <div className="list-container"> <ul className="list"> {edges.map(edge => { - const { author, path, title } = edge.node.frontmatter; + const { + attributed, + author, + misattributed, + path, + title, + } = edge.node.frontmatter; return ( <li className="list-item" key={path}> <article> @@ -22,6 +28,20 @@ function Blog({ data }) { <span> <span className="screen-reader">Quote by </span> <Link to={`/authors/${author}`}>{author}</Link> + {attributed ? ( + <span> + <sup> + <em>!</em> + </sup> + </span> + ) : null} + {misattributed ? ( + <span> + <sup> + <em>?</em> + </sup> + </span> + ) : null} </span> </div> <header className="list-item-header"> @@ -51,7 +71,9 @@ export const query = graphql` edges { node { frontmatter { + attributed author + misattributed path title } diff --git a/src/pages/random.js b/src/pages/random.js @@ -6,7 +6,9 @@ import SEO from '../components/seo'; function RandomQuotePage({ data }) { const { edges } = data.allMarkdownRemark; const rnd = Math.floor(Math.random() * edges.length); - const { author, path, title } = edges[rnd].node.frontmatter; + const { attributed, author, misattributed, path, title, where } = edges[ + rnd + ].node.frontmatter; return ( <Layout> @@ -30,7 +32,27 @@ function RandomQuotePage({ data }) { <span> <span className="screen-reader">Quote by </span> <span className="author-container"> - <Link to={`/author/${author}`}>{author}</Link> + <Link + className="author-container-link" + to={`/author/${author}`} + > + {author} + </Link> + {attributed ? ( + <span> + <sup> + <em>!</em> + </sup> + </span> + ) : null} + {misattributed ? ( + <span> + <sup> + <em>?</em> + </sup> + </span> + ) : null} + {where ? <span>, {where}</span> : null} </span> </span> </div> @@ -54,9 +76,12 @@ export const query = graphql` edges { node { frontmatter { + attributed author + misattributed path title + where } } } diff --git a/src/templates/singleAuthorTemplate.js b/src/templates/singleAuthorTemplate.js @@ -4,14 +4,24 @@ import Layout from '../components/layout'; import SEO from '../components/seo'; function SingleAuthorTemplate({ pageContext }) { - const { posts, author } = pageContext; + const { author, posts } = pageContext; return ( - <Layout heading={`Author: ${author}`} link="/authors" slug="authors"> + <Layout + heading={`Author: ${author} (${posts.length})`} + link="/authors" + slug="authors" + > <SEO title={`Author: ${author}`} /> <div className="list-container"> <ul className="list"> {posts.map(post => { - const { author, path, title } = post.frontmatter; + const { + attributed, + author, + misattributed, + path, + title, + } = post.frontmatter; return ( <li key={path} className="list-item"> <article> @@ -20,6 +30,20 @@ function SingleAuthorTemplate({ pageContext }) { <span className="screen-reader">Quote by </span> <span> <Link to={`/authors/${author}`}>{author}</Link> + {attributed ? ( + <span> + <sup> + <em>!</em> + </sup> + </span> + ) : null} + {misattributed ? ( + <span> + <sup> + <em>?</em> + </sup> + </span> + ) : null} </span> </span> </div> diff --git a/src/templates/singleTagTemplate.js b/src/templates/singleTagTemplate.js @@ -6,12 +6,18 @@ import SEO from '../components/seo'; function SingleTagTemplate({ pageContext }) { const { posts, tag } = pageContext; return ( - <Layout heading={`Tag: ${tag}`} link="/tags" slug="tag"> + <Layout heading={`Tag: ${tag} (${posts.length})`} link="/tags" slug="tag"> <SEO title={`Tag: ${tag}`} /> <div className="list-container"> <ul className="list"> {posts.map(post => { - const { author, path, title } = post.frontmatter; + const { + attributed, + author, + misattributed, + path, + title, + } = post.frontmatter; return ( <li key={path} className="list-item"> <article> @@ -20,6 +26,20 @@ function SingleTagTemplate({ pageContext }) { <span className="screen-reader">Quote by </span> <span> <Link to={`/authors/${author}`}>{author}</Link> + {attributed ? ( + <span> + <sup> + <em>!</em> + </sup> + </span> + ) : null} + {misattributed ? ( + <span> + <sup> + <em>?</em> + </sup> + </span> + ) : null} </span> </span> </div>