diff --git a/src/components/atoms/PostContent.jsx b/src/components/atoms/PostContent.jsx new file mode 100644 index 00000000..79583196 --- /dev/null +++ b/src/components/atoms/PostContent.jsx @@ -0,0 +1,33 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './PostContent.module.scss' + +// Remove lead paragraph from content +const PostContent = ({ post }) => { + let content + const separator = '' + + content = post.html + + if (post.frontmatter.type === 'post') { + if (content.includes(separator)) { + content = content.split(separator)[1] + } else { + const lead = content.split('\n')[0] + content = content.replace(lead, '') + } + } + + return ( +
+ ) +} + +PostContent.propTypes = { + post: PropTypes.object +} + +export default PostContent diff --git a/src/components/atoms/PostContent.module.scss b/src/components/atoms/PostContent.module.scss new file mode 100644 index 00000000..0650a6fd --- /dev/null +++ b/src/components/atoms/PostContent.module.scss @@ -0,0 +1,98 @@ +@import 'variables'; +@import 'mixins'; + +.content { + h1, + h2 { + @include heading-band(); + } + + h1 { + font-size: $font-size-h2; + } + + h2 { + font-size: $font-size-h3; + } + + h3 { + font-size: $font-size-h4; + } + + h4 { + font-size: $font-size-h5; + } + + p:last-child { + margin-bottom: 0; + } + + .gatsby-resp-image-figure, + .gatsby-resp-image-wrapper { + margin-bottom: $spacer; + } + + figcaption { + font-size: $font-size-small; + color: $brand-grey; + font-style: italic; + text-align: center; + margin-top: -$spacer / 2; + } + + .anchor { + margin-top: $spacer / 3; + } + + // Quotes + ///////////////////////////////////// + + q { + font-style: italic; + } + + cite { + font-style: normal; + text-transform: uppercase; + } + + // stylelint-disable no-descending-specificity + blockquote, + blockquote > p { + font-style: italic; + color: $brand-grey-light; + } + // stylelint-enable no-descending-specificity + + blockquote { + margin: 0 0 $spacer; + position: relative; + padding-left: 20px; + + @media (min-width: $screen-xs) { + padding-left: 40px; + } + + @media (min-width: $screen-lg) { + padding-left: 60px; + } + + // quotation marks + &::before { + content: '“'; + font-size: 300%; + color: lighten($brand-grey-light, 20%); + position: absolute; + left: -10px; + top: -20px; + + @media (min-width: $screen-xs) { + left: 0; + } + + @media (min-width: $screen-lg) { + top: -30px; + } + } + } +} diff --git a/src/components/atoms/PostLead.jsx b/src/components/atoms/PostLead.jsx new file mode 100644 index 00000000..dfc18ec1 --- /dev/null +++ b/src/components/atoms/PostLead.jsx @@ -0,0 +1,31 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './PostLead.module.scss' + +// Extract lead paragraph from content +// Grab everything before more tag, or just first paragraph +const PostLead = ({ post }) => { + let lead + const content = post.html + const separator = '' + + if (post.frontmatter.type === 'post') { + if (content.includes(separator)) { + lead = content.split(separator)[0] + } else { + lead = content.split('\n')[0] + } + } else { + return null + } + + return ( +
+ ) +} + +PostLead.propTypes = { + post: PropTypes.object +} + +export default PostLead diff --git a/src/components/atoms/PostLead.module.scss b/src/components/atoms/PostLead.module.scss new file mode 100644 index 00000000..8701c272 --- /dev/null +++ b/src/components/atoms/PostLead.module.scss @@ -0,0 +1,5 @@ +@import 'mixins'; + +.lead { + @include lead(); +} diff --git a/src/components/atoms/PostLinkActions.module.scss b/src/components/atoms/PostLinkActions.module.scss index 91201294..1ae70dc9 100644 --- a/src/components/atoms/PostLinkActions.module.scss +++ b/src/components/atoms/PostLinkActions.module.scss @@ -4,7 +4,6 @@ display: flex; justify-content: space-between; margin-top: $spacer * 2; - margin-bottom: $spacer * 2; a { svg { diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 99489298..c55bf87b 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,23 +1,53 @@ -import React from 'react' +import React, { Fragment } from 'react' import PropTypes from 'prop-types' import { Link, graphql } from 'gatsby' import Layout from '../components/Layout' +import Image from '../components/atoms/Image' +import PostTitle from '../components/atoms/PostTitle' +import PostLead from '../components/atoms/PostLead' +import PostContent from '../components/atoms/PostContent' +import PostLinkActions from '../components/atoms/PostLinkActions' +import postStyles from '../templates/Post.module.scss' +import styles from './index.module.scss' const IndexPage = ({ data, location }) => { const edges = data.allMarkdownRemark.edges - const Posts = edges - // .filter(edge => !!edge.node.frontmatter.date) - .map(edge => ( -
  • - {edge.node.frontmatter.title} -
  • - )) - return ( - -
      {Posts}
    -
    - ) + const Posts = edges.map(({ node }) => { + const { type, linkurl, title, image } = node.frontmatter + const { slug } = node.fields + + return ( +
    + + + {image && ( +
    + + {title} + +
    + )} + + + + {type === 'post' && ( + + Continue Reading + + )} + + {type === 'link' && ( + + + + + )} +
    + ) + }) + + return {Posts} } IndexPage.propTypes = { @@ -33,9 +63,17 @@ export const indexQuery = graphql` edges { node { id + html excerpt(pruneLength: 250) frontmatter { title + type + linkurl + image { + childImageSharp { + ...ImageFluid + } + } } fields { slug diff --git a/src/pages/index.module.scss b/src/pages/index.module.scss new file mode 100644 index 00000000..58c5ee54 --- /dev/null +++ b/src/pages/index.module.scss @@ -0,0 +1,28 @@ +@import 'variables'; +@import 'mixins'; + +// Post/photo teaser +///////////////////////////////////// + +.hentry__image { + @include breakoutviewport(); + + max-width: none; + display: block; + margin-top: $spacer * 1.5; + margin-bottom: $spacer * 1.5; + + > div { + @include media-frame(); + + border-radius: 0; + + @media (min-width: $screen-sm) { + border-radius: $border-radius; + } + } + + img { + border-radius: 0; + } +} diff --git a/src/styles/_content.scss b/src/styles/_content.scss index bc856236..9efdfab5 100644 --- a/src/styles/_content.scss +++ b/src/styles/_content.scss @@ -1,102 +1,3 @@ -@import 'variables'; -@import 'mixins'; - -.content { - h1, - h2 { - @include heading-band(); - } - - h1 { - font-size: $font-size-h2; - } - - h2 { - font-size: $font-size-h3; - } - - h3 { - font-size: $font-size-h4; - } - - h4 { - font-size: $font-size-h5; - } - - p:last-child { - margin-bottom: 0; - } - - .gatsby-resp-image-figure, - .gatsby-resp-image-wrapper { - margin-bottom: $spacer; - } - - figcaption { - font-size: $font-size-small; - color: $brand-grey; - font-style: italic; - text-align: center; - margin-top: -$spacer / 2; - } - - .anchor { - margin-top: $spacer / 3; - } - - // Quotes - ///////////////////////////////////// - - q { - font-style: italic; - } - - cite { - font-style: normal; - text-transform: uppercase; - } - - // stylelint-disable no-descending-specificity - blockquote, - blockquote > p { - font-style: italic; - color: $brand-grey-light; - } - // stylelint-enable no-descending-specificity - - blockquote { - margin: 0 0 $spacer; - position: relative; - padding-left: 20px; - - @media (min-width: $screen-xs) { - padding-left: 40px; - } - - @media (min-width: $screen-lg) { - padding-left: 60px; - } - - // quotation marks - &::before { - content: '“'; - font-size: 300%; - color: lighten($brand-grey-light, 20%); - position: absolute; - left: -10px; - top: -20px; - - @media (min-width: $screen-xs) { - left: 0; - } - - @media (min-width: $screen-lg) { - top: -30px; - } - } - } -} - // Goodies download ///////////////////////////////////// diff --git a/src/templates/Post.jsx b/src/templates/Post.jsx index 9f29dbc0..b9392b99 100644 --- a/src/templates/Post.jsx +++ b/src/templates/Post.jsx @@ -5,55 +5,11 @@ import { graphql } from 'gatsby' import Layout from '../components/Layout' import Image from '../components/atoms/Image' import PostTitle from '../components/atoms/PostTitle' +import PostLead from '../components/atoms/PostLead' +import PostContent from '../components/atoms/PostContent' import PostMeta from '../components/molecules/PostMeta' import styles from './Post.module.scss' -const separator = '' - -// Extract lead paragraph from content -// Grab everything before more tag, or just first paragraph -const PostLead = ({ post }) => { - let lead - const content = post.html - - if (post.frontmatter.type === 'post') { - if (content.includes(separator)) { - lead = content.split(separator)[0] - } else { - lead = content.split('\n')[0] - } - } else { - return null - } - - return ( -
    - ) -} - -// Remove lead paragraph from content -const PostContent = ({ post }) => { - let content - - content = post.html - - if (post.frontmatter.type === 'post') { - if (content.includes(separator)) { - content = content.split(separator)[1] - } else { - const lead = content.split('\n')[0] - content = content.replace(lead, '') - } - } - - return ( -
    - ) -} - const Post = ({ data, location }) => { const { markdownRemark: post } = data const { contentYaml: meta } = data diff --git a/src/templates/Post.module.scss b/src/templates/Post.module.scss index b34c50ee..e94dd45f 100644 --- a/src/templates/Post.module.scss +++ b/src/templates/Post.module.scss @@ -2,6 +2,10 @@ @import 'mixins'; .hentry { + @include divider; + + margin-top: 0; + margin-bottom: 0; padding-top: $spacer * 2; padding-bottom: $spacer * 2; width: 100%; @@ -41,10 +45,3 @@ border-radius: 0; } } - -// Post Content -///////////////////////////////////// - -.hentry__lead { - @include lead(); -}