Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Add titles + descriptions to pages (#566)

RandomLetterscd5a77871f58
diff --git a/apps/admin/src/app/layout.tsx b/apps/admin/src/app/layout.tsx
index 6b9e11e1..3aaf81b8 100644
--- a/apps/admin/src/app/layout.tsx
+++ b/apps/admin/src/app/layout.tsx
@@ -11,7 +11,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html suppressHydrationWarning lang="en">
<head>
- <title>Type Hero Admin</title>
+ <title>TypeHero Admin</title>
</head>
<body className={`${inter.className} flex flex-col`}>
<Providers>
diff --git a/apps/web/src/app/[username]/page.tsx b/apps/web/src/app/[username]/page.tsx
index afff3ab6..41f9e853 100644
--- a/apps/web/src/app/[username]/page.tsx
+++ b/apps/web/src/app/[username]/page.tsx
@@ -9,3 +9,13 @@ interface Props {
export default function Page({ params }: Props) {
return <Profile username={params.username} />;
}
+
+export async function generateMetadata({ params: { username } }: Props) {
+ // remove the %40 from the username
+ const name = username.substring(3);
+
+ return {
+ title: `${name}'s profile | TypeHero`,
+ description: `View the profile of ${name} on TypeHero.`,
+ };
+}
diff --git a/apps/web/src/app/_components/features.tsx b/apps/web/src/app/_components/features.tsx
index b400d6b2..4cca2483 100644
--- a/apps/web/src/app/_components/features.tsx
+++ b/apps/web/src/app/_components/features.tsx
@@ -113,7 +113,7 @@ function Features() {
'pointer-events-none w-[90%] border border-zinc-300 dark:border-zinc-700 rounded-t-2xl transition-all duration-500 overflow-hidden',
'left-[5%] top-[50%] md:top-[30%] md:left-1/2 md:left-[35px]',
)}
- description="Craft your own coding challenges to share with the Typehero community"
+ description="Craft your own coding challenges to share with the TypeHero community"
bgClass="lg:bg-gradient-to-tr"
image={{
step1dark1: Step1Dark1,
diff --git a/apps/web/src/app/challenge/[id]/page.tsx b/apps/web/src/app/challenge/[id]/page.tsx
index 4476669a..d56502cb 100644
--- a/apps/web/src/app/challenge/[id]/page.tsx
+++ b/apps/web/src/app/challenge/[id]/page.tsx
@@ -13,11 +13,12 @@ interface Props {
export async function generateMetadata({ params: { id } }: Props) {
const challenge = await getChallengeRouteData(id, null);
return buildMetaForChallenge({
- title: challenge.name,
- description: challenge.shortDescription,
+ title: `${challenge.name} | TypeHero`,
+ description: `${challenge.shortDescription} Can you solve it?`,
username: challenge.user.name,
});
}
+
export default async function Challenges({ params: { id } }: Props) {
const session = await getServerAuthSession();
const challenge = await getChallengeRouteData(id, session);
diff --git a/apps/web/src/app/challenge/[id]/solutions/[solutionId]/page.tsx b/apps/web/src/app/challenge/[id]/solutions/[solutionId]/page.tsx
index 9b72840e..9f71a621 100644
--- a/apps/web/src/app/challenge/[id]/solutions/[solutionId]/page.tsx
+++ b/apps/web/src/app/challenge/[id]/solutions/[solutionId]/page.tsx
@@ -15,6 +15,16 @@ export default async function SolutionPage({ params: { solutionId } }: Props) {
return <SolutionDetails solution={solution} />;
}
+export async function generateMetadata({ params: { solutionId } }: Props) {
+ const solution = await getSolution(solutionId);
+ if (!solution) return null;
+
+ return {
+ title: `${solution.title}, solution to ${solution.challenge?.name} | TypeHero`,
+ description: `View this solution to ${solution.challenge?.name} on TypeHero.`,
+ };
+}
+
async function getSolution(solutionId: string) {
const solution = await prisma.sharedSolution.findFirst({
where: {
diff --git a/apps/web/src/app/challenge/[id]/solutions/page.tsx b/apps/web/src/app/challenge/[id]/solutions/page.tsx
index f32455c1..bba4267b 100644
--- a/apps/web/src/app/challenge/[id]/solutions/page.tsx
+++ b/apps/web/src/app/challenge/[id]/solutions/page.tsx
@@ -3,6 +3,8 @@ import { notFound } from 'next/navigation';
import { getServerAuthSession } from '@repo/auth/server';
import { prisma } from '@repo/db';
import { Solutions } from './_components';
+import { getChallengeRouteData } from '../getChallengeRouteData';
+import { buildMetaForChallenge } from '~/app/metadata';
interface Props {
params: {
@@ -10,6 +12,15 @@ interface Props {
};
}
+export async function generateMetadata({ params: { id } }: Props) {
+ const challenge = await getChallengeRouteData(id, null);
+ return buildMetaForChallenge({
+ title: `Solutions to ${challenge.name} | TypeHero`,
+ description: challenge.shortDescription,
+ username: challenge.user.name,
+ });
+}
+
export default async function SolutionPage({ params: { id } }: Props) {
const session = await getServerAuthSession();
const solutions = await getSolutionsData(id, session);
diff --git a/apps/web/src/app/challenge/[id]/submissions/page.tsx b/apps/web/src/app/challenge/[id]/submissions/page.tsx
index cc2e6829..c4237273 100644
--- a/apps/web/src/app/challenge/[id]/submissions/page.tsx
+++ b/apps/web/src/app/challenge/[id]/submissions/page.tsx
@@ -2,6 +2,7 @@ import { notFound } from 'next/navigation';
import { getServerAuthSession } from '@repo/auth/server';
import { getChallengeSubmissions } from './getChallengeSubmissions';
import { Submissions } from './_components';
+import type { Metadata } from 'next';
interface Props {
params: {
@@ -9,6 +10,22 @@ interface Props {
};
}
+export async function generateMetadata({ params: { id } }: Props): Promise<Metadata> {
+ const submissions = await getChallengeSubmissions('', id);
+
+ if (!submissions) {
+ return {
+ title: 'Submissions | TypeHero',
+ description: 'View your submissions to this challenge on TypeHero.',
+ };
+ }
+
+ return {
+ title: `${submissions.length} Submission${submissions.length == 1 ? '' : 's'} | TypeHero`,
+ description: 'View all of your submissions to this challenge on TypeHero.',
+ };
+}
+
export default async function SubmissionPage({ params: { id } }: Props) {
const session = await getServerAuthSession();
const submissions = await getChallengeSubmissions(session?.user.id ?? '', id);
diff --git a/apps/web/src/app/explore/[slug]/page.tsx b/apps/web/src/app/explore/[slug]/page.tsx
index ccd65e5b..bdbb8b2b 100644
--- a/apps/web/src/app/explore/[slug]/page.tsx
+++ b/apps/web/src/app/explore/[slug]/page.tsx
@@ -1,6 +1,7 @@
import { Suspense } from 'react';
import { ExploreSlugSkeleton } from '../_components/explore-slug-skeleton';
import { ExploreSlug } from '../_components/explore-slug';
+import type { Metadata } from 'next';
export const dynamic = 'force-dynamic';
@@ -10,6 +11,10 @@ interface Props {
};
}
+export const metadata: Metadata = {
+ title: 'Explore Challenges | TypeHero',
+};
+
// accepts both difficulty & tags as slug.
// ex: `/explore/easy`, `explore/popular`
export default function Page({ params }: Props) {
diff --git a/apps/web/src/app/explore/error.tsx b/apps/web/src/app/explore/error.tsx
index 224cd5cd..1b1ecd44 100644
--- a/apps/web/src/app/explore/error.tsx
+++ b/apps/web/src/app/explore/error.tsx
@@ -7,7 +7,7 @@ export default function Error() {
return (
<div className="container flex h-full flex-col items-center justify-center">
<Text className="mb-6" intent="h2">
- Uh oh! We couldn&apos;t find the challenge&apos;s you were looking for.
+ Uh oh! We couldn&apos;t find the challenges you were looking for.
</Text>
<Link href="/explore">
<Button>Explore Challenges</Button>
diff --git a/apps/web/src/app/explore/page.tsx b/apps/web/src/app/explore/page.tsx
index cd1efe63..db1f3a08 100644
--- a/apps/web/src/app/explore/page.tsx
+++ b/apps/web/src/app/explore/page.tsx
@@ -1,4 +1,11 @@
+import type { Metadata } from 'next';
+
// CI fails without this
export const dynamic = 'force-dynamic';
+export const metadata: Metadata = {
+ title: 'Explore Challenges | TypeHero',
+ description: 'Explore all challenges by difficulty or tags on TypeHero.',
+};
+
export { Explore as default } from './_components';
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index 45babb67..5accdd05 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -19,7 +19,6 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html suppressHydrationWarning lang="en">
<head>
- <title>Type Hero</title>
<meta
content="Level up your typescript skills with interactive exercises"
name="description"
diff --git a/apps/web/src/app/metadata.ts b/apps/web/src/app/metadata.ts
index e35e8e66..0d957676 100644
--- a/apps/web/src/app/metadata.ts
+++ b/apps/web/src/app/metadata.ts
@@ -8,8 +8,8 @@ const tagline = 'Level up your typescript skills with interactive exercises';
const baseMetadata: Metadata = {
metadataBase: new URL(OG_URL),
title: {
- default: 'Typehero',
- template: '%s | TypeHero',
+ default: 'TypeHero',
+ template: '%s',
},
robots: {
index: true,
@@ -17,9 +17,9 @@ const baseMetadata: Metadata = {
},
description: tagline,
openGraph: {
- title: 'Typehero',
+ title: 'TypeHero',
description: tagline,
- siteName: 'Typehero',
+ siteName: 'TypeHero',
images: [
{
url: `${OG_URL}/api/default`,
@@ -31,7 +31,7 @@ const baseMetadata: Metadata = {
type: 'website',
},
twitter: {
- title: 'Typehero',
+ title: 'TypeHero',
card: 'summary_large_image',
images: [
{
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx
index 447d093e..a6af7d81 100644
--- a/apps/web/src/app/page.tsx
+++ b/apps/web/src/app/page.tsx
@@ -6,7 +6,7 @@ import Hero from './_components/hero';
import { WaitlistBanner } from './_components/waitlist-banner';
export const metadata: Metadata = {
- title: 'Typehero',
+ title: 'TypeHero',
description:
'Connect, collaborate, and grow with a community of TypeScript developers. Elevate your skills through interactive coding challenges, discussions, and knowledge sharing',
};
diff --git a/apps/web/src/app/settings/page.tsx b/apps/web/src/app/settings/page.tsx
index 55e602ea..e352e7a8 100644
--- a/apps/web/src/app/settings/page.tsx
+++ b/apps/web/src/app/settings/page.tsx
@@ -1,5 +1,6 @@
import { getServerAuthSession } from '@repo/auth/server';
import { prisma } from '@repo/db';
+import type { Metadata } from 'next';
import { Settings } from '~/components/settings';
export default async function SettingsPage() {
@@ -44,3 +45,8 @@ export default async function SettingsPage() {
/>
);
}
+
+export const metadata: Metadata = {
+ title: 'Settings | TypeHero',
+ description: 'Change your settings on TypeHero.',
+};
diff --git a/apps/web/src/app/tracks/[slug]/page.tsx b/apps/web/src/app/tracks/[slug]/page.tsx
index 087dcd2f..9fcd9fb2 100644
--- a/apps/web/src/app/tracks/[slug]/page.tsx
+++ b/apps/web/src/app/tracks/[slug]/page.tsx
@@ -1,4 +1,5 @@
import { TrackDetail } from '../_components/track-details';
+import { getTrackDetails } from '../_components/track.action';
export const dynamic = 'force-dynamic';
@@ -12,3 +13,19 @@ interface Props {
export default function Page({ params }: Props) {
return <TrackDetail slug={params.slug} />;
}
+
+export async function generateMetadata({ params: { slug } }: Props) {
+ const track = await getTrackDetails(parseInt(slug));
+
+ if (!track) {
+ return {
+ title: 'Track | TypeHero',
+ description: 'View the details of this track on TypeHero.',
+ };
+ }
+
+ return {
+ title: `${track.title} Track | TypeHero`,
+ description: `View the details of the ${track.title} track on TypeHero. ${track.description}`,
+ };
+}
diff --git a/apps/web/src/app/tracks/page.tsx b/apps/web/src/app/tracks/page.tsx
index e655efb9..0f4cad40 100644
--- a/apps/web/src/app/tracks/page.tsx
+++ b/apps/web/src/app/tracks/page.tsx
@@ -1 +1,9 @@
+import type { Metadata } from 'next';
+
export { Tracks as default } from './_components';
+
+export const metadata: Metadata = {
+ title: 'Explore Tracks | TypeHero',
+ description:
+ 'Explore the learning tracks that TypeHero has to offer, find one you like, and get started on learning!',
+};
diff --git a/apps/web/src/app/waitlist/_components/create.action.ts b/apps/web/src/app/waitlist/_components/create.action.ts
index 9b5158d9..84ca3646 100644
--- a/apps/web/src/app/waitlist/_components/create.action.ts
+++ b/apps/web/src/app/waitlist/_components/create.action.ts
@@ -13,9 +13,9 @@ const resend = new Resend(process.env.RESEND_API_KEY);
*/
export const sendUserSignupEmail = async (to: string) => {
const data = await resend.emails.send({
- from: 'Typehero <[email protected]>',
+ from: 'TypeHero <[email protected]>',
to: [to],
- subject: '🔥 Thanks for signing up to Typehero!',
+ subject: '🔥 Thanks for signing up to TypeHero!',
react: UserSignupEmail(),
});
diff --git a/apps/web/src/app/waitlist/page.tsx b/apps/web/src/app/waitlist/page.tsx
index 50a62eff..ff4452cb 100644
--- a/apps/web/src/app/waitlist/page.tsx
+++ b/apps/web/src/app/waitlist/page.tsx
@@ -1 +1,8 @@
+import type { Metadata } from 'next';
+
export { Waitlist as default } from './_components';
+
+export const metadata: Metadata = {
+ title: 'Waitlist | TypeHero',
+ description: 'Join the waitlist for TypeHero and be the first to know when we launch!',
+};
diff --git a/apps/web/src/app/wizard/page.tsx b/apps/web/src/app/wizard/page.tsx
index b5f9c55b..c7dcc978 100644
--- a/apps/web/src/app/wizard/page.tsx
+++ b/apps/web/src/app/wizard/page.tsx
@@ -1,5 +1,6 @@
import { getServerAuthSession } from '@repo/auth/server';
import { TypographyH2 } from '@repo/ui';
+import type { Metadata } from 'next';
import { Wizard } from '~/components/wizard';
export default async function Page() {
@@ -15,3 +16,8 @@ export default async function Page() {
return <Wizard />;
}
+
+export const metadata: Metadata = {
+ title: 'Create a Challenge | TypeHero',
+ description: 'Create a challenge on TypeHero and share it with the world!',
+};
diff --git a/apps/web/src/components/ui/footsies.tsx b/apps/web/src/components/ui/footsies.tsx
index 80a63179..48dcffd1 100644
--- a/apps/web/src/components/ui/footsies.tsx
+++ b/apps/web/src/components/ui/footsies.tsx
@@ -9,7 +9,7 @@ export function Footsies() {
community.
</div>
<div className="text-neutral-500 dark:text-neutral-400">
- © {new Date().getFullYear()} Type Hero
+ © {new Date().getFullYear()} TypeHero
</div>
</div>
</footer>
diff --git a/apps/web/src/components/user/profile.tsx b/apps/web/src/components/user/profile.tsx
index b727d898..e90743e8 100644
--- a/apps/web/src/components/user/profile.tsx
+++ b/apps/web/src/components/user/profile.tsx
@@ -8,8 +8,8 @@ interface Props {
}
export const metadata: Metadata = {
- title: 'Profile',
- description: 'A users profile',
+ title: 'Profile | TypeHero',
+ description: 'View this profile on TypeHero.',
};
export async function Profile({ username: usernameFromQuery }: Props) {
diff --git a/packages/email/emails/waitlist-user-signup.tsx b/packages/email/emails/waitlist-user-signup.tsx
index 5f54fb5e..5579bc1f 100644
--- a/packages/email/emails/waitlist-user-signup.tsx
+++ b/packages/email/emails/waitlist-user-signup.tsx
@@ -24,15 +24,15 @@ export const UserSignupEmail = () => {
return (
<Html>
<Head />
- <Preview>You're on the Typehero Waitlist!</Preview>
+ <Preview>You're on the TypeHero Waitlist!</Preview>
<Tailwind>
<Body className="mx-auto my-auto bg-white font-sans">
<Container className="mx-auto my-[40px] w-[465px] rounded border border-solid border-[#eaeaea] p-[20px]">
<Section className="mt-[32px]">
- <Img src={`${baseUrl}/typehero.png`} width="64" height="auto" alt="Typehero" />
+ <Img src={`${baseUrl}/typehero.png`} width="64" height="auto" alt="TypeHero" />
</Section>
<Heading className="mx-0 my-[30px] p-0 text-[24px] font-bold text-black">
- You're on the Typehero Waitlist!
+ You're on the TypeHero Waitlist!
</Heading>
<Text className="pb-2 text-[20px] leading-[24px] text-black">Hey there 👋</Text>
<Text className="text-[14px] leading-[24px] text-black">