import React from 'react';
import Link from 'next/link';
import {fetchData} from '@2fn/data';

export default function Index({data}) {
	return (
		<div>
			<div>
  {data.map(item => <Link href={`/category/${item['id']}`} key={item['name']}><a><span>{item['name']}</span></a></Link>
  )}
</div>
		</div>
	);
}
	
export async function getStaticProps(context) {
	const data = await fetchData('categories');
	return {
    props: { data },
    unstable_revalidate: 1,
	};
}
