Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/app/(public)/events/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from "next";
import { Calendar, ExternalLink } from "lucide-react";

import { siteConfig } from "@/config/site";
import { createPageMetadata } from "@/lib/metadata";
import { createPageMetadata, pageDescriptions } from "@/lib/metadata";
import { Button } from "@/components/ui/button";

// ============================================================================
Expand All @@ -11,8 +11,7 @@ import { Button } from "@/components/ui/button";

export const metadata: Metadata = createPageMetadata({
title: "Events Calendar",
description:
"Upcoming events, seminars, and meetings at the Materials and Process Simulation Center.",
description: pageDescriptions.calendar,
path: "/events/calendar",
Comment thread
TKanX marked this conversation as resolved.
});

Expand Down
5 changes: 2 additions & 3 deletions src/app/(public)/events/photos/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from "next";
import { Camera, Calendar as CalendarIcon } from "lucide-react";

import { getPhotosGroupedByYear, getPhotoStats } from "@/lib/db/queries/photos";
import { createPageMetadata } from "@/lib/metadata";
import { createPageMetadata, pageDescriptions } from "@/lib/metadata";
import { PhotoGallery } from "@/components/events";

// ============================================================================
Expand All @@ -11,8 +11,7 @@ import { PhotoGallery } from "@/components/events";

export const metadata: Metadata = createPageMetadata({
title: "Group Photos",
description:
"Photo gallery of the Materials and Process Simulation Center team through the years.",
description: pageDescriptions.photos,
path: "/events/photos",
});
Comment thread
TKanX marked this conversation as resolved.

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/admins/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { AdminListSkeleton } from "@/components/admin/shared";
Expand All @@ -10,8 +11,8 @@ import { AdminList, AccountView } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Administrators | Admin",
export const metadata: Metadata = {
title: "Administrators",
description: "Manage administrator accounts and roles",
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/collaborators/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { CollaboratorListSkeleton } from "@/components/admin/shared";
Expand All @@ -9,8 +10,8 @@ import { CollaboratorList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Collaborators | Admin",
export const metadata: Metadata = {
title: "Collaborators",
description: "Manage collaborators and their locations",
};

Expand Down
14 changes: 14 additions & 0 deletions src/app/admin/(authenticated)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { redirect } from "next/navigation";
import type { Metadata } from "next";

import { getCurrentUser } from "@/lib/auth";
import { siteConfig } from "@/config/site";
import { Sidebar, TopBar, AuthKeepAlive } from "@/components/admin/layout";

// ============================================================================
// Metadata
// ============================================================================

export const metadata: Metadata = {
title: {
template: `%s | Admin | ${siteConfig.name}`,
default: `Admin | ${siteConfig.name}`,
Comment thread
TKanX marked this conversation as resolved.
},
robots: "noindex,nofollow",
};

// ============================================================================
// Route Config
// ============================================================================
Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/members/categories/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { ListSkeleton } from "@/components/admin/shared";
Expand All @@ -9,8 +10,8 @@ import { CategoryList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Member Categories | Admin",
export const metadata: Metadata = {
title: "Member Categories",
description: "Manage member categories and display order",
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/members/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Suspense } from "react";
import Link from "next/link";
import type { Metadata } from "next";
import { Settings } from "lucide-react";

import { PageHeader } from "@/components/admin/layout";
Expand All @@ -12,8 +13,8 @@ import { MemberList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Members | Admin",
export const metadata: Metadata = {
title: "Members",
description: "Manage team members and their profiles",
};

Expand Down
6 changes: 4 additions & 2 deletions src/app/admin/(authenticated)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { Metadata } from "next";

import { getDashboardStats } from "@/lib/admin/actions";
import { PublicationChart, RecentActivity, StatsGrid } from "./_components";

// ============================================================================
// Metadata
// ============================================================================

export const metadata = {
title: "Dashboard | Admin",
export const metadata: Metadata = {
title: "Dashboard",
description: "Overview of your site content and activity",
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/photos/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { PhotoGridSkeleton } from "@/components/admin/shared";
Expand All @@ -9,8 +10,8 @@ import { PhotoList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Group Photos | Admin",
export const metadata: Metadata = {
title: "Group Photos",
description: "Manage group photos and display order",
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/publications/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { PublicationListSkeleton } from "@/components/admin/shared";
Expand All @@ -13,8 +14,8 @@ import { PublicationList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Publications | Admin",
export const metadata: Metadata = {
title: "Publications",
description: "Manage research publications",
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/admin/(authenticated)/research/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suspense } from "react";
import type { Metadata } from "next";

import { PageHeader } from "@/components/admin/layout";
import { ResearchTreeSkeleton } from "@/components/admin/shared";
Expand All @@ -9,8 +10,8 @@ import { ResearchList } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Research Areas | Admin",
export const metadata: Metadata = {
title: "Research Areas",
description: "Manage research areas and their hierarchy",
};

Expand Down
6 changes: 4 additions & 2 deletions src/app/admin/(authenticated)/sync/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Metadata } from "next";

import { getSyncStats } from "@/lib/admin/actions";
import { PageHeader } from "@/components/admin/layout";
import { SyncDashboard } from "./_components";
Expand All @@ -6,8 +8,8 @@ import { SyncDashboard } from "./_components";
// Metadata
// ============================================================================

export const metadata = {
title: "Data Sync | Admin",
export const metadata: Metadata = {
title: "Data Sync",
description: "Sync publication metadata and rebuild data relationships",
};

Expand Down
16 changes: 0 additions & 16 deletions src/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,3 @@ export const mainNav: NavItem[] = [
],
},
] as const;

// ============================================================================
// SEO Defaults
// ============================================================================

export const seoDefaults = {
defaultTitle: `${siteConfig.name} - ${siteConfig.fullName}`,
openGraph: {
type: "website",
locale: "en_US",
siteName: siteConfig.name,
},
twitter: {
card: "summary_large_image",
},
} as const;
76 changes: 38 additions & 38 deletions src/lib/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import type { Metadata } from "next";
import { siteConfig, seoDefaults } from "@/config/site";
import { siteConfig } from "@/config/site";
import { truncateAtWordBoundary } from "@/lib/format";
import { getYear } from "@/lib/date";

Expand All @@ -24,43 +24,42 @@ interface PageMetadataOptions {
/**
* Generate metadata for a page.
*/
export function createPageMetadata(
options: PageMetadataOptions = {}
): Metadata {
const {
title,
description = siteConfig.description,
path = "",
image = siteConfig.images.ogImage,
noIndex = false,
} = options;

const fullTitle = title
? `${title} | ${siteConfig.name}`
: seoDefaults.defaultTitle;

const url = `${siteConfig.url}${path}`;
export function createPageMetadata({
title,
description,
path,
image,
noIndex = false,
}: PageMetadataOptions = {}): Metadata {
Comment thread
TKanX marked this conversation as resolved.
const ogTitle = title ? `${title} | ${siteConfig.name}` : undefined;
const url = path !== undefined ? `${siteConfig.url}${path}` : undefined;
const hasContent = !!(ogTitle || description);
const resolvedImage = image ?? siteConfig.images.ogImage;

return {
title: fullTitle,
description,
...(title && { title }),
...(description && { description }),
...(noIndex && { robots: "noindex,nofollow" }),
openGraph: {
...seoDefaults.openGraph,
title: fullTitle,
description,
url,
images: image ? [{ url: image }] : undefined,
},
twitter: {
...seoDefaults.twitter,
title: fullTitle,
description,
images: image ? [image] : undefined,
},
alternates: {
canonical: url,
},
...(hasContent && {
openGraph: {
type: "website",
locale: "en_US",
siteName: siteConfig.name,
...(ogTitle && { title: ogTitle }),
...(description && { description }),
...(url && { url }),
images: [{ url: resolvedImage }],
},
}),
...(hasContent && {
twitter: {
card: "summary_large_image",
...(ogTitle && { title: ogTitle }),
...(description && { description }),
images: [resolvedImage],
},
}),
...(url && { alternates: { canonical: url } }),
};
}

Expand All @@ -74,16 +73,15 @@ export function createMemberMetadata(member: {
bio?: string | null;
photo?: string | null;
}): Metadata {
const title = member.name;
const description = member.bio
? truncateAtWordBoundary(member.bio, 160)
: `${member.name}${member.position ? ` - ${member.position}` : ""} at ${siteConfig.fullName}, Caltech.`;

return createPageMetadata({
title,
title: member.name,
description,
path: `/members/${member.id}`,
image: member.photo || siteConfig.images.ogImage,
...(member.photo && { image: member.photo }),
Comment thread
TKanX marked this conversation as resolved.
});
}

Expand Down Expand Up @@ -155,6 +153,8 @@ export const pageDescriptions = {
research: `Explore research areas at ${siteConfig.fullName}, Caltech.`,
collaborators: `Global research partners and collaborators of ${siteConfig.fullName}.`,
events: `Events, group photos, and calendar for ${siteConfig.fullName}.`,
photos: `Photo gallery of ${siteConfig.fullName} team through the years.`,
calendar: `Upcoming events, seminars, and meetings at ${siteConfig.fullName}.`,
wag: `Prof. William A. Goddard III, Director of ${siteConfig.fullName} at Caltech.`,
msc: `About ${siteConfig.fullName} at the California Institute of Technology.`,
} as const;