From 686c05127863192481981324fffca2f47d106293 Mon Sep 17 00:00:00 2001 From: leomet07 Date: Sun, 15 Oct 2023 17:12:11 -0400 Subject: [PATCH] Convert all components to not be anonymous functions anonymous functions MAY break fast refresh, so don't use them for components --- pages/404.tsx | 2 +- pages/_error.tsx | 2 +- pages/about.tsx | 84 +++++++++---------- pages/about/advertise.tsx | 2 +- pages/about/contact.tsx | 2 +- pages/about/developers.tsx | 46 +++++----- pages/about/our-charter.tsx | 2 +- pages/about/sponsors.tsx | 2 +- pages/about/staff.tsx | 2 +- pages/article/[article_slug].tsx | 3 +- pages/department/[department].tsx | 2 +- .../department/[department]/[sub_section].tsx | 7 +- pages/index.tsx | 2 +- pages/search.tsx | 2 +- pages/staff/[staff_identifier].tsx | 2 +- pages/subscribe.tsx | 2 +- pages/volume/[volume]/issue/[issue].tsx | 2 +- 17 files changed, 83 insertions(+), 83 deletions(-) diff --git a/pages/404.tsx b/pages/404.tsx index c5f3878..a543951 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -3,7 +3,7 @@ import styles from "../styles/404.module.css"; import { useEffect, useState } from "react"; import Link from "next/link"; -const Fourzerofour = (props: any) => { +function Fourzerofour(props: any) { const [location, setLocation] = useState(""); useEffect(() => setLocation(window.location.pathname), []); // window object is available in useEffect diff --git a/pages/_error.tsx b/pages/_error.tsx index db5c419..8f0d12c 100644 --- a/pages/_error.tsx +++ b/pages/_error.tsx @@ -1,7 +1,7 @@ import Head from "next/head"; import styles from "../styles/Error.module.css"; -const Error = () => { +function Error() { return (
diff --git a/pages/about.tsx b/pages/about.tsx index bbfd75e..e3a1409 100644 --- a/pages/about.tsx +++ b/pages/about.tsx @@ -4,54 +4,54 @@ import Image from "next/image"; import one_hundred_years_logo from "../public/images/100years_logo.png"; import Link from "next/link"; -const AboutUs = (props: any) => { +function AboutUs(props: any) { const pages: Array<{ name: string; link: string; summary: string; image: string; }> = [ - { - name: "Our Charter", - link: "/our-charter", - summary: - "Curious about our policies? Learn more by reading the charter of the Stuyvesant Spectator.", - image: "string", - }, - { - name: "Advertise", - link: "/advertise", - summary: - "Considering posting an advertisement? Learn more about how you can advertise on The Stuyvesant Spectator's website.", - image: "string", - }, - { - name: "Sponsors", - link: "/sponsors", - summary: - "Considering sponsoring us? Learn more about how you can sponsor us here.", - image: "string", - }, - { - name: "Staff", - link: "/staff", - summary: "Learn more about our current or past staff members.", - image: "string", - }, - { - name: "Developers", - link: "/developers", - summary: - "Learn more about the developers behind The Stuyvesant Spectator's website.", - image: "string", - }, - { - name: "Contact", - link: "/contact", - summary: "Want to contact us? Get in touch.", - image: "string", - }, - ]; + { + name: "Our Charter", + link: "/our-charter", + summary: + "Curious about our policies? Learn more by reading the charter of the Stuyvesant Spectator.", + image: "string", + }, + { + name: "Advertise", + link: "/advertise", + summary: + "Considering posting an advertisement? Learn more about how you can advertise on The Stuyvesant Spectator's website.", + image: "string", + }, + { + name: "Sponsors", + link: "/sponsors", + summary: + "Considering sponsoring us? Learn more about how you can sponsor us here.", + image: "string", + }, + { + name: "Staff", + link: "/staff", + summary: "Learn more about our current or past staff members.", + image: "string", + }, + { + name: "Developers", + link: "/developers", + summary: + "Learn more about the developers behind The Stuyvesant Spectator's website.", + image: "string", + }, + { + name: "Contact", + link: "/contact", + summary: "Want to contact us? Get in touch.", + image: "string", + }, + ]; return (
diff --git a/pages/about/advertise.tsx b/pages/about/advertise.tsx index 581752a..3817780 100644 --- a/pages/about/advertise.tsx +++ b/pages/about/advertise.tsx @@ -8,7 +8,7 @@ interface Props { manager: ReceivedStaff; } -const Advertise = (props: Props) => { +function Advertise(props: Props) { const { name, email } = props.manager; const mailto = "mailto:" + email; diff --git a/pages/about/contact.tsx b/pages/about/contact.tsx index ffadce1..226d1d6 100644 --- a/pages/about/contact.tsx +++ b/pages/about/contact.tsx @@ -1,7 +1,7 @@ import Head from "next/head"; import { generateMetaTags } from "../../utils/generateMetaTags"; -const ContactPage = () => { +function ContactPage() { const page_title = "Contact - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/about/contact`; const meta_description = `Contact The Stuyvesant Spectator.`; diff --git a/pages/about/developers.tsx b/pages/about/developers.tsx index 80010c9..b6ade96 100644 --- a/pages/about/developers.tsx +++ b/pages/about/developers.tsx @@ -2,7 +2,7 @@ import Head from "next/head"; import styles from "../../styles/Developers.module.css"; import { generateMetaTags } from "../../utils/generateMetaTags"; -const DevelopersPage = () => { +function DevelopersPage() { const developers: Array<{ name: string; role: string; @@ -10,28 +10,28 @@ const DevelopersPage = () => { image: string; github: string; }> = [ - { - name: "Leonid Metlitsky", - role: "Developer", - year: "2025", - github: "leomet07", - image: "https://cdn.discordapp.com/avatars/426703074157920266/d3490e284e9254345f7e23158b5d6686.webp?size=256", - }, - { - name: "David Chen", - role: "Editor", - year: "2023", - github: "dchen278", - image: "https://cdn.discordapp.com/attachments/854398680835948544/925432531959054346/unknown.png", - }, - { - name: "Ivan Chen", - role: "Designer & Developer", - year: "2024", - github: "anivanchen", - image: "https://cdn.discordapp.com/avatars/695729168343629844/f4df801dc96eb786fa050272ba5fdfac.webp?size=256", - }, - ]; + { + name: "Leonid Metlitsky", + role: "Developer", + year: "2025", + github: "leomet07", + image: "https://cdn.discordapp.com/avatars/426703074157920266/d3490e284e9254345f7e23158b5d6686.webp?size=256", + }, + { + name: "David Chen", + role: "Editor", + year: "2023", + github: "dchen278", + image: "https://cdn.discordapp.com/attachments/854398680835948544/925432531959054346/unknown.png", + }, + { + name: "Ivan Chen", + role: "Designer & Developer", + year: "2024", + github: "anivanchen", + image: "https://cdn.discordapp.com/avatars/695729168343629844/f4df801dc96eb786fa050272ba5fdfac.webp?size=256", + }, + ]; const page_title = "Developers - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/about/developers`; diff --git a/pages/about/our-charter.tsx b/pages/about/our-charter.tsx index e0139db..c230164 100644 --- a/pages/about/our-charter.tsx +++ b/pages/about/our-charter.tsx @@ -2,7 +2,7 @@ import Head from "next/head"; import styles from "../../styles/About.module.css"; import { generateMetaTags } from "../../utils/generateMetaTags"; -const OurCharter = () => { +function OurCharter() { const page_title = "Our Charter - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/about/our-charter`; const meta_description = `The Stuyvesant Spectator's charter.`; diff --git a/pages/about/sponsors.tsx b/pages/about/sponsors.tsx index 5c89df6..ca30097 100644 --- a/pages/about/sponsors.tsx +++ b/pages/about/sponsors.tsx @@ -2,7 +2,7 @@ import Head from "next/head"; import styles from "../../styles/About.module.css"; import { generateMetaTags } from "../../utils/generateMetaTags"; -const Sponsors = () => { +function Sponsors() { const page_title = "Sponsors - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/about/sponsors`; const meta_description = `The sponsors for The Stuyvesant Spectator, and how to become a sponsor for The Stuyvesant Spectator.`; diff --git a/pages/about/staff.tsx b/pages/about/staff.tsx index acc11c0..d5ad61b 100644 --- a/pages/about/staff.tsx +++ b/pages/about/staff.tsx @@ -2,7 +2,7 @@ import Head from "next/head"; import styles from "../../styles/Staff.module.css"; import { generateMetaTags } from "../../utils/generateMetaTags"; -const StaffPage = () => { +function StaffPage() { const page_title = "Staff - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/about/staff`; const meta_description = `The members of The Stuyvesant Spectator's 2022-2023 Editorial Board.`; diff --git a/pages/article/[article_slug].tsx b/pages/article/[article_slug].tsx index f11d47c..10eef9c 100644 --- a/pages/article/[article_slug].tsx +++ b/pages/article/[article_slug].tsx @@ -18,7 +18,8 @@ interface Props { article: ReceivedArticle; } -const Article = (props: Props) => { +function Article(props: Props) { + const { text, title, diff --git a/pages/department/[department].tsx b/pages/department/[department].tsx index 2f81732..40dd534 100644 --- a/pages/department/[department].tsx +++ b/pages/department/[department].tsx @@ -17,7 +17,7 @@ interface Props { section_id: number; } -const Article = (props: Props) => { +function Article(props: Props) { const page_title = props.department_display + " - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/department/` + DepartmentsArray[props.section_id]; diff --git a/pages/department/[department]/[sub_section].tsx b/pages/department/[department]/[sub_section].tsx index 309ddbd..b1f4841 100644 --- a/pages/department/[department]/[sub_section].tsx +++ b/pages/department/[department]/[sub_section].tsx @@ -18,14 +18,13 @@ interface Props { department_id: number; } -const SubSection = (props: Props) => { +function SubSection(props: Props) { const sub_section_display = props.sub_section.charAt(0).toUpperCase() + props.sub_section.slice(1); const page_title = sub_section_display + " - The Stuyvesant Spectator"; - const meta_url = `https://stuyspec.com/department/${ - DepartmentsArray[props.department_id] - }/${props.sub_section}`; + const meta_url = `https://stuyspec.com/department/${DepartmentsArray[props.department_id] + }/${props.sub_section}`; const meta_description = `${sub_section_display} at The Stuyvesant Spectator.`; const fetch_addtional_articles = async (skip?: number, max?: number) => { diff --git a/pages/index.tsx b/pages/index.tsx index b52f816..a316488 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -21,7 +21,7 @@ async function fetch_addtional_articles(skip?: number, max?: number) { return articles; } -const Home = (props: Props) => { +function Home(props: Props) { return (
diff --git a/pages/search.tsx b/pages/search.tsx index 758b88c..e49c011 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -19,7 +19,7 @@ enum sortingOptions { Oldest = "oldest", } -const SearchRoute = (props: Props) => { +function SearchRoute(props: Props) { const [sortingOption, setSortingOption] = useState(sortingOptions.Relevance); const [sortedArticles, setSortedArticles] = useState(props.articles); diff --git a/pages/staff/[staff_identifier].tsx b/pages/staff/[staff_identifier].tsx index c44598f..4c6fccc 100644 --- a/pages/staff/[staff_identifier].tsx +++ b/pages/staff/[staff_identifier].tsx @@ -30,7 +30,7 @@ interface Props { }[]; } -const StaffMember = (props: Props) => { +function StaffMember(props: Props) { const staff_member = props.staff; const page_title = staff_member.name + " - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/staff/` + staff_member.slug; diff --git a/pages/subscribe.tsx b/pages/subscribe.tsx index c00c136..d12057b 100644 --- a/pages/subscribe.tsx +++ b/pages/subscribe.tsx @@ -3,7 +3,7 @@ import styles from "../styles/Subscribe.module.css"; import SubscribeForm from "../components/SubscribeForm"; import { generateMetaTags } from "../utils/generateMetaTags"; -const Subscribe = () => { +function Subscribe() { const page_title = "Subscribe - The Stuyvesant Spectator"; const meta_url = `https://stuyspec.com/subscribe`; const meta_description = `Subscribe to The Stuyvesant Spectator's biweekly newsletter.`; diff --git a/pages/volume/[volume]/issue/[issue].tsx b/pages/volume/[volume]/issue/[issue].tsx index f44dd94..27bea72 100644 --- a/pages/volume/[volume]/issue/[issue].tsx +++ b/pages/volume/[volume]/issue/[issue].tsx @@ -13,7 +13,7 @@ interface Props { issue: number; } -const Issue_Component = (props: Props) => { +function Issue_Component(props: Props) { const page_title = `Volume ${props.volume} Issue ${props.issue} - The Stuyvesant Spectator`; const meta_url = `https://stuyspec.com/volume/${props.volume}/issue/${props.issue}`; const meta_description = `Volume ${props.volume} Issue ${props.issue} at The Stuyvesant Spectator.`;