rickvanlieshout.com/src/hooks/use-categories-list.js

24 lines
529 B
JavaScript
Raw Normal View History

2019-08-01 04:05:23 +02:00
// @flow strict
2019-05-09 15:57:42 +02:00
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;