@@ -58,11 +57,8 @@ export async function getStaticProps({ params: { slug } }: StaticProps) {
return {
props: {
mdxSource,
- month: frontmatter.month,
- date: frontmatter.date,
- bio: frontmatter.bio,
- pic: frontmatter.pic,
- path: frontmatter.path,
+ frontmatter,
+ slug,
},
};
}
diff --git a/src/pages/under-the-radar/index.tsx b/src/pages/under-the-radar/index.tsx
index 8ddf5412..b00e146a 100644
--- a/src/pages/under-the-radar/index.tsx
+++ b/src/pages/under-the-radar/index.tsx
@@ -1,11 +1,10 @@
-import { InferGetStaticPropsType } from "next";
import { GetStaticProps } from "next/types";
import Error from "components/Error";
import { useSearchFilter } from "hooks/useSearchFilter.hook";
import { TextCard } from "components/Card";
import styles from "styles/page.module.scss";
-import { AllPostProps } from "types/frontmatter";
+import { PostProps } from "types/frontmatter";
import { SearchBox } from "components/SearchBox";
import { getPosts } from "utils/getPosts";
import PageMetaData from "components/PageMetaData";
@@ -14,11 +13,9 @@ import { sortByMostRecentDate } from "utils";
import { Loading } from "components/Loading";
import { SocialGroup } from "components/Icon";
-export default function UnderTheRadarPage({
- radars,
-}: InferGetStaticPropsType) {
+export default function UnderTheRadarPage({ radars }: { radars: PostProps[] }) {
const { searchError, filter, searchHasErrored, postCards, handleSearchChange } =
- useSearchFilter(radars);
+ useSearchFilter(radars);
if (searchHasErrored) return ;
@@ -41,7 +38,7 @@ export default function UnderTheRadarPage({
- {postCards.map((radar: AllPostProps) => (
+ {postCards.map((radar) => (
, Record>;
slug: string;
- frontmatter: IGigs | IFreshJuice | INews | ITakeover | IRadio | ITopTen | IPremiere;
}
-interface Frontmatter {
- title: string;
- name: string;
- date: string;
- pic: string;
- path: string;
- bio: string;
- postLink: string;
+export interface StaticProps {
+ params: {
+ slug: string;
+ };
}
-export interface IGigs extends Frontmatter {
+interface Optionals {
tags: string;
city: string;
anames: string[];
- tickets: string;
-}
-
-interface IFreshJuice extends Frontmatter {
- tags: string;
bandcamp: string;
- artist?: string;
-}
-
-interface INews extends Frontmatter {
- tags: string;
- tickets?: string;
- seeMore?: string;
-}
-
-interface IPremiere extends Frontmatter {
+ artist: string;
+ tickets: string;
listen: string;
-}
-
-interface ITakeover extends Frontmatter {
- artistPage: string;
-}
-
-interface IRadio extends Omit {
artistPage: string;
+ seeMore: string;
mixLink: string;
-}
-
-interface ITopTen extends Omit {
- tags: string;
cover: string;
header: string;
insta: string;
+ youtube: string;
+ gallery: string;
+ gallerySize: number;
+ intro: string;
+ month: string;
+}
+
+export interface Frontmatter extends Partial {
+ title: string;
+ name: string;
+ date: string;
+ pic: string;
+ path: string;
+ bio: string;
+ postLink: string;
+}
+
+export interface PostProps {
+ slug: string;
+ frontmatter: Frontmatter;
}
export interface CardProps {
@@ -70,9 +66,3 @@ export interface FilterProps {
city: string;
};
}
-
-export interface StaticProps {
- params: {
- slug: string;
- };
-}
diff --git a/src/utils/getAllPosts.ts b/src/utils/getAllPosts.ts
index 1b608f91..c112432b 100644
--- a/src/utils/getAllPosts.ts
+++ b/src/utils/getAllPosts.ts
@@ -2,14 +2,14 @@
import matter from "gray-matter";
import { resolve } from "path";
import { promises as fs } from "fs";
-import { AllPostProps } from "types/frontmatter";
+import { Frontmatter, PostProps } from "types/frontmatter";
/**
* Recursively Reading All Files From a Directory
* An async iterator that returns a result whenever
* the necessary async operations complete
*/
-async function* recursiveFind(dir: string) {
+async function* recursiveFind(dir: string): AsyncGenerator {
const posts = await fs.readdir(dir, { withFileTypes: true });
for (const dirPath of posts) {
const res = resolve(dir, dirPath.name);
@@ -17,7 +17,8 @@ async function* recursiveFind(dir: string) {
yield* recursiveFind(res);
} else {
const fileContents = await fs.readFile(res, "utf8");
- const { data: frontmatter } = matter(fileContents);
+ const { data } = matter(fileContents);
+ const frontmatter: Frontmatter = data as Frontmatter;
const slug = dirPath.name.replace(".mdx", "");
yield { frontmatter, slug };
}
@@ -27,9 +28,9 @@ async function* recursiveFind(dir: string) {
* we can "consume" an entire async iterator and
* push the results into an array.
*/
-export const getAllPosts = async () => {
- const posts = await recursiveFind("src/posts");
- const res: AllPostProps[] = [];
+export const getAllPosts = async (): Promise => {
+ const posts = recursiveFind("src/posts");
+ const res = [];
for await (const item of posts) {
res.push(item);
}
diff --git a/src/utils/getPosts.ts b/src/utils/getPosts.ts
index 7a7d36e1..f0c33f2b 100644
--- a/src/utils/getPosts.ts
+++ b/src/utils/getPosts.ts
@@ -1,15 +1,18 @@
import matter from "gray-matter";
import { join, resolve } from "path";
import { promises as fs } from "fs";
+import { Frontmatter, PostProps } from "types/frontmatter";
-export const getPosts = async (dir: string) => {
+export const getPosts = async (dir: string): Promise => {
const files = await fs.readdir(join("src/posts", dir), { withFileTypes: true });
const posts = [];
for await (const dirPath of files) {
const res = resolve("src/posts", dir, dirPath.name);
const fileContents = await fs.readFile(res, "utf8");
- const { data: frontmatter } = matter(fileContents);
+
+ const { data } = matter(fileContents);
+ const frontmatter: Frontmatter = data as Frontmatter;
const slug = dirPath.name.replace(".mdx", "");
posts.push({ frontmatter, slug });
}
diff --git a/src/utils/sortAlphabetically.ts b/src/utils/sortAlphabetically.ts
index b2444324..d8fbeaaf 100644
--- a/src/utils/sortAlphabetically.ts
+++ b/src/utils/sortAlphabetically.ts
@@ -1,10 +1,8 @@
-interface GuestProp {
- img: string;
- link: string;
+interface SortProp {
name: string;
}
-export const sortAlphabetically = (a: GuestProp, b: GuestProp) => {
+export const sortAlphabetically = (a: SortProp, b: SortProp) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
diff --git a/tsconfig.json b/tsconfig.json
index d0c51c81..941197c3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -10,7 +10,7 @@
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
- "strict": false,
+ "strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,