{"size": 947, "ext": "js", "max_stars_repo_path": "src/hooks/use-posts.js", "max_stars_repo_name": "stephencweiss/gatsby-intro", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/hooks/use-posts.js", "max_issues_repo_name": "stephencweiss/gatsby-intro", "max_issues_repo_issues_event_min_datetime": "2021-09-02T17:51:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T10:46:25.000Z", "max_forks_repo_path": "src/hooks/use-posts.js", "max_forks_repo_name": "stephencweiss/gatsby-intro", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 22.023255814, "max_line_length": 69, "alphanum_fraction": 0.4677930306}
import { graphql, useStaticQuery } from 'gatsby';

const usePosts = () => {
  const data = useStaticQuery(graphql`
    query {
      allMdx {
        nodes {
          frontmatter {
            title
            slug
            author
            cover {
              sharp: childImageSharp {
                fluid (
                  maxWidth: 100
                  maxHeight: 100
                  duotone: { shadow: "#663399", highlight: "#ddbbff"}
                ) {
                  ...GatsbyImageSharpFluid_withWebp_tracedSVG
                }
              }
            }
          }
          excerpt
          wordCount {
            words
          }
        }
      }
    }
  `);

  return data.allMdx.nodes.map(posts => ({
    title: posts.frontmatter.title,
    author: posts.frontmatter.author,
    slug: posts.frontmatter.slug,
    excerpt: posts.excerpt,
    cover: posts.frontmatter.cover
  }));
};

export default usePosts;
