rickvanlieshout.com/src/hooks/use-categories-list.js
2019-07-31 22:05:23 -04:00

24 lines
529 B
JavaScript

// @flow strict
import { useStaticQuery, graphql } from 'gatsby';
const useCategoriesList = () => {
const { allMarkdownRemark } = useStaticQuery(
graphql`
query CategoriesListQuery {
allMarkdownRemark(
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
) {
group(field: frontmatter___category) {
fieldValue
totalCount
}
}
}
`
);
return allMarkdownRemark.group;
};
export default useCategoriesList;