Convert most non-admin pages to ISR
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { NextPage, GetServerSideProps } from "next";
|
||||
import { NextPage, GetStaticProps, GetStaticPaths } from "next";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import {
|
||||
@@ -32,14 +32,30 @@ const EventPage: NextPage<InitialProps> = ({ initialEvent }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<InitialProps> = async (context) => {
|
||||
const { id } = context.query;
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
const { url, config } = generateFetchParams();
|
||||
const allEvents = await eventFetcher(url, config);
|
||||
const paths = allEvents.results.map((e: Event) => ({
|
||||
params: {
|
||||
id: String(e.id),
|
||||
},
|
||||
}
|
||||
));
|
||||
return {
|
||||
paths,
|
||||
fallback: false,
|
||||
};
|
||||
};
|
||||
|
||||
export const getStaticProps: GetStaticProps<InitialProps> = async ({ params }) => {
|
||||
const { id } = params;
|
||||
const { url, config } = generateFetchParams(id as string);
|
||||
const initialEvent = await eventFetcher(url, config);
|
||||
return {
|
||||
props: {
|
||||
initialEvent,
|
||||
},
|
||||
revalidate: 60,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { NextPage, GetServerSideProps } from "next";
|
||||
import { NextPage, GetStaticProps } from "next";
|
||||
import Head from "next/head";
|
||||
import {
|
||||
Event, useFetchEvents, eventFetcher, generateFetchParams as eventParams,
|
||||
@@ -36,7 +36,7 @@ const InEnglishPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) =
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<InitialProps> = async () => {
|
||||
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
|
||||
let url: string;
|
||||
let config: any;
|
||||
({ url, config } = eventParams("", eventOptions));
|
||||
@@ -48,6 +48,7 @@ export const getServerSideProps: GetServerSideProps<InitialProps> = async () =>
|
||||
initialEvents,
|
||||
initialFeed,
|
||||
},
|
||||
revalidate: 60,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { NextPage, GetServerSideProps } from "next";
|
||||
import { NextPage, GetStaticProps } from "next";
|
||||
import Head from "next/head";
|
||||
import {
|
||||
Event, useFetchEvents, eventFetcher, generateFetchParams as eventParams,
|
||||
@@ -36,7 +36,7 @@ const FrontPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<InitialProps> = async () => {
|
||||
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
|
||||
let url: string;
|
||||
let config: any;
|
||||
({ url, config } = eventParams("", eventOptions));
|
||||
@@ -48,6 +48,7 @@ export const getServerSideProps: GetServerSideProps<InitialProps> = async () =>
|
||||
initialEvents,
|
||||
initialFeed,
|
||||
},
|
||||
revalidate: 60,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { NextPage, GetServerSideProps } from "next";
|
||||
import { NextPage, GetStaticProps } from "next";
|
||||
import Head from "next/head";
|
||||
import {
|
||||
Event, useFetchEvents, eventFetcher, generateFetchParams as eventParams,
|
||||
@@ -35,7 +35,7 @@ const ActualPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<InitialProps> = async () => {
|
||||
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
|
||||
let url: string;
|
||||
let config: any;
|
||||
({ url, config } = eventParams("", eventOptions));
|
||||
@@ -47,6 +47,7 @@ export const getServerSideProps: GetServerSideProps<InitialProps> = async () =>
|
||||
initialEvents,
|
||||
initialFeed,
|
||||
},
|
||||
revalidate: 60,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { NextPage, GetServerSideProps } from "next";
|
||||
import { NextPage, GetStaticProps } from "next";
|
||||
import Head from "next/head";
|
||||
import {
|
||||
JobAd, useFetchJobAds, jobAdFetcher, generateFetchParams,
|
||||
@@ -26,13 +26,14 @@ const CorporatePage: NextPage<InitialProps> = ({ initialJobAds }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<InitialProps> = async () => {
|
||||
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
|
||||
const { url } = generateFetchParams();
|
||||
const initialJobAds = await jobAdFetcher(url);
|
||||
return {
|
||||
props: {
|
||||
initialJobAds,
|
||||
},
|
||||
revalidate: 60,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user