import React from 'react'; import { Link, graphql } from 'gatsby'; import kebabCase from 'lodash/kebabCase'; import Sidebar from '../components/Sidebar'; import Layout from '../components/Layout'; import Page from '../components/Page'; const CategoriesListTemplate = ({ data }) => { const { title, subtitle } = data.site.siteMetadata; const { group } = data.allMarkdownRemark; return (
    {group.map((category) => (
  • {category.fieldValue} ({category.totalCount})
  • ))}
); }; export const query = graphql` query CategoriesListQuery { site { siteMetadata { title subtitle } } allMarkdownRemark( filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } } ) { group(field: frontmatter___category) { fieldValue totalCount } } } `; export default CategoriesListTemplate;