59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import React from "react";
|
|
import { NextPage, GetStaticProps } from "next";
|
|
import Head from "next/head";
|
|
import useSWR from "swr";
|
|
import Event from "@models/Event";
|
|
import Post from "@models/Feed";
|
|
import InEnglishPageView from "@views/InEnglishPage/InEnglishPageView";
|
|
import PageWrapper from "@views/common/PageWrapper";
|
|
import { fetcher, APIPath, API } from "@api/backend";
|
|
|
|
const eventApi: API = {
|
|
path: APIPath.EVENTS,
|
|
queryParams: {
|
|
limit: 4,
|
|
},
|
|
};
|
|
|
|
const feedApi: API = {
|
|
path: APIPath.FEED,
|
|
queryParams: {
|
|
limit: 4,
|
|
},
|
|
};
|
|
|
|
interface InitialProps {
|
|
initialEvents: Event[];
|
|
initialFeed: Post[];
|
|
}
|
|
|
|
const InEnglishPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
|
|
const { data: events } = useSWR<Event[]>(eventApi, fetcher, { fallbackData: initialEvents });
|
|
const { data: feed } = useSWR<Post[]>(feedApi, fetcher, { fallbackData: initialFeed });
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<link rel="canonical" href={`${process.env.NEXT_PUBLIC_SITE_URL}/in_english`} />
|
|
</Head>
|
|
<PageWrapper>
|
|
<InEnglishPageView events={events} feed={feed} />
|
|
</PageWrapper>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
|
|
const initialEvents = await fetcher<Event[]>(eventApi);
|
|
const initialFeed = await fetcher<Post[]>(feedApi);
|
|
return {
|
|
props: {
|
|
initialEvents,
|
|
initialFeed,
|
|
},
|
|
revalidate: 10,
|
|
};
|
|
};
|
|
|
|
export default InEnglishPage;
|