Styling changes and refactor

Switch google fonts to use Next.js font optimization, animate comment fade in, and refactor beer like handler and comment submit handler.
This commit is contained in:
Aaron William Po
2023-04-04 20:50:00 -04:00
parent a4362a531c
commit 796a5fce3f
15 changed files with 148 additions and 77 deletions

View File

@@ -2,6 +2,21 @@ import { GetServerSidePropsContext, GetServerSidePropsResult, PreviewData } from
import { ParsedUrlQuery } from 'querystring';
import { getLoginSession } from '../config/auth/session';
/**
* Represents a type definition for a function that handles server-side rendering with
* extended capabilities.
*
* @template P - A generic type that represents an object with string keys and any values.
* It defaults to an empty object.
* @template Q - A generic type that represents a parsed URL query object. It defaults to
* the ParsedUrlQuery type.
* @template D - A generic type that represents preview data. It defaults to the
* PreviewData type.
* @param context - The context object containing information about the incoming HTTP
* request.
* @param session - An awaited value of the return type of the getLoginSession function.
* @returns - A promise that resolves to the result of the server-side rendering process.
*/
export type ExtendedGetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery,
@@ -11,6 +26,20 @@ export type ExtendedGetServerSideProps<
session: Awaited<ReturnType<typeof getLoginSession>>,
) => Promise<GetServerSidePropsResult<P>>;
/**
* A Higher Order Function that adds authentication requirement to a Next.js server-side
* page component.
*
* @param fn An async function that receives the GetServerSidePropsContext and
* authenticated session as arguments and returns a GetServerSidePropsResult with props
* for the wrapped component.
* @returns A promise that resolves to a GetServerSidePropsResult object with props for
* the wrapped component. If authentication is successful, the GetServerSidePropsResult
* will include props generated by the wrapped component's getServerSideProps method. If
* authentication fails, the GetServerSidePropsResult will include a redirect to the
* login page.
*/
const withPageAuthRequired =
<P extends { [key: string]: any } = { [key: string]: any }>(
fn?: ExtendedGetServerSideProps<P>,