LinkList/frontend/pages/index.tsx

28 lines
602 B
TypeScript

import React from "react";
import { GetStaticProps } from "next";
import { Link, Links } from "components/Links";
import { readFileSync } from "fs";
export const getStaticProps: GetStaticProps<Props> = async () => {
if (!process.env.LINKS_FILE) {
throw new Error("Set the LINKS_FILE environment variable");
}
const links = JSON.parse(readFileSync(process.env.LINKS_FILE).toString());
return {
props: { links },
revalidate: 1,
};
};
interface Props {
links: Link[];
}
const Home: React.FC<Props> = ({ links }) => {
return <Links links={links} />;
};
export default Home;