Skip to content

Commit

Permalink
Convert all components to not be anonymous functions
Browse files Browse the repository at this point in the history
anonymous functions MAY break fast refresh, so don't use them for components
  • Loading branch information
leomet07 committed Oct 15, 2023
1 parent 65b6056 commit 686c051
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from "next/head";
import styles from "../styles/Error.module.css";

const Error = () => {
function Error() {
return (
<div>
<Head>
Expand Down
84 changes: 42 additions & 42 deletions pages/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
Expand Down
2 changes: 1 addition & 1 deletion pages/about/advertise.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion pages/about/contact.tsx
Original file line number Diff line number Diff line change
@@ -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.`;
Expand Down
46 changes: 23 additions & 23 deletions pages/about/developers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ 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;
year: string;
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`;
Expand Down
2 changes: 1 addition & 1 deletion pages/about/our-charter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down
2 changes: 1 addition & 1 deletion pages/about/sponsors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down
2 changes: 1 addition & 1 deletion pages/about/staff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down
3 changes: 2 additions & 1 deletion pages/article/[article_slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ interface Props {
article: ReceivedArticle;
}

const Article = (props: Props) => {
function Article(props: Props) {

const {
text,
title,
Expand Down
2 changes: 1 addition & 1 deletion pages/department/[department].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
7 changes: 3 additions & 4 deletions pages/department/[department]/[sub_section].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function fetch_addtional_articles(skip?: number, max?: number) {
return articles;
}

const Home = (props: Props) => {
function Home(props: Props) {
return (
<div>
<main id={styles.main}>
Expand Down
2 changes: 1 addition & 1 deletion pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum sortingOptions {
Oldest = "oldest",
}

const SearchRoute = (props: Props) => {
function SearchRoute(props: Props) {
const [sortingOption, setSortingOption] = useState<sortingOptions>(sortingOptions.Relevance);
const [sortedArticles, setSortedArticles] = useState<ReceivedArticle[]>(props.articles);

Expand Down
2 changes: 1 addition & 1 deletion pages/staff/[staff_identifier].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pages/subscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down
2 changes: 1 addition & 1 deletion pages/volume/[volume]/issue/[issue].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down

0 comments on commit 686c051

Please sign in to comment.