mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-01-15 16:12:55 +01:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
|
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 (
|
||
|
<Layout title={`Categories - ${title}`} description={subtitle}>
|
||
|
<Sidebar />
|
||
|
<Page title="Categories">
|
||
|
<ul>
|
||
|
{group.map((category) => (
|
||
|
<li key={category.fieldValue}>
|
||
|
<Link to={`/categories/${kebabCase(category.fieldValue)}/`}>
|
||
|
{category.fieldValue} ({category.totalCount})
|
||
|
</Link>
|
||
|
</li>
|
||
|
))}
|
||
|
</ul>
|
||
|
</Page>
|
||
|
</Layout>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export const query = graphql`
|
||
|
query CategoriesListQuery {
|
||
|
site {
|
||
|
siteMetadata {
|
||
|
title
|
||
|
subtitle
|
||
|
}
|
||
|
}
|
||
|
allMarkdownRemark(
|
||
|
filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } }
|
||
|
) {
|
||
|
group(field: frontmatter___category) {
|
||
|
fieldValue
|
||
|
totalCount
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`;
|
||
|
|
||
|
export default CategoriesListTemplate;
|