rickvanlieshout.com/src/templates/categories-list-template.js

33 lines
944 B
JavaScript
Raw Normal View History

2019-08-01 04:05:23 +02:00
// @flow strict
2018-11-09 18:08:48 +01:00
import React from 'react';
2019-05-09 15:57:42 +02:00
import { Link } from 'gatsby';
2018-11-09 18:08:48 +01:00
import kebabCase from 'lodash/kebabCase';
import Sidebar from '../components/Sidebar';
import Layout from '../components/Layout';
import Page from '../components/Page';
2019-05-09 15:57:42 +02:00
import { useSiteMetadata, useCategoriesList } from '../hooks';
2018-11-09 18:08:48 +01:00
2019-05-09 15:57:42 +02:00
const CategoriesListTemplate = () => {
const { title, subtitle } = useSiteMetadata();
const categories = useCategoriesList();
2018-11-09 18:08:48 +01:00
return (
<Layout title={`Categories - ${title}`} description={subtitle}>
<Sidebar />
<Page title="Categories">
<ul>
2019-05-09 15:57:42 +02:00
{categories.map((category) => (
2018-11-09 18:08:48 +01:00
<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>
);
};
2019-08-01 04:05:23 +02:00
export default CategoriesListTemplate;