-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: migrate to app router * chore: remove export * fix: format * fix: formatting
- Loading branch information
1 parent
859c88c
commit 8dc3bba
Showing
34 changed files
with
1,798 additions
and
2,595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,6 @@ yarn-error.log* | |
# Sentry | ||
.sentryclirc | ||
|
||
public/sitemap*.xml | ||
public/sitemap*.xml | ||
# Sentry Config File | ||
.sentryclirc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
|
||
import { sendGAEvent } from "@next/third-parties/google"; | ||
|
||
/* eslint-disable jsx-a11y/media-has-caption */ | ||
|
||
export interface AudioSource { | ||
ext: string; | ||
mime: string; | ||
url: string; | ||
} | ||
|
||
interface AudioPlayerProps { | ||
readonly soundId: string; | ||
readonly sources: AudioSource[]; | ||
} | ||
|
||
export const AudioPlayer = ({ soundId, sources }: AudioPlayerProps) => ( | ||
<audio | ||
autoPlay | ||
controls | ||
onPlay={() => { | ||
sendGAEvent("play_sound", { | ||
value: soundId, | ||
}); | ||
}} | ||
> | ||
{sources.map(({ mime, url }) => ( | ||
<source key={url} src={url} type={mime} /> | ||
))} | ||
|
||
<p>Your user agent does not support the HTML5 Audio element.</p> | ||
</audio> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { Metadata } from "next"; | ||
import { notFound } from "next/navigation"; | ||
|
||
import { SAYINGS } from "@/constants/sayings"; | ||
import { getSayingData } from "@/lib/sayings"; | ||
|
||
import { AudioPlayer } from "./audio-player"; | ||
import { RandomSayings } from "./random-sayings"; | ||
|
||
interface PlayPageProps { | ||
readonly params: { | ||
sound_id: string; | ||
}; | ||
} | ||
|
||
export const generateMetadata = ({ params }: PlayPageProps): Metadata => { | ||
const data = getSayingData(params.sound_id); | ||
|
||
if (!data) { | ||
return {}; | ||
} | ||
|
||
return { | ||
title: `${data.text} - Duke Nukem Says`, | ||
description: `Duke Nukem Says "${data.text}". Play Duke Nukem quotes on Duke Nukem Says!`, | ||
}; | ||
}; | ||
|
||
export const generateStaticParams = () => { | ||
return SAYINGS.map((saying) => ({ | ||
sound_id: saying.id, | ||
})); | ||
}; | ||
|
||
const PlayPage = ({ params }: PlayPageProps) => { | ||
const data = getSayingData(params.sound_id); | ||
|
||
if (!data) { | ||
notFound(); | ||
} | ||
|
||
const { soundId, text, sources } = data; | ||
|
||
return ( | ||
<> | ||
<h1>Duke Nukem Says...</h1> | ||
<h2>{`"${text}"`}</h2> | ||
<AudioPlayer soundId={soundId} sources={sources} /> | ||
<RandomSayings key={soundId} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default PlayPage; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use client"; | ||
|
||
import * as Sentry from "@sentry/nextjs"; | ||
import Error from "next/error"; | ||
import { useEffect } from "react"; | ||
|
||
interface GlobalErrorProps { | ||
readonly error: Error; | ||
} | ||
|
||
const GlobalError = ({ error }: GlobalErrorProps) => { | ||
useEffect(() => { | ||
Sentry.captureException(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html lang="en"> | ||
<body> | ||
<Error statusCode={undefined as unknown as number} /> | ||
</body> | ||
</html> | ||
); | ||
}; | ||
|
||
export default GlobalError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
body { | ||
font: 18px "Verdana", sans-serif; | ||
font: | ||
18px "Verdana", | ||
sans-serif; | ||
background-color: #000000; | ||
} | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable react/no-danger */ | ||
import { GoogleAnalytics } from "@next/third-parties/google"; | ||
import type { Metadata, Viewport } from "next"; | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
|
||
import { WEBSITE_INFO } from "@/constants/website-info"; | ||
|
||
import Logo from "../public/logo.webp"; | ||
import "./global.css"; | ||
import styles from "./layout.module.css"; | ||
|
||
export const metadata: Metadata = { | ||
openGraph: { | ||
siteName: "Duke Nukem Says", | ||
type: "website", | ||
images: ["/logo.webp"], | ||
}, | ||
authors: [{ name: "Allan Legemaate" }], | ||
manifest: "/manifest.json", | ||
metadataBase: new URL(WEBSITE_INFO.url), | ||
}; | ||
|
||
export const viewport: Viewport = { | ||
themeColor: "#000", | ||
}; | ||
|
||
interface LayoutProps { | ||
readonly children: React.ReactNode; | ||
} | ||
|
||
const Layout = ({ children }: LayoutProps) => ( | ||
<html lang="en"> | ||
<head> | ||
<link href="/icon.png" rel="shortcut icon" /> | ||
<link href="/icon.png" rel="apple-touch-icon" /> | ||
<link href="/favicon.png" rel="icon" /> | ||
<script | ||
async | ||
crossOrigin="anonymous" | ||
src={`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${ | ||
process.env.NEXT_PUBLIC_ADSENSE_CLIENT ?? "" | ||
}`} | ||
/> | ||
</head> | ||
|
||
<body> | ||
<header className={styles.header}> | ||
<Link href="/"> | ||
<Image alt="Duke Nuke Says Logo" height={79} src={Logo} width={300} /> | ||
</Link> | ||
</header> | ||
|
||
<main className={styles.content}>{children}</main> | ||
|
||
<footer className={styles.link}> | ||
Created by a bored employee at{" "} | ||
<Link href="https://www.adsgames.net">A.D.S. Games</Link> | ||
</footer> | ||
</body> | ||
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_ID ?? ""} /> | ||
</html> | ||
); | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Metadata } from "next"; | ||
import Link from "next/link"; | ||
|
||
export const metadata: Metadata = { | ||
title: "404 Not Found - Duke Nuke Says", | ||
description: "Page not found", | ||
}; | ||
|
||
const NotFound = () => ( | ||
<> | ||
<h2>404 Page not found</h2> | ||
<Link href="/">Go back to the homepage</Link> | ||
</> | ||
); | ||
|
||
export default NotFound; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import type { Metadata } from "next"; | ||
import Link from "next/link"; | ||
|
||
import { Layout } from "@/components/Layout"; | ||
import { SAYINGS } from "@/constants/sayings"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Home - Duke Nuke Says", | ||
description: "Duke Nukem soundboard", | ||
}; | ||
|
||
const HomePage = () => ( | ||
<Layout description="Duke Nukem soundboard" title="Home"> | ||
<> | ||
<h1>Duke Nukem Says...</h1> | ||
<div className="sayings"> | ||
{SAYINGS.map((saying) => ( | ||
<Link href={`/${saying.id}`} key={saying.id} prefetch={false}> | ||
<a> | ||
<p>{saying.text}</p> | ||
</a> | ||
<p>{saying.text}</p> | ||
</Link> | ||
))} | ||
</div> | ||
</Layout> | ||
</> | ||
); | ||
|
||
export default HomePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { MetadataRoute } from "next"; | ||
|
||
import { SAYINGS } from "@/constants/sayings"; | ||
import { WEBSITE_INFO } from "@/constants/website-info"; | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
const paths = SAYINGS.map( | ||
(saying) => | ||
({ | ||
url: `${WEBSITE_INFO.url}/${saying.id}`, | ||
lastModified: new Date(), | ||
changeFrequency: "monthly", | ||
priority: 0.7, | ||
}) as const, | ||
); | ||
|
||
return [ | ||
{ | ||
url: WEBSITE_INFO.url, | ||
lastModified: new Date(), | ||
changeFrequency: "monthly", | ||
priority: 1, | ||
}, | ||
...paths, | ||
]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const WEBSITE_INFO = { | ||
url: "https://duke.adsgames.net", | ||
} as const; |
Oops, something went wrong.