You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
732 B
JavaScript

import Head from 'next/head'
import CategoryCard from '~/components/categoryCard'
import styles from './category/style.module.css'
Categories.getInitialProps = async ({ctx}) => {
const {data: categories} = await ctx.axios.get('/api/categories')
return {categories}
}
export default function Categories({categories: allCategories}) {
const topCategories = allCategories.filter(cat => !cat.parent)
return (
<>
<Head>
<title>Categories | Society of Socks</title>
</Head>
<h2>Categories</h2>
{topCategories.length > 0 && <div className={styles.childCategories}>
{topCategories.map(category => (
<CategoryCard category={category}/>
))}
</div>}
</>
)
}