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.
25 lines
697 B
JavaScript
25 lines
697 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</title></Head>
|
|
<h2>Categories</h2>
|
|
{topCategories.length > 0 && <div className={styles.childCategories}>
|
|
{topCategories.map(category => (
|
|
<CategoryCard category={category}/>
|
|
))}
|
|
</div>}
|
|
</>
|
|
)
|
|
}
|