2018-11-09 18:08:48 +01:00
|
|
|
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}>
|
2018-11-11 21:40:08 +01:00
|
|
|
<Link to={`/category/${kebabCase(category.fieldValue)}/`}>
|
2018-11-09 18:08:48 +01:00
|
|
|
{category.fieldValue} ({category.totalCount})
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</Page>
|
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const query = graphql`
|
|
|
|
query CategoriesListQuery {
|
|
|
|
site {
|
|
|
|
siteMetadata {
|
|
|
|
title
|
|
|
|
subtitle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
allMarkdownRemark(
|
2018-11-11 17:32:51 +01:00
|
|
|
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
|
2018-11-09 18:08:48 +01:00
|
|
|
) {
|
|
|
|
group(field: frontmatter___category) {
|
|
|
|
fieldValue
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default CategoriesListTemplate;
|