From 3f452c529abd3a417a0be3ed9bdde24d23fad9bc Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 3 Apr 2022 10:34:21 +0200 Subject: [PATCH] Made props types more consistent --- src/components/AppLayout.tsx | 4 +- src/components/Button.tsx | 6 +- src/components/Chip.tsx | 6 +- .../Chronology/ChronologyItemComponent.tsx | 8 +- .../Chronology/ChronologyYearComponent.tsx | 8 +- src/components/Content/ThumbnailHeader.tsx | 8 +- src/components/HorizontalLine.tsx | 8 +- src/components/Img.tsx | 108 +++++++++--------- src/components/InsetBox.tsx | 6 +- src/components/LanguageSwitcher.tsx | 4 +- src/components/Library/ContentTOCLine.tsx | 8 +- .../Library/LibraryContentPreview.tsx | 8 +- .../Library/LibraryItemsPreview.tsx | 8 +- src/components/LightBox.tsx | 6 +- src/components/Markdown/Markdawn.tsx | 6 +- src/components/Markdown/TOC.tsx | 16 +-- src/components/News/PostsPreview.tsx | 6 +- src/components/PageSelector.tsx | 4 +- src/components/PanelComponents/NavOption.tsx | 6 +- .../PanelComponents/PanelHeader.tsx | 6 +- .../PanelComponents/ReturnButton.tsx | 6 +- src/components/Panels/ContentPanel.tsx | 6 +- src/components/Panels/MainPanel.tsx | 6 +- src/components/Panels/SubPanel.tsx | 6 +- src/components/Popup.tsx | 6 +- src/components/RecorderChip.tsx | 6 +- src/components/SVG.tsx | 6 +- src/components/Select.tsx | 6 +- src/components/Switch.tsx | 6 +- src/components/ToolTip.tsx | 4 +- src/components/Videos/VideoPreview.tsx | 4 +- src/contexts/AppLayoutContext.tsx | 6 +- .../operations/getVideoChannel.graphql | 68 +++++------ .../operations/getVideoChannelsSlugs.graphql | 10 +- src/pages/404.tsx | 8 +- src/pages/500.tsx | 8 +- src/pages/api/mail.ts | 8 +- src/pages/api/revalidate.ts | 16 +-- src/pages/archives/index.tsx | 8 +- src/pages/archives/videos/index.tsx | 2 +- src/pages/archives/videos/v/[uid].tsx | 4 +- src/pages/chronicles/index.tsx | 8 +- src/pages/contents/index.tsx | 12 +- src/pages/editor.tsx | 8 +- src/pages/gallery/index.tsx | 8 +- src/pages/merch/index.tsx | 8 +- src/pages/news/[slug].tsx | 8 +- src/pages/wiki/index.tsx | 8 +- src/queries/helpers.ts | 4 +- 49 files changed, 246 insertions(+), 258 deletions(-) diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index ce78812..8a9efd0 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -18,7 +18,7 @@ import MainPanel from "./Panels/MainPanel"; import Popup from "./Popup"; import Select from "./Select"; -interface AppLayoutProps extends AppStaticProps { +interface Props extends AppStaticProps { subPanel?: React.ReactNode; subPanelIcon?: string; contentPanel?: React.ReactNode; @@ -28,7 +28,7 @@ interface AppLayoutProps extends AppStaticProps { description?: string; } -export default function AppLayout(props: AppLayoutProps): JSX.Element { +export default function AppLayout(props: Props): JSX.Element { const { langui, currencies, languages, subPanel, contentPanel } = props; const router = useRouter(); const isMobile = useMediaMobile(); diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 8da4382..6bfba9b 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,7 +1,7 @@ import { useRouter } from "next/router"; import { MouseEventHandler } from "react"; -type ButtonProps = { +interface Props { id?: string; className?: string; href?: string; @@ -9,9 +9,9 @@ type ButtonProps = { active?: boolean; locale?: string; onClick?: MouseEventHandler; -}; +} -export default function Button(props: ButtonProps): JSX.Element { +export default function Button(props: Props): JSX.Element { const router = useRouter(); const button = ( diff --git a/src/components/Chip.tsx b/src/components/Chip.tsx index 282f566..b410c5e 100644 --- a/src/components/Chip.tsx +++ b/src/components/Chip.tsx @@ -1,9 +1,9 @@ -type ChipProps = { +interface Props { className?: string; children: React.ReactNode; -}; +} -export default function Chip(props: ChipProps): JSX.Element { +export default function Chip(props: Props): JSX.Element { return (
["data"][number]; displayYear: boolean; langui: AppStaticProps["langui"]; -}; +} -export default function ChronologyItemComponent( - props: ChronologyItemComponentProps -): JSX.Element { +export default function ChronologyItemComponent(props: Props): JSX.Element { const { langui } = props; function generateAnchor( diff --git a/src/components/Chronology/ChronologyYearComponent.tsx b/src/components/Chronology/ChronologyYearComponent.tsx index b4c9f4b..53c6c54 100644 --- a/src/components/Chronology/ChronologyYearComponent.tsx +++ b/src/components/Chronology/ChronologyYearComponent.tsx @@ -2,18 +2,16 @@ import ChronologyItemComponent from "components/Chronology/ChronologyItemCompone import { GetChronologyItemsQuery } from "graphql/generated"; import { AppStaticProps } from "queries/getAppStaticProps"; -type ChronologyYearComponentProps = { +interface Props { year: number; items: Exclude< GetChronologyItemsQuery["chronologyItems"], null | undefined >["data"][number][]; langui: AppStaticProps["langui"]; -}; +} -export default function ChronologyYearComponent( - props: ChronologyYearComponentProps -): JSX.Element { +export default function ChronologyYearComponent(props: Props): JSX.Element { const { langui } = props; return ( diff --git a/src/components/Content/ThumbnailHeader.tsx b/src/components/Content/ThumbnailHeader.tsx index 7e9004b..0d41c49 100644 --- a/src/components/Content/ThumbnailHeader.tsx +++ b/src/components/Content/ThumbnailHeader.tsx @@ -5,7 +5,7 @@ import { GetContentQuery, UploadImageFragment } from "graphql/generated"; import { AppStaticProps } from "queries/getAppStaticProps"; import { prettyinlineTitle, prettySlug, slugify } from "queries/helpers"; -export type ThumbnailHeaderProps = { +interface Props { pre_title?: string | null | undefined; title: string | null | undefined; subtitle?: string | null | undefined; @@ -26,11 +26,9 @@ export type ThumbnailHeaderProps = { >["categories"]; thumbnail?: UploadImageFragment | null | undefined; langui: AppStaticProps["langui"]; -}; +} -export default function ThumbnailHeader( - props: ThumbnailHeaderProps -): JSX.Element { +export default function ThumbnailHeader(props: Props): JSX.Element { const { langui, pre_title, diff --git a/src/components/HorizontalLine.tsx b/src/components/HorizontalLine.tsx index 985e220..ae6a065 100644 --- a/src/components/HorizontalLine.tsx +++ b/src/components/HorizontalLine.tsx @@ -1,10 +1,8 @@ -type HorizontalLineProps = { +interface Props { className?: string; -}; +} -export default function HorizontalLine( - props: HorizontalLineProps -): JSX.Element { +export default function HorizontalLine(props: Props): JSX.Element { return (
+ ); + } + return ( + {props.alt + ); + } + return <>; +} + export enum ImageQuality { Small = "small", Medium = "medium", @@ -48,57 +102,3 @@ export function getImgSizesByQuality( return { width: 0, height: 0 }; } } - -type ImgProps = { - className?: string; - image?: UploadImageFragment; - quality?: ImageQuality; - alt?: ImageProps["alt"]; - layout?: ImageProps["layout"]; - objectFit?: ImageProps["objectFit"]; - priority?: ImageProps["priority"]; - rawImg?: boolean; -}; - -export default function Img(props: ImgProps): JSX.Element { - if (props.image?.width && props.image?.height) { - const imgSize = getImgSizesByQuality( - props.image.width, - props.image.height, - props.quality ?? ImageQuality.Small - ); - - if (props.rawImg) { - return ( - // eslint-disable-next-line @next/next/no-img-element - {props.alt - ); - } - return ( - {props.alt - ); - } - return <>; -} diff --git a/src/components/InsetBox.tsx b/src/components/InsetBox.tsx index c9f45ea..e19f8cd 100644 --- a/src/components/InsetBox.tsx +++ b/src/components/InsetBox.tsx @@ -1,10 +1,10 @@ -type InsetBoxProps = { +interface Props { className?: string; children: React.ReactNode; id?: string; -}; +} -export default function InsetBox(props: InsetBoxProps): JSX.Element { +export default function InsetBox(props: Props): JSX.Element { return (
["data"][number]; parentSlug: string; langui: AppStaticProps["langui"]; -}; +} -export default function ContentTOCLine( - props: ContentTOCLineProps -): JSX.Element { +export default function ContentTOCLine(props: Props): JSX.Element { const { content, langui, parentSlug } = props; const [opened, setOpened] = useState(false); diff --git a/src/components/Library/LibraryContentPreview.tsx b/src/components/Library/LibraryContentPreview.tsx index 0c2b402..0f44a4f 100644 --- a/src/components/Library/LibraryContentPreview.tsx +++ b/src/components/Library/LibraryContentPreview.tsx @@ -4,16 +4,14 @@ import { GetContentsQuery } from "graphql/generated"; import Link from "next/link"; import { prettySlug } from "queries/helpers"; -export type LibraryContentPreviewProps = { +interface Props { item: Exclude< GetContentsQuery["contents"], null | undefined >["data"][number]["attributes"]; -}; +} -export default function LibraryContentPreview( - props: LibraryContentPreviewProps -): JSX.Element { +export default function LibraryContentPreview(props: Props): JSX.Element { const { item } = props; return ( diff --git a/src/components/Library/LibraryItemsPreview.tsx b/src/components/Library/LibraryItemsPreview.tsx index 5e36fc7..4f06ece 100644 --- a/src/components/Library/LibraryItemsPreview.tsx +++ b/src/components/Library/LibraryItemsPreview.tsx @@ -9,7 +9,7 @@ import Link from "next/link"; import { AppStaticProps } from "queries/getAppStaticProps"; import { prettyDate, prettyItemSubType, prettyPrice } from "queries/helpers"; -export type LibraryItemsPreviewProps = { +interface Props { className?: string; item: | Exclude< @@ -27,11 +27,9 @@ export type LibraryItemsPreviewProps = { null | undefined >["data"][number]["attributes"]; currencies: AppStaticProps["currencies"]; -}; +} -export default function LibraryItemsPreview( - props: LibraryItemsPreviewProps -): JSX.Element { +export default function LibraryItemsPreview(props: Props): JSX.Element { const { item } = props; const appLayout = useAppLayout(); diff --git a/src/components/LightBox.tsx b/src/components/LightBox.tsx index 41754bc..4864815 100644 --- a/src/components/LightBox.tsx +++ b/src/components/LightBox.tsx @@ -2,7 +2,7 @@ import { useMediaMobile } from "hooks/useMediaQuery"; import { Dispatch, SetStateAction } from "react"; import Lightbox from "react-image-lightbox"; -export type LightBoxProps = { +interface Props { setState: | Dispatch> | Dispatch>; @@ -10,9 +10,9 @@ export type LightBoxProps = { images: string[]; index: number; setIndex: Dispatch>; -}; +} -export default function LightBox(props: LightBoxProps): JSX.Element { +export default function LightBox(props: Props): JSX.Element { const { state, setState, images, index, setIndex } = props; const mobile = useMediaMobile(); diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx index 3e7d108..d157719 100644 --- a/src/components/Markdown/Markdawn.tsx +++ b/src/components/Markdown/Markdawn.tsx @@ -10,12 +10,12 @@ import { slugify } from "queries/helpers"; import React, { useState } from "react"; import ReactDOMServer from "react-dom/server"; -type MarkdawnProps = { +interface Props { className?: string; text: string; -}; +} -export default function Markdawn(props: MarkdawnProps): JSX.Element { +export default function Markdawn(props: Props): JSX.Element { const appLayout = useAppLayout(); const text = preprocessMarkDawn(props.text); diff --git a/src/components/Markdown/TOC.tsx b/src/components/Markdown/TOC.tsx index a90b752..54822de 100644 --- a/src/components/Markdown/TOC.tsx +++ b/src/components/Markdown/TOC.tsx @@ -2,12 +2,12 @@ import { useRouter } from "next/router"; import { slugify } from "queries/helpers"; import { preprocessMarkDawn } from "./Markdawn"; -type TOCProps = { +interface Props { text: string; title?: string; -}; +} -export default function TOCComponent(props: TOCProps): JSX.Element { +export default function TOCComponent(props: Props): JSX.Element { const { text, title } = props; const toc = getTocFromMarkdawn(preprocessMarkDawn(text), title); const router = useRouter(); @@ -27,12 +27,12 @@ export default function TOCComponent(props: TOCProps): JSX.Element { ); } -type TOCLevelProps = { +interface LevelProps { tocchildren: TOC[]; parentNumbering: string; -}; +} -function TOCLevel(props: TOCLevelProps): JSX.Element { +function TOCLevel(props: LevelProps): JSX.Element { const router = useRouter(); const { tocchildren, parentNumbering } = props; return ( @@ -60,11 +60,11 @@ function TOCLevel(props: TOCLevelProps): JSX.Element { ); } -export type TOC = { +interface TOC { title: string; slug: string; children: TOC[]; -}; +} export function getTocFromMarkdawn(text: string, title?: string): TOC { const toc: TOC = { diff --git a/src/components/News/PostsPreview.tsx b/src/components/News/PostsPreview.tsx index ecd41f6..b1cd585 100644 --- a/src/components/News/PostsPreview.tsx +++ b/src/components/News/PostsPreview.tsx @@ -4,14 +4,14 @@ import { GetPostsPreviewQuery } from "graphql/generated"; import Link from "next/link"; import { prettyDate, prettySlug } from "queries/helpers"; -export type PostPreviewProps = { +interface Props { post: Exclude< GetPostsPreviewQuery["posts"], null | undefined >["data"][number]["attributes"]; -}; +} -export default function PostPreview(props: PostPreviewProps): JSX.Element { +export default function PostPreview(props: Props): JSX.Element { const { post } = props; return ( diff --git a/src/components/PageSelector.tsx b/src/components/PageSelector.tsx index 15c43be..0955af9 100644 --- a/src/components/PageSelector.tsx +++ b/src/components/PageSelector.tsx @@ -1,12 +1,12 @@ import { Dispatch, SetStateAction } from "react"; import Button from "./Button"; -type Props = { +interface Props { className?: string; maxPage: number; page: number; setPage: Dispatch>; -}; +} export default function PageSelector(props: Props): JSX.Element { const { page, setPage, maxPage } = props; diff --git a/src/components/PanelComponents/NavOption.tsx b/src/components/PanelComponents/NavOption.tsx index fc68a8f..9de955a 100644 --- a/src/components/PanelComponents/NavOption.tsx +++ b/src/components/PanelComponents/NavOption.tsx @@ -2,7 +2,7 @@ import ToolTip from "components/ToolTip"; import { useRouter } from "next/router"; import { MouseEventHandler } from "react"; -type NavOptionProps = { +interface Props { url: string; icon?: string; title: string | null | undefined; @@ -10,9 +10,9 @@ type NavOptionProps = { border?: boolean; reduced?: boolean; onClick?: MouseEventHandler; -}; +} -export default function NavOption(props: NavOptionProps): JSX.Element { +export default function NavOption(props: Props): JSX.Element { const router = useRouter(); const isActive = router.asPath.startsWith(props.url); const divActive = "bg-mid shadow-inner-sm shadow-shade"; diff --git a/src/components/PanelComponents/PanelHeader.tsx b/src/components/PanelComponents/PanelHeader.tsx index 286cd01..7eef723 100644 --- a/src/components/PanelComponents/PanelHeader.tsx +++ b/src/components/PanelComponents/PanelHeader.tsx @@ -1,12 +1,12 @@ import HorizontalLine from "components/HorizontalLine"; -type PanelHeaderProps = { +interface Props { icon?: string; title: string | null | undefined; description?: string | null | undefined; -}; +} -export default function PanelHeader(props: PanelHeaderProps): JSX.Element { +export default function PanelHeader(props: Props): JSX.Element { return ( <>
diff --git a/src/components/PanelComponents/ReturnButton.tsx b/src/components/PanelComponents/ReturnButton.tsx index bec0752..c127701 100644 --- a/src/components/PanelComponents/ReturnButton.tsx +++ b/src/components/PanelComponents/ReturnButton.tsx @@ -3,14 +3,14 @@ import HorizontalLine from "components/HorizontalLine"; import { useAppLayout } from "contexts/AppLayoutContext"; import { AppStaticProps } from "queries/getAppStaticProps"; -type ReturnButtonProps = { +interface Props { href: string; title: string | null | undefined; langui: AppStaticProps["langui"]; displayOn: ReturnButtonType; horizontalLine?: boolean; className?: string; -}; +} export enum ReturnButtonType { mobile = "mobile", @@ -18,7 +18,7 @@ export enum ReturnButtonType { both = "both", } -export default function ReturnButton(props: ReturnButtonProps): JSX.Element { +export default function ReturnButton(props: Props): JSX.Element { const appLayout = useAppLayout(); return ( diff --git a/src/components/Panels/ContentPanel.tsx b/src/components/Panels/ContentPanel.tsx index ad86d8a..b583e99 100644 --- a/src/components/Panels/ContentPanel.tsx +++ b/src/components/Panels/ContentPanel.tsx @@ -1,15 +1,15 @@ -type ContentPanelProps = { +interface Props { children: React.ReactNode; autoformat?: boolean; width?: ContentPanelWidthSizes; -}; +} export enum ContentPanelWidthSizes { default = "default", large = "large", } -export default function ContentPanel(props: ContentPanelProps): JSX.Element { +export default function ContentPanel(props: Props): JSX.Element { const width = props.width ? props.width : ContentPanelWidthSizes.default; const widthCSS = width === ContentPanelWidthSizes.default ? "max-w-2xl" : "w-full"; diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index 3fd328b..ee8f636 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -9,11 +9,11 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { AppStaticProps } from "queries/getAppStaticProps"; -type MainPanelProps = { +interface Props { langui: AppStaticProps["langui"]; -}; +} -export default function MainPanel(props: MainPanelProps): JSX.Element { +export default function MainPanel(props: Props): JSX.Element { const { langui } = props; const router = useRouter(); const isDesktop = useMediaDesktop(); diff --git a/src/components/Panels/SubPanel.tsx b/src/components/Panels/SubPanel.tsx index be36a28..4494645 100644 --- a/src/components/Panels/SubPanel.tsx +++ b/src/components/Panels/SubPanel.tsx @@ -1,8 +1,8 @@ -type SubPanelProps = { +interface Props { children: React.ReactNode; -}; +} -export default function SubPanel(props: SubPanelProps): JSX.Element { +export default function SubPanel(props: Props): JSX.Element { return (
{props.children} diff --git a/src/components/Popup.tsx b/src/components/Popup.tsx index 345ca26..b564a65 100644 --- a/src/components/Popup.tsx +++ b/src/components/Popup.tsx @@ -1,7 +1,7 @@ import { Dispatch, SetStateAction } from "react"; import Button from "./Button"; -export type PopupProps = { +interface Props { setState: | Dispatch> | Dispatch>; @@ -9,9 +9,9 @@ export type PopupProps = { children: React.ReactNode; fillViewport?: boolean; hideBackground?: boolean; -}; +} -export default function Popup(props: PopupProps): JSX.Element { +export default function Popup(props: Props): JSX.Element { return (
>; state: number; options: string[]; selected?: number; allowEmpty?: boolean; className?: string; -}; +} -export default function Select(props: SelectProps): JSX.Element { +export default function Select(props: Props): JSX.Element { const [opened, setOpened] = useState(false); return ( diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx index 72cb871..9640fa3 100644 --- a/src/components/Switch.tsx +++ b/src/components/Switch.tsx @@ -1,12 +1,12 @@ import { Dispatch, SetStateAction } from "react"; -export type SwitchProps = { +interface Props { setState: Dispatch>; state: boolean; className?: string; -}; +} -export default function Switch(props: SwitchProps): JSX.Element { +export default function Switch(props: Props): JSX.Element { return (
["data"][number]["attributes"], null | undefined >; -}; +} export default function PostPreview(props: Props): JSX.Element { const { video } = props; diff --git a/src/contexts/AppLayoutContext.tsx b/src/contexts/AppLayoutContext.tsx index b931cdf..de506b2 100644 --- a/src/contexts/AppLayoutContext.tsx +++ b/src/contexts/AppLayoutContext.tsx @@ -2,7 +2,7 @@ import useDarkMode from "hooks/useDarkMode"; import useStateWithLocalStorage from "hooks/useStateWithLocalStorage"; import React, { ReactNode, useContext } from "react"; -export interface AppLayoutState { +interface AppLayoutState { subPanelOpen: boolean | undefined; languagePanelOpen: boolean | undefined; configPanelOpen: boolean | undefined; @@ -68,9 +68,9 @@ export function useAppLayout(): AppLayoutState { return useContext(AppContext); } -type Props = { +interface Props { children: ReactNode; -}; +} export function AppContextProvider(props: Props): JSX.Element { const [subPanelOpen, setSubPanelOpen] = useStateWithLocalStorage< diff --git a/src/graphql/operations/getVideoChannel.graphql b/src/graphql/operations/getVideoChannel.graphql index 0e6472f..17e6072 100644 --- a/src/graphql/operations/getVideoChannel.graphql +++ b/src/graphql/operations/getVideoChannel.graphql @@ -1,36 +1,36 @@ query getVideoChannel($channel: String) { - videoChannels(filters: { uid: { eq: $channel } } ) { - data { - attributes { - uid - title - subscribers - videos (pagination:{limit: -1}) { - data { - id - attributes { - uid - title - views - duration - gone - categories { - data { - id - attributes { - short - } - } - } - published_date { - year - month - day - } - } - } - } - } - } - } + videoChannels(filters: { uid: { eq: $channel } }) { + data { + attributes { + uid + title + subscribers + videos(pagination: { limit: -1 }) { + data { + id + attributes { + uid + title + views + duration + gone + categories { + data { + id + attributes { + short + } + } + } + published_date { + year + month + day + } + } + } + } + } + } + } } diff --git a/src/graphql/operations/getVideoChannelsSlugs.graphql b/src/graphql/operations/getVideoChannelsSlugs.graphql index 410adfe..7be4ea8 100644 --- a/src/graphql/operations/getVideoChannelsSlugs.graphql +++ b/src/graphql/operations/getVideoChannelsSlugs.graphql @@ -1,9 +1,9 @@ query getVideoChannelsSlugs { - videoChannels(pagination: {limit: -1}) { - data { - attributes { + videoChannels(pagination: { limit: -1 }) { + data { + attributes { uid } - } - } + } + } } diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 8a8fcd9..6c69fdf 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -6,9 +6,9 @@ import ContentPanel from "components/Panels/ContentPanel"; import { GetStaticPropsContext } from "next"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; -interface FourOhFourProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function FourOhFour(props: FourOhFourProps): JSX.Element { +export default function FourOhFour(props: Props): JSX.Element { const { langui } = props; const contentPanel = ( @@ -26,8 +26,8 @@ export default function FourOhFour(props: FourOhFourProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: FourOhFourProps }> { - const props: FourOhFourProps = { +): Promise<{ notFound: boolean } | { props: Props }> { + const props: Props = { ...(await getAppStaticProps(context)), }; return { diff --git a/src/pages/500.tsx b/src/pages/500.tsx index c0e77fc..c647c95 100644 --- a/src/pages/500.tsx +++ b/src/pages/500.tsx @@ -6,9 +6,9 @@ import ContentPanel from "components/Panels/ContentPanel"; import { GetStaticPropsContext } from "next"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; -interface FiveHundredProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function FiveHundred(props: FiveHundredProps): JSX.Element { +export default function FiveHundred(props: Props): JSX.Element { const { langui } = props; const contentPanel = ( @@ -26,8 +26,8 @@ export default function FiveHundred(props: FiveHundredProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: FiveHundredProps }> { - const props: FiveHundredProps = { +): Promise<{ notFound: boolean } | { props: Props }> { + const props: Props = { ...(await getAppStaticProps(context)), }; return { diff --git a/src/pages/api/mail.ts b/src/pages/api/mail.ts index 032b5d5..e874acb 100644 --- a/src/pages/api/mail.ts +++ b/src/pages/api/mail.ts @@ -2,17 +2,17 @@ import type { NextApiRequest, NextApiResponse } from "next"; import nodemailer from "nodemailer"; import { SMTPError } from "nodemailer/lib/smtp-connection"; -export type ResponseMailProps = { +export interface ResponseMailProps { code?: string; message?: string; -}; +} -export type RequestMailProps = { +export interface RequestMailProps { name: string; email: string; message: string; formName: string; -}; +} export default async function Mail( req: NextApiRequest, diff --git a/src/pages/api/revalidate.ts b/src/pages/api/revalidate.ts index c45fc78..0a203e7 100644 --- a/src/pages/api/revalidate.ts +++ b/src/pages/api/revalidate.ts @@ -1,7 +1,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import getConfig from "next/config"; -export type RequestProps = +type RequestProps = | HookRangedContent | HookPostContent | HookLibraryItem @@ -9,7 +9,7 @@ export type RequestProps = | HookContent | HookCustom; -export type HookRangedContent = { +type HookRangedContent = { event: "entry.update" | "entry.delete" | "entry.create"; model: "ranged-content"; entry: { @@ -22,19 +22,19 @@ export type HookRangedContent = { }; }; -export type HookCustom = { +type HookCustom = { model: "custom"; url: string; }; -export type HookContent = { +type HookContent = { model: "content"; entry: { slug: string; }; }; -export type HookPostContent = { +type HookPostContent = { event: "entry.update" | "entry.delete" | "entry.create"; model: "post"; entry: { @@ -42,7 +42,7 @@ export type HookPostContent = { }; }; -export type HookLibraryItem = { +type HookLibraryItem = { event: "entry.update" | "entry.delete" | "entry.create"; model: "library-item"; entry: { @@ -50,12 +50,12 @@ export type HookLibraryItem = { }; }; -export type HookChronology = { +type HookChronology = { event: "entry.update" | "entry.delete" | "entry.create"; model: "chronology-era" | "chronology-item"; }; -export type ResponseMailProps = { +type ResponseMailProps = { message: string; revalidated: boolean; }; diff --git a/src/pages/archives/index.tsx b/src/pages/archives/index.tsx index f6d0213..5694feb 100644 --- a/src/pages/archives/index.tsx +++ b/src/pages/archives/index.tsx @@ -5,9 +5,9 @@ import SubPanel from "components/Panels/SubPanel"; import { GetStaticPropsContext } from "next"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; -interface ArchivesProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function Archives(props: ArchivesProps): JSX.Element { +export default function Archives(props: Props): JSX.Element { const { langui } = props; const subPanel = ( @@ -26,8 +26,8 @@ export default function Archives(props: ArchivesProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: ArchivesProps }> { - const props: ArchivesProps = { +): Promise<{ notFound: boolean } | { props: Props }> { + const props: Props = { ...(await getAppStaticProps(context)), }; return { diff --git a/src/pages/archives/videos/index.tsx b/src/pages/archives/videos/index.tsx index 474b482..044da27 100644 --- a/src/pages/archives/videos/index.tsx +++ b/src/pages/archives/videos/index.tsx @@ -72,7 +72,7 @@ export default function Videos(props: Props): JSX.Element { className="mb-12" /> -
+
{paginatedVideos[page].map((video) => ( <> {video.attributes && ( diff --git a/src/pages/archives/videos/v/[uid].tsx b/src/pages/archives/videos/v/[uid].tsx index 039e417..84f6860 100644 --- a/src/pages/archives/videos/v/[uid].tsx +++ b/src/pages/archives/videos/v/[uid].tsx @@ -146,7 +146,9 @@ export default function Video(props: Props): JSX.Element {

{"Channel"}

- diff --git a/src/pages/chronicles/index.tsx b/src/pages/chronicles/index.tsx index 4f1d4f3..f78e0dd 100644 --- a/src/pages/chronicles/index.tsx +++ b/src/pages/chronicles/index.tsx @@ -4,9 +4,9 @@ import SubPanel from "components/Panels/SubPanel"; import { GetStaticPropsContext } from "next"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; -interface ChroniclesProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function Chronicles(props: ChroniclesProps): JSX.Element { +export default function Chronicles(props: Props): JSX.Element { const { langui } = props; const subPanel = ( @@ -24,8 +24,8 @@ export default function Chronicles(props: ChroniclesProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: ChroniclesProps }> { - const props: ChroniclesProps = { +): Promise<{ notFound: boolean } | { props: Props }> { + const props: Props = { ...(await getAppStaticProps(context)), }; return { diff --git a/src/pages/contents/index.tsx b/src/pages/contents/index.tsx index a6e5201..2630d4b 100644 --- a/src/pages/contents/index.tsx +++ b/src/pages/contents/index.tsx @@ -14,13 +14,13 @@ import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import { prettyinlineTitle, prettySlug } from "queries/helpers"; import { useEffect, useState } from "react"; -interface ContentsProps extends AppStaticProps { +interface Props extends AppStaticProps { contents: Exclude["data"]; } -type GroupContentItems = Map; +type GroupContentItems = Map; -export default function Contents(props: ContentsProps): JSX.Element { +export default function Contents(props: Props): JSX.Element { const { langui, contents } = props; const [groupingMethod, setGroupingMethod] = useState(-1); @@ -105,7 +105,7 @@ export default function Contents(props: ContentsProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: ContentsProps }> { +): Promise<{ notFound: boolean } | { props: Props }> { const sdk = getReadySdk(); const contents = await sdk.getContents({ language_code: context.locale ?? "en", @@ -129,7 +129,7 @@ export async function getStaticProps( return titleA.localeCompare(titleB); }); - const props: ContentsProps = { + const props: Props = { ...(await getAppStaticProps(context)), contents: contents.contents.data, }; @@ -141,7 +141,7 @@ export async function getStaticProps( function getGroups( langui: AppStaticProps["langui"], groupByType: number, - items: ContentsProps["contents"] + items: Props["contents"] ): GroupContentItems { switch (groupByType) { case 0: { diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx index ec5bb22..6d8f94f 100644 --- a/src/pages/editor.tsx +++ b/src/pages/editor.tsx @@ -9,9 +9,9 @@ import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; import { useCallback, useState } from "react"; import { default as TurndownService } from "turndown"; -interface EditorProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function Editor(props: EditorProps): JSX.Element { +export default function Editor(props: Props): JSX.Element { const handleInput = useCallback((event) => { setMarkdown(event.target.value); }, []); @@ -91,8 +91,8 @@ export default function Editor(props: EditorProps): JSX.Element { export async function getStaticProps( context: GetStaticPropsContext -): Promise<{ notFound: boolean } | { props: EditorProps }> { - const props: EditorProps = { +): Promise<{ notFound: boolean } | { props: Props }> { + const props: Props = { ...(await getAppStaticProps(context)), }; return { diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index b12514f..03340c9 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -2,9 +2,9 @@ import AppLayout from "components/AppLayout"; import { GetStaticPropsContext } from "next"; import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps"; -interface GalleryProps extends AppStaticProps {} +interface Props extends AppStaticProps {} -export default function Gallery(props: GalleryProps): JSX.Element { +export default function Gallery(props: Props): JSX.Element { const { langui } = props; const contentPanel = (