mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-10 10:16:21 +02:00
30 lines
671 B
TypeScript
30 lines
671 B
TypeScript
import { graphql, useStaticQuery } from "gatsby";
|
|
|
|
interface CategoriesQueryResult {
|
|
allMarkdownRemark: {
|
|
group: Array<{
|
|
fieldValue: string;
|
|
totalCount: number;
|
|
}>;
|
|
};
|
|
}
|
|
|
|
const useCategoriesList = () => {
|
|
const { allMarkdownRemark } = useStaticQuery<CategoriesQueryResult>(graphql`
|
|
query CategoriesListQuery {
|
|
allMarkdownRemark(
|
|
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
|
|
) {
|
|
group(field: { frontmatter: { category: SELECT } }) {
|
|
fieldValue
|
|
totalCount
|
|
}
|
|
}
|
|
}
|
|
`);
|
|
|
|
return allMarkdownRemark.group ?? [];
|
|
};
|
|
|
|
export default useCategoriesList;
|