-
+
-
Accord’s Library
-
- Discover • Analyze • Translate • Archive
-
-
- }
- displayTitle={false}
- displayLanguageSwitcher
- />
- );
-}
+ />
+ Accord’s Library
+
+ Discover • Analyze • Translate • Archive
+
+
+ }
+ displayTitle={false}
+ displayLanguageSwitcher
+ />
+);
+
+export default Home;
+
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
export const getStaticProps = getPostStaticProps("home");
diff --git a/src/pages/library/[slug]/index.tsx b/src/pages/library/[slug]/index.tsx
index b622b78..d85eb3f 100644
--- a/src/pages/library/[slug]/index.tsx
+++ b/src/pages/library/[slug]/index.tsx
@@ -42,14 +42,9 @@ import {
isDefinedAndNotEmpty,
sortContent,
} from "helpers/others";
-
import { useLightBox } from "hooks/useLightBox";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
-import {
- GetStaticPathsContext,
- GetStaticPathsResult,
- GetStaticPropsContext,
-} from "next";
+import { GetStaticPaths, GetStaticPathsResult, GetStaticProps } from "next";
import { Fragment, useCallback, useMemo, useState } from "react";
import { isUntangibleGroupItem } from "helpers/libraryItem";
import { useMediaHoverable } from "hooks/useMediaQuery";
@@ -58,6 +53,12 @@ import { useToggle } from "hooks/useToggle";
import { Ico, Icon } from "components/Ico";
import { cJoin, cIf } from "helpers/className";
import { useSmartLanguage } from "hooks/useSmartLanguage";
+import { getDescription } from "helpers/description";
+
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
interface Props extends AppStaticProps {
item: NonNullable<
@@ -70,8 +71,14 @@ interface Props extends AppStaticProps {
>["data"][number]["id"];
}
-export default function LibrarySlug(props: Props): JSX.Element {
- const { item, itemId, langui, currencies, languages } = props;
+const LibrarySlug = ({
+ item,
+ itemId,
+ langui,
+ currencies,
+ languages,
+ ...otherProps
+}: Props): JSX.Element => {
const appLayout = useAppLayout();
const hoverable = useMediaHoverable();
const [openLightBox, LightBox] = useLightBox();
@@ -192,12 +199,11 @@ export default function LibrarySlug(props: Props): JSX.Element {
)}
-
+ {!isUntangibleGroupItem(item.metadata?.[0]) &&
+ isDefinedAndNotEmpty(itemId) && (
+
+ )}
+
{item.descriptions?.[0] && (
{item.descriptions[0].description}
@@ -479,15 +485,9 @@ export default function LibrarySlug(props: Props): JSX.Element {
position: "Bottom",
}}
infoAppend={
-
+ !isUntangibleGroupItem(
+ subitem.attributes.metadata?.[0]
+ ) &&
}
/>
@@ -598,15 +598,25 @@ export default function LibrarySlug(props: Props): JSX.Element {
contentPanel={contentPanel}
subPanel={subPanel}
thumbnail={item.thumbnail?.data?.attributes ?? undefined}
- description={item.descriptions?.[0]?.description ?? undefined}
- {...props}
+ description={getDescription({
+ langui,
+ description: item.descriptions?.[0]?.description,
+ })}
+ currencies={currencies}
+ languages={languages}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default LibrarySlug;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const item = await sdk.getLibraryItem({
slug:
@@ -625,11 +635,11 @@ export async function getStaticProps(
return {
props: props,
};
-}
+};
-export async function getStaticPaths(
- context: GetStaticPathsContext
-): Promise {
+// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
+
+export const getStaticPaths: GetStaticPaths = async (context) => {
const sdk = getReadySdk();
const libraryItems = await sdk.getLibraryItemsSlugs();
const paths: GetStaticPathsResult["paths"] = [];
@@ -638,12 +648,16 @@ export async function getStaticPaths(
paths.push({ params: { slug: item.attributes.slug }, locale: local })
);
});
-
return {
paths,
fallback: "blocking",
};
-}
+};
+
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ PRIVATE COMPONENTS ╰──────────────────────────────────────
+ */
interface ContentLineProps {
content?: {
@@ -665,17 +679,15 @@ interface ContentLineProps {
hasScanSet: boolean;
}
-export function ContentLine(props: ContentLineProps): JSX.Element {
- const {
- rangeStart,
- content,
- langui,
- languages,
- hasScanSet,
- slug,
- parentSlug,
- } = props;
-
+const ContentLine = ({
+ rangeStart,
+ content,
+ langui,
+ languages,
+ hasScanSet,
+ slug,
+ parentSlug,
+}: ContentLineProps): JSX.Element => {
const [opened, setOpened] = useState(false);
const toggleOpened = useToggle(setOpened);
@@ -753,6 +765,4 @@ export function ContentLine(props: ContentLineProps): JSX.Element {
);
-
- return <>>;
-}
+};
diff --git a/src/pages/library/[slug]/scans.tsx b/src/pages/library/[slug]/scans.tsx
index a1aa170..16ecd4c 100644
--- a/src/pages/library/[slug]/scans.tsx
+++ b/src/pages/library/[slug]/scans.tsx
@@ -18,13 +18,14 @@ import { prettyinlineTitle, prettySlug } from "helpers/formatters";
import { filterHasAttributes, isDefined, sortContent } from "helpers/others";
import { useLightBox } from "hooks/useLightBox";
-import {
- GetStaticPathsContext,
- GetStaticPathsResult,
- GetStaticPropsContext,
-} from "next";
+import { GetStaticPaths, GetStaticPathsResult, GetStaticProps } from "next";
import { Fragment, useMemo } from "react";
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
+
interface Props extends AppStaticProps {
item: NonNullable<
NonNullable<
@@ -36,8 +37,12 @@ interface Props extends AppStaticProps {
>;
}
-export default function LibrarySlug(props: Props): JSX.Element {
- const { item, langui, languages } = props;
+const LibrarySlug = ({
+ item,
+ langui,
+ languages,
+ ...otherProps
+}: Props): JSX.Element => {
const [openLightBox, LightBox] = useLightBox();
sortContent(item.contents);
@@ -129,14 +134,20 @@ export default function LibrarySlug(props: Props): JSX.Element {
contentPanel={contentPanel}
subPanel={subPanel}
thumbnail={item.thumbnail?.data?.attributes ?? undefined}
- {...props}
+ languages={languages}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default LibrarySlug;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const item = await sdk.getLibraryItemScans({
slug:
@@ -155,11 +166,11 @@ export async function getStaticProps(
return {
props: props,
};
-}
+};
-export async function getStaticPaths(
- context: GetStaticPathsContext
-): Promise {
+// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
+
+export const getStaticPaths: GetStaticPaths = async (context) => {
const sdk = getReadySdk();
const libraryItems = await sdk.getLibraryItemsSlugs({});
const paths: GetStaticPathsResult["paths"] = [];
@@ -173,4 +184,4 @@ export async function getStaticPaths(
paths,
fallback: "blocking",
};
-}
+};
diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx
index 52e3adb..aca6e9f 100644
--- a/src/pages/library/index.tsx
+++ b/src/pages/library/index.tsx
@@ -13,7 +13,7 @@ import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
import { getReadySdk } from "graphql/sdk";
import { prettyItemSubType } from "helpers/formatters";
import { LibraryItemUserStatus } from "helpers/types";
-import { GetStaticPropsContext } from "next";
+import { GetStaticProps } from "next";
import { Fragment, useState, useMemo } from "react";
import { Icon } from "components/Ico";
import { WithLabel } from "components/Inputs/WithLabel";
@@ -38,11 +38,12 @@ import {
} from "helpers/others";
import { ContentPlaceholder } from "components/PanelComponents/ContentPlaceholder";
-interface Props extends AppStaticProps {
- items: NonNullable["data"];
-}
+/*
+ * ╭─────────────╮
+ * ────────────────────────────────────────╯ CONSTANTS ╰──────────────────────────────────────────
+ */
-const defaultFiltersState = {
+const DEFAULT_FILTERS_STATE = {
searchName: "",
showSubitems: false,
showPrimaryItems: true,
@@ -53,33 +54,48 @@ const defaultFiltersState = {
filterUserStatus: undefined,
};
-export default function Library(props: Props): JSX.Element {
- const { langui, items: libraryItems, currencies } = props;
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
+
+interface Props extends AppStaticProps {
+ items: NonNullable["data"];
+}
+
+const Library = ({
+ langui,
+ items: libraryItems,
+ currencies,
+ ...otherProps
+}: Props): JSX.Element => {
const appLayout = useAppLayout();
const hoverable = useMediaHoverable();
- const [searchName, setSearchName] = useState(defaultFiltersState.searchName);
+ const [searchName, setSearchName] = useState(
+ DEFAULT_FILTERS_STATE.searchName
+ );
const [showSubitems, setShowSubitems] = useState(
- defaultFiltersState.showSubitems
+ DEFAULT_FILTERS_STATE.showSubitems
);
const [showPrimaryItems, setShowPrimaryItems] = useState(
- defaultFiltersState.showPrimaryItems
+ DEFAULT_FILTERS_STATE.showPrimaryItems
);
const [showSecondaryItems, setShowSecondaryItems] = useState(
- defaultFiltersState.showSecondaryItems
+ DEFAULT_FILTERS_STATE.showSecondaryItems
);
const [sortingMethod, setSortingMethod] = useState(
- defaultFiltersState.sortingMethod
+ DEFAULT_FILTERS_STATE.sortingMethod
);
const [groupingMethod, setGroupingMethod] = useState(
- defaultFiltersState.groupingMethod
+ DEFAULT_FILTERS_STATE.groupingMethod
);
const [keepInfoVisible, setKeepInfoVisible] = useState(
- defaultFiltersState.keepInfoVisible
+ DEFAULT_FILTERS_STATE.keepInfoVisible
);
const [filterUserStatus, setFilterUserStatus] = useState<
LibraryItemUserStatus | undefined
- >(defaultFiltersState.filterUserStatus);
+ >(DEFAULT_FILTERS_STATE.filterUserStatus);
const filteredItems = useMemo(
() =>
@@ -193,7 +209,6 @@ export default function Library(props: Props): JSX.Element {
/>
)}
- {/* TODO: Add "All" to langui */}
setFilterUserStatus(undefined),
active: isUndefined(filterUserStatus),
},
@@ -229,14 +244,14 @@ export default function Library(props: Props): JSX.Element {
text={langui.reset_all_filters}
icon={Icon.Replay}
onClick={() => {
- setSearchName(defaultFiltersState.searchName);
- setShowSubitems(defaultFiltersState.showSubitems);
- setShowPrimaryItems(defaultFiltersState.showPrimaryItems);
- setShowSecondaryItems(defaultFiltersState.showSecondaryItems);
- setSortingMethod(defaultFiltersState.sortingMethod);
- setGroupingMethod(defaultFiltersState.groupingMethod);
- setKeepInfoVisible(defaultFiltersState.keepInfoVisible);
- setFilterUserStatus(defaultFiltersState.filterUserStatus);
+ setSearchName(DEFAULT_FILTERS_STATE.searchName);
+ setShowSubitems(DEFAULT_FILTERS_STATE.showSubitems);
+ setShowPrimaryItems(DEFAULT_FILTERS_STATE.showPrimaryItems);
+ setShowSecondaryItems(DEFAULT_FILTERS_STATE.showSecondaryItems);
+ setSortingMethod(DEFAULT_FILTERS_STATE.sortingMethod);
+ setGroupingMethod(DEFAULT_FILTERS_STATE.groupingMethod);
+ setKeepInfoVisible(DEFAULT_FILTERS_STATE.keepInfoVisible);
+ setFilterUserStatus(DEFAULT_FILTERS_STATE.filterUserStatus);
}}
/>
@@ -258,12 +273,9 @@ export default function Library(props: Props): JSX.Element {
const contentPanel = useMemo(
() => (
- {/* TODO: Add to langui */}
{groups.size === 0 && (
)}
@@ -314,13 +326,9 @@ export default function Library(props: Props): JSX.Element {
position: "Bottom",
}}
infoAppend={
-
+ !isUntangibleGroupItem(item.attributes.metadata?.[0]) && (
+
+ )
}
/>
@@ -339,14 +347,20 @@ export default function Library(props: Props): JSX.Element {
subPanel={subPanel}
contentPanel={contentPanel}
subPanelIcon={Icon.Search}
- {...props}
+ currencies={currencies}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default Library;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const items = await sdk.getLibraryItemsPreview({
language_code: context.locale ?? "en",
@@ -359,4 +373,4 @@ export async function getStaticProps(
return {
props: props,
};
-}
+};
diff --git a/src/pages/merch/index.tsx b/src/pages/merch/index.tsx
index 97a5c08..97c2a79 100644
--- a/src/pages/merch/index.tsx
+++ b/src/pages/merch/index.tsx
@@ -3,15 +3,19 @@ import { PanelHeader } from "components/PanelComponents/PanelHeader";
import { SubPanel } from "components/Panels/SubPanel";
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
-import { GetStaticPropsContext } from "next";
+import { GetStaticProps } from "next";
import { Icon } from "components/Ico";
-import { useMemo } from "react";
+
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
interface Props extends AppStaticProps {}
-export default function Merch(props: Props): JSX.Element {
- const { langui } = props;
- const subPanel = useMemo(
- () => (
+const Merch = ({ langui, ...otherProps }: Props): JSX.Element => (
+
- ),
- [langui]
- );
+ }
+ langui={langui}
+ {...otherProps}
+ />
+);
+export default Merch;
- return ;
-}
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+export const getStaticProps: GetStaticProps = async (context) => {
const props: Props = {
...(await getAppStaticProps(context)),
};
return {
props: props,
};
-}
+};
diff --git a/src/pages/news/[slug].tsx b/src/pages/news/[slug].tsx
index 8b0f21b..df47c7a 100644
--- a/src/pages/news/[slug].tsx
+++ b/src/pages/news/[slug].tsx
@@ -6,45 +6,43 @@ import {
} from "graphql/getPostStaticProps";
import { getReadySdk } from "graphql/sdk";
import { filterHasAttributes, isDefined } from "helpers/others";
+import { GetStaticPaths, GetStaticPathsResult, GetStaticProps } from "next";
-import {
- GetStaticPathsContext,
- GetStaticPathsResult,
- GetStaticPropsContext,
-} from "next";
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
interface Props extends AppStaticProps, PostStaticProps {}
-export default function LibrarySlug(props: Props): JSX.Element {
- const { post, langui, languages, currencies } = props;
- return (
-
- );
-}
+const LibrarySlug = (props: Props): JSX.Element => (
+
+);
+export default LibrarySlug;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const slug =
context.params && isDefined(context.params.slug)
? context.params.slug.toString()
: "";
return await getPostStaticProps(slug)(context);
-}
+};
-export async function getStaticPaths(
- context: GetStaticPathsContext
-): Promise {
+// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
+
+export const getStaticPaths: GetStaticPaths = async (context) => {
const sdk = getReadySdk();
const posts = await sdk.getPostsSlugs();
const paths: GetStaticPathsResult["paths"] = [];
@@ -58,4 +56,4 @@ export async function getStaticPaths(
paths,
fallback: "blocking",
};
-}
+};
diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx
index a1cab9e..c764895 100644
--- a/src/pages/news/index.tsx
+++ b/src/pages/news/index.tsx
@@ -12,7 +12,7 @@ import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
import { getReadySdk } from "graphql/sdk";
import { prettyDate, prettySlug } from "helpers/formatters";
-import { GetStaticPropsContext } from "next";
+import { GetStaticProps } from "next";
import { Fragment, useMemo, useState } from "react";
import { Icon } from "components/Ico";
import { WithLabel } from "components/Inputs/WithLabel";
@@ -21,24 +21,32 @@ import { Button } from "components/Inputs/Button";
import { useMediaHoverable } from "hooks/useMediaQuery";
import { filterHasAttributes } from "helpers/others";
-interface Props extends AppStaticProps {
- posts: NonNullable["data"];
-}
+/*
+ * ╭─────────────╮
+ * ────────────────────────────────────────╯ CONSTANTS ╰──────────────────────────────────────────
+ */
-const defaultFiltersState = {
+const DEFAULT_FILTERS_STATE = {
searchName: "",
keepInfoVisible: true,
};
-export default function News(props: Props): JSX.Element {
- const { langui } = props;
- const posts = sortPosts(props.posts);
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
+
+interface Props extends AppStaticProps {
+ posts: NonNullable["data"];
+}
+
+const News = ({ langui, posts, ...otherProps }: Props): JSX.Element => {
const hoverable = useMediaHoverable();
-
- const [searchName, setSearchName] = useState(defaultFiltersState.searchName);
-
+ const [searchName, setSearchName] = useState(
+ DEFAULT_FILTERS_STATE.searchName
+ );
const [keepInfoVisible, setKeepInfoVisible] = useState(
- defaultFiltersState.keepInfoVisible
+ DEFAULT_FILTERS_STATE.keepInfoVisible
);
const filteredItems = useMemo(
@@ -76,8 +84,8 @@ export default function News(props: Props): JSX.Element {
text={langui.reset_all_filters}
icon={Icon.Replay}
onClick={() => {
- setSearchName(defaultFiltersState.searchName);
- setKeepInfoVisible(defaultFiltersState.keepInfoVisible);
+ setSearchName(DEFAULT_FILTERS_STATE.searchName);
+ setKeepInfoVisible(DEFAULT_FILTERS_STATE.keepInfoVisible);
}}
/>
@@ -127,14 +135,19 @@ export default function News(props: Props): JSX.Element {
subPanel={subPanel}
contentPanel={contentPanel}
subPanelIcon={Icon.Search}
- {...props}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default News;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const posts = await sdk.getPostsPreview({
language_code: context.locale ?? "en",
@@ -142,25 +155,31 @@ export async function getStaticProps(
if (!posts.posts) return { notFound: true };
const props: Props = {
...(await getAppStaticProps(context)),
- posts: posts.posts.data,
+ posts: sortPosts(posts.posts.data),
};
return {
props: props,
};
-}
+};
-function sortPosts(posts: Props["posts"]): Props["posts"] {
- return posts
+/*
+ * ╭───────────────────╮
+ * ─────────────────────────────────────╯ PRIVATE METHODS ╰───────────────────────────────────────
+ */
+
+const sortPosts = (posts: Props["posts"]): Props["posts"] =>
+ posts
.sort((a, b) => {
const dateA = a.attributes?.date ? prettyDate(a.attributes.date) : "9999";
const dateB = b.attributes?.date ? prettyDate(b.attributes.date) : "9999";
return dateA.localeCompare(dateB);
})
.reverse();
-}
-function filterItems(posts: Props["posts"], searchName: string) {
- return posts.filter((post) => {
+// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
+
+const filterItems = (posts: Props["posts"], searchName: string) =>
+ posts.filter((post) => {
if (searchName.length > 1) {
if (
post.attributes?.translations?.[0]?.title
@@ -173,4 +192,3 @@ function filterItems(posts: Props["posts"], searchName: string) {
}
return true;
});
-}
diff --git a/src/pages/wiki/[slug]/index.tsx b/src/pages/wiki/[slug]/index.tsx
index d54d4d0..5069bc1 100644
--- a/src/pages/wiki/[slug]/index.tsx
+++ b/src/pages/wiki/[slug]/index.tsx
@@ -21,20 +21,19 @@ import {
} from "helpers/others";
import { WikiPageWithTranslations } from "helpers/types";
import { useSmartLanguage } from "hooks/useSmartLanguage";
-import {
- GetStaticPathsContext,
- GetStaticPathsResult,
- GetStaticPropsContext,
-} from "next";
+import { GetStaticPaths, GetStaticPathsResult, GetStaticProps } from "next";
import { useCallback, useMemo } from "react";
interface Props extends AppStaticProps {
page: WikiPageWithTranslations;
}
-export default function WikiPage(props: Props): JSX.Element {
- const { page, langui, languages } = props;
-
+const WikiPage = ({
+ page,
+ langui,
+ languages,
+ ...otherProps
+}: Props): JSX.Element => {
const [selectedTranslation, LanguageSwitcher, languageSwitcherProps] =
useSmartLanguage({
items: page.translations,
@@ -143,14 +142,15 @@ export default function WikiPage(props: Props): JSX.Element {
navTitle={langui.news}
subPanel={subPanel}
contentPanel={contentPanel}
- {...props}
+ languages={languages}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default WikiPage;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const slug =
context.params && isDefined(context.params.slug)
@@ -169,11 +169,9 @@ export async function getStaticProps(
return {
props: props,
};
-}
+};
-export async function getStaticPaths(
- context: GetStaticPathsContext
-): Promise {
+export const getStaticPaths: GetStaticPaths = async (context) => {
const sdk = getReadySdk();
const contents = await sdk.getWikiPagesSlugs();
const paths: GetStaticPathsResult["paths"] = [];
@@ -189,4 +187,4 @@ export async function getStaticPaths(
paths,
fallback: "blocking",
};
-}
+};
diff --git a/src/pages/wiki/chronology.tsx b/src/pages/wiki/chronology.tsx
index ba73b1d..1b2f4af 100644
--- a/src/pages/wiki/chronology.tsx
+++ b/src/pages/wiki/chronology.tsx
@@ -13,9 +13,14 @@ import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
import { getReadySdk } from "graphql/sdk";
import { prettySlug } from "helpers/formatters";
import { filterHasAttributes, isDefined } from "helpers/others";
-import { GetStaticPropsContext } from "next";
+import { GetStaticProps } from "next";
import { Fragment, useMemo } from "react";
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
+
interface Props extends AppStaticProps {
chronologyItems: NonNullable<
GetChronologyItemsQuery["chronologyItems"]
@@ -23,9 +28,12 @@ interface Props extends AppStaticProps {
chronologyEras: NonNullable["data"];
}
-export default function Chronology(props: Props): JSX.Element {
- const { chronologyItems, chronologyEras, langui } = props;
-
+const Chronology = ({
+ chronologyItems,
+ chronologyEras,
+ langui,
+ ...otherProps
+}: Props): JSX.Element => {
// Group by year the Chronology items
const chronologyItemYearGroups = useMemo(() => {
const memo: Props["chronologyItems"][number][][][] = [];
@@ -141,14 +149,19 @@ export default function Chronology(props: Props): JSX.Element {
navTitle={langui.chronology}
contentPanel={contentPanel}
subPanel={subPanel}
- {...props}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default Chronology;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const chronologyItems = await sdk.getChronologyItems({
language_code: context.locale ?? "en",
@@ -166,4 +179,4 @@ export async function getStaticProps(
return {
props: props,
};
-}
+};
diff --git a/src/pages/wiki/index.tsx b/src/pages/wiki/index.tsx
index 5e73cce..f0e194d 100644
--- a/src/pages/wiki/index.tsx
+++ b/src/pages/wiki/index.tsx
@@ -4,7 +4,7 @@ import { PanelHeader } from "components/PanelComponents/PanelHeader";
import { SubPanel } from "components/Panels/SubPanel";
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
-import { GetStaticPropsContext } from "next";
+import { GetStaticProps } from "next";
import { Icon } from "components/Ico";
import { getReadySdk } from "graphql/sdk";
import { GetWikiPagesPreviewsQuery } from "graphql/generated";
@@ -23,23 +23,38 @@ import { useMediaHoverable } from "hooks/useMediaQuery";
import { filterHasAttributes } from "helpers/others";
import { ContentPlaceholder } from "components/PanelComponents/ContentPlaceholder";
-interface Props extends AppStaticProps {
- pages: NonNullable["data"];
-}
+/*
+ * ╭─────────────╮
+ * ────────────────────────────────────────╯ CONSTANTS ╰──────────────────────────────────────────
+ */
-const defaultFiltersState = {
+const DEFAULT_FILTERS_STATE = {
searchName: "",
keepInfoVisible: true,
};
-export default function Wiki(props: Props): JSX.Element {
- const { langui, languages } = props;
- const pages = sortPages(props.pages);
+/*
+ * ╭────────╮
+ * ──────────────────────────────────────────╯ PAGE ╰─────────────────────────────────────────────
+ */
+
+interface Props extends AppStaticProps {
+ pages: NonNullable["data"];
+}
+
+const Wiki = ({
+ langui,
+ languages,
+ pages,
+ ...otherProps
+}: Props): JSX.Element => {
const hoverable = useMediaHoverable();
- const [searchName, setSearchName] = useState(defaultFiltersState.searchName);
+ const [searchName, setSearchName] = useState(
+ DEFAULT_FILTERS_STATE.searchName
+ );
const [keepInfoVisible, setKeepInfoVisible] = useState(
- defaultFiltersState.keepInfoVisible
+ DEFAULT_FILTERS_STATE.keepInfoVisible
);
const filteredPages = useMemo(
@@ -77,14 +92,13 @@ export default function Wiki(props: Props): JSX.Element {
text={langui.reset_all_filters}
icon={Icon.Replay}
onClick={() => {
- setSearchName(defaultFiltersState.searchName);
- setKeepInfoVisible(defaultFiltersState.keepInfoVisible);
+ setSearchName(DEFAULT_FILTERS_STATE.searchName);
+ setKeepInfoVisible(DEFAULT_FILTERS_STATE.keepInfoVisible);
}}
/>
- {/* TODO: Langui */}
- Special Pages
+ {langui.special_pages}
@@ -99,12 +113,9 @@ export default function Wiki(props: Props): JSX.Element {
className="grid grid-cols-2 items-end gap-8
desktop:grid-cols-[repeat(auto-fill,_minmax(20rem,1fr))] mobile:gap-4"
>
- {/* TODO: Add to langui */}
{filteredPages.length === 0 && (
)}
@@ -137,7 +148,7 @@ export default function Wiki(props: Props): JSX.Element {
),
- [filteredPages, keepInfoVisible, languages]
+ [filteredPages, keepInfoVisible, languages, langui]
);
return (
@@ -146,36 +157,48 @@ export default function Wiki(props: Props): JSX.Element {
subPanel={subPanel}
contentPanel={contentPanel}
subPanelIcon={Icon.Search}
- {...props}
+ languages={languages}
+ langui={langui}
+ {...otherProps}
/>
);
-}
+};
+export default Wiki;
-export async function getStaticProps(
- context: GetStaticPropsContext
-): Promise<{ notFound: boolean } | { props: Props }> {
+/*
+ * ╭──────────────────────╮
+ * ───────────────────────────────────╯ NEXT DATA FETCHING ╰──────────────────────────────────────
+ */
+
+export const getStaticProps: GetStaticProps = async (context) => {
const sdk = getReadySdk();
const pages = await sdk.getWikiPagesPreviews({});
if (!pages.wikiPages?.data) return { notFound: true };
const props: Props = {
...(await getAppStaticProps(context)),
- pages: pages.wikiPages.data,
+ pages: sortPages(pages.wikiPages.data),
};
return {
props: props,
};
-}
+};
-function sortPages(pages: Props["pages"]): Props["pages"] {
- return pages.sort((a, b) => {
+/*
+ * ╭───────────────────╮
+ * ─────────────────────────────────────╯ PRIVATE METHODS ╰───────────────────────────────────────
+ */
+
+const sortPages = (pages: Props["pages"]): Props["pages"] =>
+ pages.sort((a, b) => {
const slugA = a.attributes?.slug ?? "";
const slugB = b.attributes?.slug ?? "";
return slugA.localeCompare(slugB);
});
-}
-function filterPages(posts: Props["pages"], searchName: string) {
- return posts.filter((post) => {
+// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
+
+const filterPages = (posts: Props["pages"], searchName: string) =>
+ posts.filter((post) => {
if (searchName.length > 1) {
if (
post.attributes?.translations?.[0]?.title
@@ -188,4 +211,3 @@ function filterPages(posts: Props["pages"], searchName: string) {
}
return true;
});
-}
diff --git a/tailwind.config.js b/tailwind.config.js
index b93f021..83ddbf6 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,9 +1,7 @@
const plugin = require("tailwindcss/plugin");
const { breaks, colors, fonts, fontFamilies } = require("./design.config.js");
-function rgb(color) {
- return [color.r, color.g, color.b].join(" ");
-}
+const rgb = (color) => [color.r, color.g, color.b].join(" ");
/** @type {import('tailwindcss').Config} */
module.exports = {
@@ -38,7 +36,7 @@ module.exports = {
},
},
plugins: [
- plugin(function ({ addUtilities }) {
+ plugin(({ addUtilities }) => {
addUtilities({
".set-theme-light": {
"--theme-color-highlight": rgb(colors.light.hightlight),
@@ -63,7 +61,7 @@ module.exports = {
});
}),
- plugin(function ({ addUtilities }) {
+ plugin(({ addUtilities }) => {
addUtilities({
".set-theme-font-standard": {
"--theme-font-body": fontFamilies.standard.body,
@@ -78,7 +76,7 @@ module.exports = {
});
}),
- plugin(function ({ addVariant, e }) {
+ plugin(({ addVariant, e }) => {
addVariant("webkit-scrollbar", ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(
@@ -89,7 +87,7 @@ module.exports = {
}),
// Colored Dropshadow
- plugin(function ({ addUtilities }) {
+ plugin(({ addUtilities }) => {
addUtilities({
".drop-shadow-shade-md": {
filter: `
@@ -131,7 +129,7 @@ module.exports = {
});
}),
- plugin(function ({ addUtilities }) {
+ plugin(({ addUtilities }) => {
addUtilities({
".linearbg-obi": {
background: `linear-gradient(
@@ -145,7 +143,7 @@ module.exports = {
});
}),
- plugin(function ({ addUtilities }) {
+ plugin(({ addUtilities }) => {
addUtilities({
".break-words": {
"word-break": "break-word",