rickvanlieshout.com/src/templates/CategoriesTemplate/CategoriesTemplate.tsx

34 lines
937 B
TypeScript
Raw Normal View History

import React from "react";
2018-11-09 18:08:48 +01:00
import { Link } from "gatsby";
import { Layout } from "@/components/Layout";
import { Page } from "@/components/Page";
import { Sidebar } from "@/components/Sidebar";
import { useCategoriesList, useSiteMetadata } from "@/hooks";
import { toKebabCase } from "@/utils";
const CategoriesTemplate: React.FC = () => {
2019-05-09 15:57:42 +02:00
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>
{categories.map(category => (
2018-11-09 18:08:48 +01:00
<li key={category.fieldValue}>
<Link to={`/category/${toKebabCase(category.fieldValue)}/`}>
2018-11-09 18:08:48 +01:00
{category.fieldValue} ({category.totalCount})
</Link>
</li>
))}
</ul>
</Page>
</Layout>
);
};
export default CategoriesTemplate;