feat(apps): prerendered landing at / and خانه at /feed in bull and bear

- `(landing)` route with `force-static` and `revalidate = 600`, its
  loading and error pages, the hero image and LandingRedirect (0026, 0027).
- `force-dynamic` moves from the root layouts to each route group's
  layout, so every other route still renders per request.
- The feed moves from `(main)/(home)` to `(main)/feed`, with bear's
  empty `@modal` page.
- Auth frames' brand goes to the landing, onboarding's to خانه.
- Server bootstrap adds the server-only translations; server env reads
  `NEXT_PHASE` for the build-time fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Amiram_se 2026-10-07 23:02:58 +04:00
parent ba673f4a28
commit 45c5551e18
45 changed files with 339 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -0,0 +1,10 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function AuthLayout({ children }: { children: ReactNode }) {
return children;
}

View File

@ -0,0 +1,10 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function FlowLayout({ children }: { children: ReactNode }) {
return children;
}

View File

@ -0,0 +1,3 @@
'use client';
export { PageError as default } from '@lumina/market/app/screens/organisms/page-error';

View File

@ -0,0 +1,36 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { GridBox } from '@lumina/island/atoms/grid-box';
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { i18n } from '../../i18n';
/** The landing before it arrives: the header's height, then the hero's copy beside its picture. */
export default function Loading() {
return (
<SkeletonRegion
label={i18n.t('landing:loading')}
delayed
className="min-h-dvh bg-surface"
>
<FlexBox
alignItems="items-center"
className="h-16 border-b border-border-subtle px-8"
>
<Skeleton width="5rem" height="1.25rem" />
</FlexBox>
<GridBox
cols="grid-cols-2"
gap="gap-16"
alignItems="items-center"
className="mx-auto max-w-page px-8 py-14"
>
<FlexBox direction="flex-col" gap="gap-4">
<Skeleton height="3rem" width="90%" />
<Skeleton lines={3} height="1rem" />
<Skeleton shape="pill" width="12rem" height="3.25rem" />
</FlexBox>
<Skeleton shape="rect" width="100%" height="36rem" />
</GridBox>
</SkeletonRegion>
);
}

View File

@ -0,0 +1,65 @@
import { Element } from '@lumina/island/primitives/element';
import { LandingRedirect } from '@lumina/market/app/guards/landing-redirect';
import { faqEntries } from '@lumina/market/app/screens/(landing)/organisms/landing-faq';
import {
landingLabels,
LandingTemplate,
} from '@lumina/market/app/screens/(landing)/templates/landing-template';
import {
faqJsonLd,
landingMetadata,
loadLandingPage,
} from '@lumina/market/server';
import type { Metadata } from 'next';
import { PHASE_PRODUCTION_BUILD } from 'next/constants';
import { displayUrl } from '../../configs';
import { serverEnv } from '../../env/server';
import { i18n } from '../../i18n';
// The landing is the same for every visitor and reads no session, so it is prerendered and its
// featured analysts are read again every 10 minutes (0026). Every other route renders fresh.
export const dynamic = 'force-static';
export const revalidate = 600;
export function generateMetadata(): Metadata {
return landingMetadata({
title: i18n.t('landing:meta.title'),
description: i18n.t('landing:hero.lead'),
});
}
/**
* The landing, `/`: what Lumina is, for a signed-out visitor, and the way to registration. A
* signed-in person is sent on to their home once the browser knows them (0027).
*/
export default async function LandingPage() {
// A failed read hides the analysts at build time; at a revalidation it keeps the last good page.
const { featured } = await loadLandingPage({
hideOnError: serverEnv.NEXT_PHASE === PHASE_PRODUCTION_BUILD,
});
const labels = landingLabels(
i18n.getFixedT(null, 'landing'),
i18n.getFixedT(null, 'common'),
i18n.getFixedT(null, 'content'),
);
return (
<>
<LandingTemplate
layout="desktop"
featured={featured}
siteHost={displayUrl('')}
labels={labels}
/>
<Element
tag="script"
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: faqJsonLd(faqEntries(labels.faq)),
}}
/>
<LandingRedirect />
</>
);
}

View File

@ -18,7 +18,7 @@ export function generateMetadata(): Metadata {
}
/**
* خانه, `/`: the investor's feed of the creators they follow. The server sends only the frame and
* خانه, `/feed`: the investor's feed of the creators they follow. The server sends only the frame and
* the feed's skeleton, the same for every visitor; the feed loads in the browser with the session.
* A guest goes to login, which returns here, and a creator to their own channel. A failed feed
* shows in a card in the column, as the desktop boards draw a state there (S3, S2-Desktop).

View File

@ -2,6 +2,10 @@ import { FlexBox } from '@lumina/island/atoms/flex-box';
import { DesktopHeader } from '@lumina/market/app/navigation';
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
type MainLayoutProps = {
children: ReactNode;
/** The `@modal` slot: «پست جدید» over the page (C4 ۷.۳), or nothing. */

View File

@ -0,0 +1,14 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function OnboardingLayout({
children,
}: {
children: ReactNode;
}) {
return children;
}

View File

@ -1,4 +1,5 @@
import { CreatorProfileStepSkeleton } from '@lumina/market/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../../templates/auth-template';
@ -6,7 +7,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
/** Registration step 5 for a creator, before its frame arrives. The same frame and skeleton as the page, so nothing moves when it arrives. */
export default function Loading() {
return (
<AuthTemplate framed={false}>
<AuthTemplate brandHref={ROUTES.home} framed={false}>
<CreatorProfileStepSkeleton
layout="desktop"
label={i18n.t('auth:loading')}

View File

@ -1,4 +1,5 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
CreatorProfileStep,
CreatorProfileStepSkeleton,
@ -28,7 +29,7 @@ export default function CreatorProfilePage() {
/>
);
return (
<AuthTemplate framed={false}>
<AuthTemplate brandHref={ROUTES.home} framed={false}>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<CreatorProfileStep

View File

@ -1,4 +1,5 @@
import { CreatorProfileDoneStepSkeleton } from '@lumina/market/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../../templates/auth-template';
@ -6,7 +7,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
/** The creator's end of registration, before its frame arrives. The same frame and skeleton as the page, so nothing moves when it arrives. */
export default function Loading() {
return (
<AuthTemplate width="wide">
<AuthTemplate brandHref={ROUTES.home} width="wide">
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
</AuthTemplate>
);

View File

@ -1,4 +1,5 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
CreatorProfileDoneStep,
CreatorProfileDoneStepSkeleton,
@ -25,7 +26,7 @@ export default function CreatorProfileDonePage() {
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
);
return (
<AuthTemplate width="wide">
<AuthTemplate brandHref={ROUTES.home} width="wide">
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<CreatorProfileDoneStep size="md" supportPlacement="popover" />

View File

@ -1,4 +1,5 @@
import { InvestorProfileStepSkeleton } from '@lumina/market/app/screens/(onboarding)/onboarding/investor-profile/organisms/investor-profile-step';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
@ -6,7 +7,7 @@ import { AuthTemplate } from '../../../templates/auth-template';
/** Registration step 5 for an investor, before its frame arrives. The same frame and skeleton as the page, so nothing moves when it arrives. */
export default function Loading() {
return (
<AuthTemplate width="wide">
<AuthTemplate brandHref={ROUTES.home} width="wide">
<InvestorProfileStepSkeleton label={i18n.t('auth:loading')} />
</AuthTemplate>
);

View File

@ -1,4 +1,5 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
InvestorProfileStep,
InvestorProfileStepSkeleton,
@ -21,7 +22,7 @@ export function generateMetadata(): Metadata {
*/
export default function InvestorProfilePage() {
return (
<AuthTemplate width="wide">
<AuthTemplate brandHref={ROUTES.home} width="wide">
<AuthGuard
role="investor"
fallback={

View File

@ -12,9 +12,6 @@ import { rootMetadata } from '../configs';
import { i18n } from '../i18n';
import { AppProviders } from './organisms/app-providers';
// Every request renders fresh: nothing is prerendered or cached on the server.
export const dynamic = 'force-dynamic';
export function generateMetadata(): Metadata {
return rootMetadata();
}

View File

@ -18,6 +18,7 @@ import type { AuthTemplateProps } from './types';
export function AuthTemplate({
width = 'narrow',
framed = true,
brandHref = ROUTES.landing,
children,
}: AuthTemplateProps) {
return (
@ -30,7 +31,7 @@ export function AuthTemplate({
>
<Typography
tag={NextLink}
href={ROUTES.home}
href={brandHref}
aria-label={i18n.t('auth:header.home')}
variant="heading-sm"
color="brand"

View File

@ -8,5 +8,7 @@ export type AuthTemplateProps = {
* live preview.
*/
framed?: boolean;
/** Where the brand goes: the landing for login and registration, خانه on onboarding pages. */
brandHref?: string;
children: ReactNode;
};

View File

@ -5,6 +5,7 @@ import { http } from '@lumina/libs/http';
import { configureServerHttp } from '@lumina/libs/server';
import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env';
import { SERVER_RESOURCES } from '@lumina/market/server';
import { cookies } from 'next/headers';
import {
@ -14,6 +15,7 @@ import {
} from '../constants';
import { clientEnv } from '../env';
import { serverEnv } from '../env/server';
import { i18n } from '../i18n';
import { ERROR_HANDLER_CONFIG } from './error-reporting';
// Fills the server module graph once, before rendering. Idempotent: safe to run again.
@ -37,3 +39,10 @@ configureServerHttp({
});
http.configure({ mapErrorBody: mapApiErrorBody });
configureErrorHandler(ERROR_HANDLER_CONFIG);
// Namespaces only server components read (the landing) join the server's i18n instance here, so
// no client bundle carries them. Existing keys are kept, so running this again changes nothing.
for (const [language, bundles] of Object.entries(SERVER_RESOURCES)) {
for (const [namespace, bundle] of Object.entries(bundles)) {
i18n.addResourceBundle(language, namespace, bundle);
}
}

View File

@ -2,12 +2,18 @@ import 'server-only';
import { origin } from '@lumina/libs/env';
import { createServerEnv } from '@lumina/libs/env/server';
import * as v from 'valibot';
/** Server variables; only server code imports them, through `env/server`. */
export const serverEnv = createServerEnv({
schema: {
/** The gateway from inside the deployment network: server requests and the `/api` proxy. */
API_INTERNAL_ORIGIN: origin,
/**
* Set by Next.js itself, never in `.env`: `phase-production-build` while `next build`
* prerenders pages (the landing, 0026).
*/
NEXT_PHASE: v.optional(v.string()),
},
runtimeEnv: process.env,
skipValidation: process.env.SKIP_ENV_VALIDATION === 'true',

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -0,0 +1,10 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function AuthLayout({ children }: { children: ReactNode }) {
return children;
}

View File

@ -0,0 +1,10 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function FlowLayout({ children }: { children: ReactNode }) {
return children;
}

View File

@ -0,0 +1,3 @@
'use client';
export { PageError as default } from '@lumina/market/app/screens/organisms/page-error';

View File

@ -0,0 +1,31 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { i18n } from '../../i18n';
/** The landing before it arrives: the header's height, then the hero's picture and copy. */
export default function Loading() {
return (
<SkeletonRegion
label={i18n.t('landing:loading')}
delayed
className="min-h-dvh bg-surface"
>
<FlexBox
alignItems="items-center"
className="h-14 border-b border-border-subtle px-4 tablet:h-16 tablet:px-8"
>
<Skeleton width="5rem" height="1.25rem" />
</FlexBox>
<FlexBox
direction="flex-col"
gap="gap-4"
className="px-4 pt-7 tablet:px-8"
>
<Skeleton shape="rect" width="100%" height="24rem" />
<Skeleton lines={3} height="1rem" />
<Skeleton shape="pill" width="100%" height="3.25rem" />
</FlexBox>
</SkeletonRegion>
);
}

View File

@ -0,0 +1,65 @@
import { Element } from '@lumina/island/primitives/element';
import { LandingRedirect } from '@lumina/market/app/guards/landing-redirect';
import { faqEntries } from '@lumina/market/app/screens/(landing)/organisms/landing-faq';
import {
landingLabels,
LandingTemplate,
} from '@lumina/market/app/screens/(landing)/templates/landing-template';
import {
faqJsonLd,
landingMetadata,
loadLandingPage,
} from '@lumina/market/server';
import type { Metadata } from 'next';
import { PHASE_PRODUCTION_BUILD } from 'next/constants';
import { displayUrl } from '../../configs';
import { serverEnv } from '../../env/server';
import { i18n } from '../../i18n';
// The landing is the same for every visitor and reads no session, so it is prerendered and its
// featured analysts are read again every 10 minutes (0026). Every other route renders fresh.
export const dynamic = 'force-static';
export const revalidate = 600;
export function generateMetadata(): Metadata {
return landingMetadata({
title: i18n.t('landing:meta.title'),
description: i18n.t('landing:hero.lead'),
});
}
/**
* The landing, `/`: what Lumina is, for a signed-out visitor, and the way to registration. A
* signed-in person is sent on to their home once the browser knows them (0027).
*/
export default async function LandingPage() {
// A failed read hides the analysts at build time; at a revalidation it keeps the last good page.
const { featured } = await loadLandingPage({
hideOnError: serverEnv.NEXT_PHASE === PHASE_PRODUCTION_BUILD,
});
const labels = landingLabels(
i18n.getFixedT(null, 'landing'),
i18n.getFixedT(null, 'common'),
i18n.getFixedT(null, 'content'),
);
return (
<>
<LandingTemplate
layout="mobile"
featured={featured}
siteHost={displayUrl('')}
labels={labels}
/>
<Element
tag="script"
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: faqJsonLd(faqEntries(labels.faq)),
}}
/>
<LandingRedirect />
</>
);
}

View File

@ -18,7 +18,7 @@ export function generateMetadata(): Metadata {
}
/**
* خانه, `/`: the investor's feed of the creators they follow. The server sends only the frame and
* خانه, `/feed`: the investor's feed of the creators they follow. The server sends only the frame and
* the feed's skeleton, the same for every visitor; the feed loads in the browser with the session.
* A guest goes to login, which returns here, and a creator to their own channel.
*/

View File

@ -2,6 +2,10 @@ import { FlexBox } from '@lumina/island/atoms/flex-box';
import { BottomNav } from '@lumina/market/app/navigation';
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** The main pages on mobile: each page brings its top bar; the bottom nav is shared. */
export default function MainLayout({ children }: { children: ReactNode }) {
return (

View File

@ -0,0 +1,14 @@
import type { ReactNode } from 'react';
// Every request renders fresh: nothing in this group is prerendered or cached on the server.
// Only the landing is (0026), so this lives in each route group's layout, not the root's.
export const dynamic = 'force-dynamic';
/** Adds nothing to the page; it holds the group's rendering mode. */
export default function OnboardingLayout({
children,
}: {
children: ReactNode;
}) {
return children;
}

View File

@ -1,4 +1,5 @@
import { CreatorProfileDoneStepSkeleton } from '@lumina/market/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
@ -7,7 +8,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
/** The creator's end of registration, before its frame arrives. The same frame and skeleton as the page, so nothing moves when it arrives. */
export default function Loading() {
return (
<AuthTemplate header={<AuthTopBar />}>
<AuthTemplate header={<AuthTopBar brandHref={ROUTES.home} />}>
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
</AuthTemplate>
);

View File

@ -1,4 +1,5 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
CreatorProfileDoneStep,
CreatorProfileDoneStepSkeleton,
@ -27,7 +28,7 @@ export default function CreatorProfileDonePage() {
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
);
return (
<AuthTemplate header={<AuthTopBar />}>
<AuthTemplate header={<AuthTopBar brandHref={ROUTES.home} />}>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<CreatorProfileDoneStep size="lg" supportPlacement="bottom" />

View File

@ -12,9 +12,6 @@ import { rootMetadata } from '../configs';
import { i18n } from '../i18n';
import { AppProviders } from './organisms/app-providers';
// Every request renders fresh: nothing is prerendered or cached on the server.
export const dynamic = 'force-dynamic';
export function generateMetadata(): Metadata {
return rootMetadata();
}

View File

@ -13,7 +13,11 @@ import type { AuthTopBarProps } from './types';
* support on a pushed step; only the name on a step with no way back (registration step 4).
* Back keeps what was typed: the number lives in the flow store.
*/
export function AuthTopBar({ title, back }: AuthTopBarProps) {
export function AuthTopBar({
title,
back,
brandHref = ROUTES.landing,
}: AuthTopBarProps) {
return (
<FlexBox
tag="header"
@ -34,7 +38,7 @@ export function AuthTopBar({ title, back }: AuthTopBarProps) {
<FlexBox className="flex-1 px-2">
<Typography
tag={NextLink}
href={ROUTES.home}
href={brandHref}
aria-label={i18n.t('auth:header.home')}
variant="heading-sm"
color="brand"

View File

@ -3,6 +3,8 @@ export type AuthTopBarProps = {
title?: string;
/** The previous step's path, behind the back button; `?redirect=` is kept from the address. */
back?: string;
/** Where the brand goes: the landing for login and registration, خانه on onboarding pages. */
brandHref?: string;
};
export type BackButtonProps = {

View File

@ -5,6 +5,7 @@ import { http } from '@lumina/libs/http';
import { configureServerHttp } from '@lumina/libs/server';
import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env';
import { SERVER_RESOURCES } from '@lumina/market/server';
import { cookies } from 'next/headers';
import {
@ -14,6 +15,7 @@ import {
} from '../constants';
import { clientEnv } from '../env';
import { serverEnv } from '../env/server';
import { i18n } from '../i18n';
import { ERROR_HANDLER_CONFIG } from './error-reporting';
// Fills the server module graph once, before rendering. Idempotent: safe to run again.
@ -37,3 +39,10 @@ configureServerHttp({
});
http.configure({ mapErrorBody: mapApiErrorBody });
configureErrorHandler(ERROR_HANDLER_CONFIG);
// Namespaces only server components read (the landing) join the server's i18n instance here, so
// no client bundle carries them. Existing keys are kept, so running this again changes nothing.
for (const [language, bundles] of Object.entries(SERVER_RESOURCES)) {
for (const [namespace, bundle] of Object.entries(bundles)) {
i18n.addResourceBundle(language, namespace, bundle);
}
}

View File

@ -2,12 +2,18 @@ import 'server-only';
import { origin } from '@lumina/libs/env';
import { createServerEnv } from '@lumina/libs/env/server';
import * as v from 'valibot';
/** Server variables; only server code imports them, through `env/server`. */
export const serverEnv = createServerEnv({
schema: {
/** The gateway from inside the deployment network: server requests and the `/api` proxy. */
API_INTERNAL_ORIGIN: origin,
/**
* Set by Next.js itself, never in `.env`: `phase-production-build` while `next build`
* prerenders pages (the landing, 0026).
*/
NEXT_PHASE: v.optional(v.string()),
},
runtimeEnv: process.env,
skipValidation: process.env.SKIP_ENV_VALIDATION === 'true',