2021-03-03 18:51:53 -05:00
|
|
|
import React from "react";
|
|
|
|
import { GetStaticProps } from "next";
|
2021-03-22 15:35:13 -04:00
|
|
|
import { Links } from "components";
|
|
|
|
|
|
|
|
// TODO: change
|
|
|
|
const API = "https://api.thedogapi.com/v1/breeds?limit=10&page=0";
|
2021-03-03 16:38:09 -05:00
|
|
|
|
2021-03-03 18:51:53 -05:00
|
|
|
export const getStaticProps: GetStaticProps = async () => {
|
2021-03-22 15:35:13 -04:00
|
|
|
// fetch data here
|
|
|
|
const data = await fetch(API).then((res) => res.json());
|
2021-03-03 18:51:53 -05:00
|
|
|
|
|
|
|
return {
|
2021-04-01 18:26:56 -04:00
|
|
|
props: { data }, // will be passed to the page component as props
|
2021-03-03 18:51:53 -05:00
|
|
|
revalidate: 1,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-04-01 18:26:56 -04:00
|
|
|
const Home: React.FC = ({ data }: any) => {
|
|
|
|
return (
|
|
|
|
<Links
|
|
|
|
links={data.map((dog: any) => ({
|
|
|
|
title: dog.name,
|
|
|
|
url: "https://www.google.com/",
|
|
|
|
}))}
|
|
|
|
/>
|
|
|
|
);
|
2021-03-03 18:51:53 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Home;
|