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
2 changes: 1 addition & 1 deletion .github/workflows/Lark-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
send-Lark-message:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- uses: denoland/setup-deno@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:

- uses: pnpm/action-setup@v6
with:
version: 11
version: 12

- uses: actions/setup-node@v7
with:
node-version: 24
node-version: 26
registry-url: https://registry.npmjs.org
cache: pnpm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { DateTime } from 'luxon';
import Link from 'next/link';
import { notFound } from 'next/navigation';

import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import type { LanguageCode } from '@/i18n';
import { localizedPath } from '@/i18n/routing';
import { ChinaMapWrapper } from '@/components/ChinaMapWrapper';
import { CommentBox } from '@/components/CommentBox';
import { TimelineItem } from '@/components/TimelineItem';
Expand All @@ -38,10 +40,10 @@ async function findActivity(id: string) {
export default async function EventDetailPage({
params,
}: {
params: Promise<{ id: string }>;
params: Promise<{ id: string; language: LanguageCode }>;
}) {
const { id } = await params;
const { t } = await loadSSRI18nFromRequest();
const { id, language } = await params;
const { t } = await loadSSRI18n(language);

const found = await findActivity(id);
if (!found) notFound();
Expand Down Expand Up @@ -82,7 +84,7 @@ export default async function EventDetailPage({
<div className="container mx-auto px-4 py-8 relative z-10 max-w-4xl">
{/* Back + Edit buttons */}
<div className="flex items-center justify-between mb-6">
<Link href="/activities">
<Link href={localizedPath(language, '/activities')}>
<Button variant="outline" size="sm" className="gap-2">
<ArrowLeft className="w-4 h-4" />
{t('activities_detail_text_back_to_list')}
Expand Down
12 changes: 9 additions & 3 deletions app/activities/page.tsx → app/[language]/activities/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Fuse from 'fuse.js';
import { DateTime } from 'luxon';
import Link from 'next/link';

import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import type { LanguageCode } from '@/i18n';
import { EventCard } from '@/components/EventCard';
import { FilterBar } from '@/components/FilterBar';
import { GitCodeIcon } from '@/components/icons/GitCodeIcon';
Expand Down Expand Up @@ -93,11 +94,16 @@ async function getFlatEvents(): Promise<FlatEvent[]> {
}

export default async function ActivitiesPage({
params,
searchParams,
}: {
params: Promise<{ language: LanguageCode }>;
searchParams: PageSearchParams;
}) {
const rawSearchParams = await searchParams;
const [{ language }, rawSearchParams] = await Promise.all([
params,
searchParams,
]);
const {
pageIndex: rawPageIndex,
keywords: rawKeywords,
Expand All @@ -109,7 +115,7 @@ export default async function ActivitiesPage({
const selectedCategory = parseCategory(pickFirstSearchParam(rawCategory));
const selectedTags = parseTags(rawTag);
const timezone = parseTimezone(pickFirstSearchParam(rawTimezone));
const { currentLanguage, t } = await loadSSRI18nFromRequest(rawSearchParams);
const { currentLanguage, t } = await loadSSRI18n(language, rawSearchParams);

const flatEvents = await getFlatEvents();

Expand Down
28 changes: 22 additions & 6 deletions app/home/page.tsx → app/[language]/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import Image from 'next/image';
import Link from 'next/link';

import { Card, CardContent } from '@/components/ui/card';
import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import { localizedPath } from '@/i18n/routing';
import type { LanguageCode } from '@/i18n';

export default async function HomeSelectorPage() {
const { t } = await loadSSRI18nFromRequest();
export default async function HomeSelectorPage({
params,
}: {
params: Promise<{ language: LanguageCode }>;
}) {
const { language } = await params;
const { t } = await loadSSRI18n(language);

return (
<div className="min-h-[calc(100vh-4rem)] bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-pink-100 via-white to-purple-100">
Expand All @@ -21,7 +28,10 @@ export default async function HomeSelectorPage() {
</div>

<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 items-stretch">
<Link href="/activities" className="group block h-full">
<Link
href={localizedPath(language, '/activities')}
className="group block h-full"
>
<Card className="h-full min-h-[200px] overflow-hidden border-pink-200 hover:border-pink-400 transition-colors">
<CardContent className="p-6 h-full">
<div className="flex items-center gap-4">
Expand All @@ -41,7 +51,10 @@ export default async function HomeSelectorPage() {
</Card>
</Link>

<Link href="/restaurants" className="group block h-full">
<Link
href={localizedPath(language, '/restaurants')}
className="group block h-full"
>
<Card className="h-full min-h-[200px] overflow-hidden border-purple-200 hover:border-purple-400 transition-colors">
<CardContent className="p-6 h-full">
<div className="flex items-center gap-4">
Expand All @@ -61,7 +74,10 @@ export default async function HomeSelectorPage() {
</Card>
</Link>

<Link href="/tutoring" className="group block h-full">
<Link
href={localizedPath(language, '/tutoring')}
className="group block h-full"
>
<Card className="h-full min-h-[200px] overflow-hidden border-cyan-200 hover:border-cyan-400 transition-colors">
<CardContent className="p-6 h-full">
<div className="flex items-center gap-4">
Expand Down
74 changes: 74 additions & 0 deletions app/[language]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import type { Metadata } from 'next';
import { toJS } from 'mobx';
import { Inter } from 'next/font/google';
import Script from 'next/script';
import { notFound } from 'next/navigation';
import { type PropsWithChildren } from 'react';

import { I18nProvider } from '@/components/I18nProvider';
import { MainNav } from '@/components/MainNav';
import { LanguageName, type LanguageCode } from '@/i18n';
import { loadSSRI18n } from '@/i18n/server';
import '../globals.css';

const inter = Inter({
variable: '--font-inter',
subsets: ['latin'],
});

const fontMono = Inter({
variable: '--font-geist-mono',
subsets: ['latin'],
});

const isLanguageCode = (language: string): language is LanguageCode =>
Object.hasOwn(LanguageName, language);

interface LanguageLayoutProps extends PropsWithChildren {
params: Promise<{ language: string }>;
}

export const generateStaticParams = () =>
Object.keys(LanguageName).map((language) => ({ language }));

export async function generateMetadata({
params,
}: Pick<LanguageLayoutProps, 'params'>): Promise<Metadata> {
const { language } = await params;
if (!isLanguageCode(language)) notFound();

const { t } = await loadSSRI18n(language);

return {
title: 'GoodAction-Hub',
description: t('metadata.description'),
};
}

export default async function LanguageLayout({
children,
params,
}: LanguageLayoutProps) {
const { language } = await params;
if (!isLanguageCode(language)) notFound();

const { currentLanguage, currentMap } = await loadSSRI18n(language);

return (
<html lang={currentLanguage}>
<head>
<Script
src="https://umami.rkd.icu/script.js"
data-website-id="78225323-cc05-46af-9a51-6c670b9a804a"
strategy="afterInteractive"
/>
</head>
<body className={`${inter.variable} ${fontMono.variable} antialiased`}>
<I18nProvider language={currentLanguage} languageMap={toJS(currentMap)}>
<MainNav />
{children}
</I18nProvider>
</body>
</html>
);
}
13 changes: 10 additions & 3 deletions app/origin/page.tsx → app/[language]/origin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { Aggregation } from '@/components/Aggregation';
import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import type { LanguageCode } from '@/i18n';

export default async function OriginPage() {
const { t } = await loadSSRI18nFromRequest();
export default async function OriginPage({
params,
}: {
params: Promise<{ language: LanguageCode }>;
}) {
const { language } = await params;
const { t } = await loadSSRI18n(language);

return (
<div
Expand All @@ -18,6 +24,7 @@ export default async function OriginPage() {
</header>

<Aggregation
language={language}
searchLabel={t('home.search.label')}
searchPlaceholder={t('ui_text.search_placeholder')}
searchAriaLabel={t('home.search.aria')}
Expand Down
1 change: 1 addition & 0 deletions app/[language]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './home/page';
12 changes: 9 additions & 3 deletions app/recommend/page.tsx → app/[language]/recommend/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Fuse from 'fuse.js';
import { DateTime } from 'luxon';

import { EventCard } from '@/components/EventCard';
import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import type { LanguageCode } from '@/i18n';
import { fetchActivitiesCatalog, transformItem } from '@/lib/activities';
import { DeadlineItem, EventData } from '@/lib/data';
import { pickFirstSearchParam } from '@/lib/pagination';
Expand Down Expand Up @@ -91,13 +92,18 @@ async function getRecommendPageData(
}

export default async function RecommendPage({
params,
searchParams,
}: {
params: Promise<{ language: LanguageCode }>;
searchParams: PageSearchParams;
}) {
const rawSearchParams = await searchParams;
const [{ language }, rawSearchParams] = await Promise.all([
params,
searchParams,
]);
const keywords = pickFirstSearchParam(rawSearchParams.keywords)?.trim() ?? '';
const { t } = await loadSSRI18nFromRequest(rawSearchParams);
const { t } = await loadSSRI18n(language, rawSearchParams);
const { recommendations, error } = await getRecommendPageData(keywords);

if (error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { ArrowLeft, MapPin, MessageSquare, Pencil } from 'lucide-react';
import Link from 'next/link';
import { notFound } from 'next/navigation';

import { loadSSRI18nFromRequest } from '@/i18n/server';
import { loadSSRI18n } from '@/i18n/server';
import type { LanguageCode } from '@/i18n';
import { localizedPath } from '@/i18n/routing';
import { ChinaMapWrapper } from '@/components/ChinaMapWrapper';
import { CommentBox } from '@/components/CommentBox';
import { fetchBitesCatalog } from '@/lib/bitesCatalog';
Expand All @@ -15,10 +17,10 @@ const DATA_EDIT_URL =
export default async function RestaurantDetailPage({
params,
}: {
params: Promise<{ id: string }>;
params: Promise<{ id: string; language: LanguageCode }>;
}) {
const { id } = await params;
const { t } = await loadSSRI18nFromRequest();
const { id, language } = await params;
const { t } = await loadSSRI18n(language);

const catalog = await fetchBitesCatalog();
const restaurant = catalog.find((r) => r.id === id);
Expand All @@ -35,7 +37,7 @@ export default async function RestaurantDetailPage({
<div className="container mx-auto px-4 py-8 relative z-10 max-w-4xl">
{/* Back + Edit buttons */}
<div className="flex items-center justify-between mb-6">
<Link href="/restaurants">
<Link href={localizedPath(language, '/restaurants')}>
<Button variant="outline" size="sm" className="gap-2">
<ArrowLeft className="w-4 h-4" />
{t('restaurants_detail_text_back')}
Expand Down
Loading
Loading