feat: render every page except the landing in the browser
- Channel, post, checkout and analysts read their data in the browser; the server reads no back-end data outside the landing (0070). - Only the landing is indexable; every other page is noindex, the rules pages through the terms layout (0071). - Remove the landing's loading.tsx so all of it renders in the first flush. - Remove the server caches and metadata helpers nothing uses any more. - Update the page rendering docs; 0021, 0045 and 0055 are superseded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3e908ab0b7
commit
2a1b657a77
|
|
@ -1,8 +1,7 @@
|
|||
import { ROUTES, withSearchParams } from '@lumina/market/app/navigation';
|
||||
import { getChannel, readOnServer } from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect, redirect } from 'next/navigation';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
import { CheckoutTemplate } from './templates/checkout-template';
|
||||
|
|
@ -18,10 +17,10 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* Checkout for a creator's channel (U9), reached only from its «اشتراک». The server renders the
|
||||
* same page for everyone: the bar and who is being paid; the investor's own checkout loads in the
|
||||
* browser. Another spelling of the username redirects to the stored one; a suspended channel
|
||||
* sends the visitor to the channel, which says it is unavailable.
|
||||
* Checkout for a creator's channel (U9), reached only from its «اشتراک». It renders in the
|
||||
* browser only (0070): the server reads nothing and sends the bar and the skeleton. Another
|
||||
* spelling of the username redirects to the stored one; a suspended channel sends the visitor to
|
||||
* the channel, which says it is unavailable.
|
||||
*/
|
||||
export default async function CheckoutPage({
|
||||
params,
|
||||
|
|
@ -36,9 +35,6 @@ export default async function CheckoutPage({
|
|||
withSearchParams(ROUTES.checkout(username), await searchParams),
|
||||
);
|
||||
}
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') notFound();
|
||||
if (channel.data.suspended) redirect(ROUTES.channel(username));
|
||||
|
||||
return <CheckoutTemplate channel={channel.data} />;
|
||||
return <CheckoutTemplate username={username} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,66 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import {
|
||||
PartBoundary,
|
||||
StatusEmptyState,
|
||||
} from '@lumina/market/app/error-boundaries';
|
||||
import {
|
||||
DesktopHeader,
|
||||
DesktopPageTitle,
|
||||
ROUTES,
|
||||
} from '@lumina/market/app/navigation';
|
||||
import { CheckoutCreator } from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-creator';
|
||||
import { CheckoutPanel } from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-panel';
|
||||
import {
|
||||
CheckoutCreator,
|
||||
CheckoutCreatorSkeleton,
|
||||
} from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-creator';
|
||||
import {
|
||||
CheckoutPanel,
|
||||
CheckoutSkeleton,
|
||||
} from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-panel';
|
||||
import { useCheckoutChannel } from '@lumina/market/features/checkout';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import type { CheckoutTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* Checkout on desktop (U9 ۹.۱): one centred column of 480 under the header, back beside the
|
||||
* title, and the pay block stuck to the bottom of the window while the tiers scroll.
|
||||
* title, and the pay block stuck to the bottom of the window while the tiers scroll. It renders
|
||||
* in the browser only (0070): the header, the title and the skeleton stay until the channel
|
||||
* arrives.
|
||||
*/
|
||||
export function CheckoutTemplate({ channel }: CheckoutTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'payment');
|
||||
export function CheckoutTemplate({ username }: CheckoutTemplateProps) {
|
||||
const { t } = useTranslation('payment');
|
||||
const page = useCheckoutChannel(username);
|
||||
const channelHref = ROUTES.channel(username);
|
||||
|
||||
let content: ReactNode;
|
||||
if (page.status === 'pending') {
|
||||
content = (
|
||||
<CheckoutSkeleton
|
||||
layout="desktop"
|
||||
creator={<CheckoutCreatorSkeleton />}
|
||||
label={t('checkout.loading')}
|
||||
/>
|
||||
);
|
||||
} else if (page.status === 'not-found') {
|
||||
content = <StatusEmptyState variant="not-found" size="page" />;
|
||||
} else {
|
||||
const { channel } = page;
|
||||
content = (
|
||||
<PartBoundary name="checkout" description={t('checkout.error')} framed>
|
||||
<CheckoutPanel
|
||||
creatorId={channel.creatorId}
|
||||
channelHref={channelHref}
|
||||
layout="desktop"
|
||||
creator={<CheckoutCreator creator={channel} />}
|
||||
creatorName={channel.displayName ?? channel.username}
|
||||
creatorLinks={channel.socialLinks}
|
||||
/>
|
||||
</PartBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
||||
|
|
@ -33,22 +77,9 @@ export function CheckoutTemplate({ channel }: CheckoutTemplateProps) {
|
|||
>
|
||||
<DesktopPageTitle
|
||||
title={t('checkout.title')}
|
||||
parentHref={ROUTES.channel(channel.username)}
|
||||
parentHref={channelHref}
|
||||
/>
|
||||
<PartBoundary
|
||||
name="checkout"
|
||||
description={t('checkout.error')}
|
||||
framed
|
||||
>
|
||||
<CheckoutPanel
|
||||
creatorId={channel.creatorId}
|
||||
channelHref={ROUTES.channel(channel.username)}
|
||||
layout="desktop"
|
||||
creator={<CheckoutCreator creator={channel} />}
|
||||
creatorName={channel.displayName ?? channel.username}
|
||||
creatorLinks={channel.socialLinks}
|
||||
/>
|
||||
</PartBoundary>
|
||||
{content}
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
|
||||
export type CheckoutTemplateProps = { channel: PublicCreatorPayload };
|
||||
export type CheckoutTemplateProps = {
|
||||
/** The channel's username as the API stores it (lower case). */
|
||||
username: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ import type { ReactNode } from 'react';
|
|||
|
||||
import { i18n } from '../../../i18n';
|
||||
|
||||
// Only the landing is indexed (0071); both tabs inherit this.
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('rules:meta-title'),
|
||||
description: i18n.t('rules:meta-description'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
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>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import { AnalystsDirectory } from '@lumina/market/app/screens/(main)/analysts/organisms/analysts-directory';
|
||||
import { getFeaturedCreators, readOnServer } from '@lumina/market/server';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { i18n } from '../../../i18n';
|
||||
|
|
@ -11,20 +10,15 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* «تحلیلگران منتخب», `/analysts` (J04-3): every featured analyst, read on the server, the same for
|
||||
* every visitor; follow (an investor) and the free registration card (a guest) join in the
|
||||
* browser. Signed-in visitors are not sent anywhere. A failed read is the page's error state with
|
||||
* its retry, never a partial list.
|
||||
* «تحلیلگران منتخب», `/analysts` (J04-3): every featured analyst, read in the browser only
|
||||
* (0070), the same for every visitor; follow (an investor) and the free registration card (a
|
||||
* guest) join once the viewer is known. Signed-in visitors are not sent anywhere. A failed read
|
||||
* is the page's error state with its retry, never a partial list.
|
||||
*/
|
||||
export default async function AnalystsPage() {
|
||||
const featured = await readOnServer(() => getFeaturedCreators());
|
||||
|
||||
export default function AnalystsPage() {
|
||||
return (
|
||||
<AnalystsTemplate>
|
||||
<AnalystsDirectory
|
||||
analysts={featured.status === 'ok' ? featured.data : []}
|
||||
layout="desktop"
|
||||
/>
|
||||
<AnalystsDirectory layout="desktop" />
|
||||
</AnalystsTemplate>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Card } from '@lumina/island/molecules/card';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { DeskBack } from '@lumina/market/app/navigation';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
import { ChannelSkeleton } from './templates/channel-template';
|
||||
|
||||
/**
|
||||
* The channel before it arrives, in the 640 column and its reading order: «بازگشت», the header
|
||||
* panel, the track record, then a post.
|
||||
* The channel before it arrives, in the 640 column under «بازگشت»: the header panel, the track
|
||||
* record, then a post. The page shows the same skeleton until its read arrives.
|
||||
*/
|
||||
export default function Loading() {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox
|
||||
|
|
@ -19,11 +16,7 @@ export default function Loading() {
|
|||
className="w-full max-w-content"
|
||||
>
|
||||
<DeskBack />
|
||||
<Card padding="lg">
|
||||
<SkeletonPreset preset="header" framed delayed label={t('loading')} />
|
||||
</Card>
|
||||
<SkeletonPreset preset="stats" delayed label={t('stats.loading')} />
|
||||
<SkeletonPreset preset="post-media" delayed label={t('feed.loading')} />
|
||||
<ChannelSkeleton delayed />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,11 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { ChannelNotFound } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { displayUrl } from '../../../../configs';
|
||||
import { ChannelMissing } from './templates/channel-template';
|
||||
|
||||
export const metadata: Metadata = { robots: { index: false } };
|
||||
|
||||
/** No channel at this address, or not any more. */
|
||||
/** An address that can't be a username; the page shows the same state for an unknown one. */
|
||||
export default function ChannelNotFoundPage() {
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox direction="flex-col" className="w-full max-w-content">
|
||||
<ChannelNotFound layout="desktop" siteHost={displayUrl('')} />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
return <ChannelMissing siteHost={displayUrl('')} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
import { ROUTES, withSearchParams } from '@lumina/market/app/navigation';
|
||||
import {
|
||||
channelMetadata,
|
||||
getChannel,
|
||||
getRequestTime,
|
||||
readOnServer,
|
||||
} from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
|
@ -18,33 +12,26 @@ type ChannelPageProps = {
|
|||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
};
|
||||
|
||||
// The one kind of route whose metadata names its data (0055): it reads through the same per-request
|
||||
// cache as the page, so the first byte, held for the metadata in <head> (0054), waits for that
|
||||
// one read.
|
||||
// From the address alone (0070): the server reads nothing for this page.
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: ChannelPageProps): Promise<Metadata> {
|
||||
const username = toChannelUsername((await params).username);
|
||||
if (!username) return { robots: { index: false } };
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') return { robots: { index: false } };
|
||||
if (channel.data.suspended) {
|
||||
return {
|
||||
title: i18n.t('channel:meta.unavailable-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
return channelMetadata({
|
||||
channel: channel.data,
|
||||
title: i18n.t('channel:meta.title', { username }),
|
||||
description: i18n.t('channel:meta.description', { username }),
|
||||
});
|
||||
return {
|
||||
title: username
|
||||
? i18n.t('channel:meta.title', { username })
|
||||
: i18n.t('channel:meta.unavailable-title'),
|
||||
description: username
|
||||
? i18n.t('channel:meta.description', { username })
|
||||
: undefined,
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A creator's channel, `/channels/username`. The same server render for every visitor: the
|
||||
* header, the track record and the first posts; subscribe, follow and the locked posts' gates
|
||||
* load in the browser. Any other spelling of the username redirects to the one the API stores.
|
||||
* A creator's channel, `/channels/username`. It renders in the browser only (0070), the same for
|
||||
* every visitor: the server reads nothing and sends the skeleton. Any other spelling of the
|
||||
* username redirects to the stored one, keeping an invite link's `?code=` (0059).
|
||||
*/
|
||||
export default async function ChannelPage({
|
||||
params,
|
||||
|
|
@ -53,20 +40,17 @@ export default async function ChannelPage({
|
|||
const segment = (await params).username;
|
||||
const username = toChannelUsername(segment);
|
||||
if (!username) notFound();
|
||||
// An invite link's `?code=` goes along (0059).
|
||||
if (username !== segment) {
|
||||
permanentRedirect(
|
||||
withSearchParams(ROUTES.channel(username), await searchParams),
|
||||
);
|
||||
}
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') notFound();
|
||||
|
||||
return (
|
||||
<ChannelTemplate
|
||||
channel={channel.data}
|
||||
username={username}
|
||||
channelUrl={displayUrl(ROUTES.channel(username))}
|
||||
now={getRequestTime()}
|
||||
siteHost={displayUrl('')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
import { Card } from '@lumina/island/molecules/card';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { DeskBack } from '@lumina/market/app/navigation';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import { PostSkeleton } from './templates/post-template';
|
||||
|
||||
/**
|
||||
* The post before it arrives, in the 640 column (C4b ۱.۵): «بازگشت», the channel bar's panel
|
||||
* with the author row and the subscribe and follow row, then the post with its media. No lock is
|
||||
* guessed meanwhile.
|
||||
* The post before it arrives, in the 640 column under «بازگشت»: the creator's panel, then the
|
||||
* post with its media. The page shows the same skeleton until its reads arrive.
|
||||
*/
|
||||
export default function Loading() {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox
|
||||
|
|
@ -21,23 +16,7 @@ export default function Loading() {
|
|||
className="w-full max-w-content"
|
||||
>
|
||||
<DeskBack />
|
||||
<Card padding="lg">
|
||||
<SkeletonRegion delayed label={t('loading')}>
|
||||
<FlexBox
|
||||
alignItems="items-center"
|
||||
gap="gap-3"
|
||||
className="min-h-touch-target"
|
||||
>
|
||||
<Skeleton shape="circle" className="size-10" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
</FlexBox>
|
||||
<FlexBox gap="gap-2">
|
||||
<Skeleton shape="pill" className="h-control-md flex-1" />
|
||||
<Skeleton shape="pill" className="h-control-md w-32" />
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
</Card>
|
||||
<SkeletonPreset preset="post-media" delayed label={t('post.loading')} />
|
||||
<PostSkeleton delayed />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
import { ROUTES } from '@lumina/market/app/navigation';
|
||||
import { POST_ID_PATTERN } from '@lumina/market/features/post';
|
||||
import {
|
||||
getChannel,
|
||||
getRequestTime,
|
||||
getPost,
|
||||
postMetadata,
|
||||
readOnServer,
|
||||
} from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
|
@ -17,65 +10,37 @@ import { PostTemplate } from './templates/post-template';
|
|||
|
||||
type PostPageProps = { params: Promise<{ username: string; id: string }> };
|
||||
|
||||
/** The channel and the post, read together; a post that isn't this channel's is missing. */
|
||||
async function readPostPage(username: string, id: string) {
|
||||
const [channel, post] = await Promise.all([
|
||||
readOnServer(() => getChannel(username)),
|
||||
POST_ID_PATTERN.test(id)
|
||||
? readOnServer(() => getPost(id))
|
||||
: ({ status: 'not-found' } as const),
|
||||
]);
|
||||
if (channel.status !== 'ok') return null;
|
||||
const found =
|
||||
post.status === 'ok' && post.data.creatorId === channel.data.creatorId
|
||||
? post.data
|
||||
: null;
|
||||
return { channel: channel.data, post: found };
|
||||
}
|
||||
|
||||
// The one kind of route whose metadata names its data (0055): it reads through the same per-request
|
||||
// cache as the page, so the first byte, held for the metadata in <head> (0054), waits for that
|
||||
// one read.
|
||||
// From the address alone (0070): the server reads nothing for this page.
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PostPageProps): Promise<Metadata> {
|
||||
const { username: segment, id } = await params;
|
||||
const username = toChannelUsername(segment);
|
||||
const page = username ? await readPostPage(username, id) : null;
|
||||
if (!page?.post || page.channel.suspended) {
|
||||
return {
|
||||
title: i18n.t('channel:meta.post-missing-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
return postMetadata({
|
||||
channel: page.channel,
|
||||
post: page.post,
|
||||
fallbackTitle: i18n.t('channel:meta.post-title', {
|
||||
username: page.channel.username,
|
||||
}),
|
||||
});
|
||||
const username = toChannelUsername((await params).username);
|
||||
return {
|
||||
title: username
|
||||
? i18n.t('channel:meta.post-title', { username })
|
||||
: i18n.t('channel:meta.post-missing-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* One post, `/channels/username/posts/[id]`: where every shared link lands. The server renders it
|
||||
* as every visitor sees it; a subscriber's or the creator's premium post opens in the browser. A
|
||||
* deleted or unknown post keeps the channel's frame and leads back to the channel.
|
||||
* One post, `/channels/username/posts/[id]`: where every shared link lands. It renders in the
|
||||
* browser only (0070): the server reads nothing and sends the skeleton; a subscriber's or the
|
||||
* creator's premium post arrives open. A deleted or unknown post keeps the channel's frame and
|
||||
* leads back to the channel, as does an id that can't be a post's.
|
||||
*/
|
||||
export default async function PostPage({ params }: PostPageProps) {
|
||||
const { username: segment, id } = await params;
|
||||
const username = toChannelUsername(segment);
|
||||
if (!username) notFound();
|
||||
if (username !== segment) permanentRedirect(ROUTES.post(username, id));
|
||||
const page = await readPostPage(username, id);
|
||||
if (!page) notFound();
|
||||
|
||||
return (
|
||||
<PostTemplate
|
||||
channel={page.channel}
|
||||
post={page.post}
|
||||
username={username}
|
||||
postId={POST_ID_PATTERN.test(id) ? id : null}
|
||||
channelUrl={displayUrl(ROUTES.channel(username))}
|
||||
now={getRequestTime()}
|
||||
siteHost={displayUrl('')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
import { Card } from '@lumina/island/molecules/card';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import type { PostSkeletonProps } from './types';
|
||||
|
||||
/**
|
||||
* The post before it arrives, in the 640 column under «بازگشت»: the creator's panel with its
|
||||
* author row and the subscribe and follow row, then the post with its media. No lock is guessed
|
||||
* meanwhile. The route's loading and the page's own wait share it.
|
||||
*/
|
||||
export function PostSkeleton({ delayed }: PostSkeletonProps) {
|
||||
const { t } = useTranslation('channel');
|
||||
return (
|
||||
<>
|
||||
<Card padding="lg">
|
||||
<SkeletonRegion delayed={delayed} label={t('loading')}>
|
||||
<FlexBox
|
||||
alignItems="items-center"
|
||||
gap="gap-3"
|
||||
className="min-h-touch-target"
|
||||
>
|
||||
<Skeleton shape="circle" className="size-10" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
</FlexBox>
|
||||
<FlexBox gap="gap-2">
|
||||
<Skeleton shape="pill" className="h-control-md flex-1" />
|
||||
<Skeleton shape="pill" className="h-control-md w-32" />
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
</Card>
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed={delayed}
|
||||
label={t('post.loading')}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { DeskBack, ROUTES } from '@lumina/market/app/navigation';
|
||||
|
|
@ -6,21 +8,70 @@ import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[
|
|||
import { PostChannelBar } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-channel-bar';
|
||||
import { PostMissing } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-missing';
|
||||
import { PostView } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-view';
|
||||
import { usePostPage } from '@lumina/market/features/post';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../../../i18n';
|
||||
import { ChannelMissing } from '../../../../templates/channel-template';
|
||||
import { PostSkeleton } from './PostSkeleton';
|
||||
import type { PostTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* The post on desktop, in the 640 column under «بازگشت»: the creator with subscribe and follow,
|
||||
* then the post in full. The action area loads in the browser.
|
||||
* The post on desktop: one 640px column under «بازگشت», the creator's panel with subscribe and
|
||||
* follow, then the post in full. It renders in the browser only (0070): the server sends the
|
||||
* column and the skeleton, which stay until the channel and the post arrive. The action area
|
||||
* waits for the viewer.
|
||||
*/
|
||||
export function PostTemplate({
|
||||
channel,
|
||||
post,
|
||||
username,
|
||||
postId,
|
||||
channelUrl,
|
||||
now,
|
||||
siteHost,
|
||||
}: PostTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
const { t } = useTranslation('channel');
|
||||
const page = usePostPage(username, postId);
|
||||
|
||||
if (page.status === 'not-found')
|
||||
return <ChannelMissing siteHost={siteHost} />;
|
||||
|
||||
let content: ReactNode;
|
||||
if (page.status === 'pending') {
|
||||
content = <PostSkeleton />;
|
||||
} else if (page.channel.suspended) {
|
||||
content = <ChannelUnavailable context="post" />;
|
||||
} else if (page.status === 'ok') {
|
||||
const { channel, post, now } = page;
|
||||
content = (
|
||||
<>
|
||||
<PostChannelBar
|
||||
channel={channel}
|
||||
layout="desktop"
|
||||
verifiedLabel={t('header.verified')}
|
||||
actions={
|
||||
<PartBoundary name="post-channel-actions">
|
||||
<ChannelActions
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
saleOpen={channel.saleOpen}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
/>
|
||||
<PostView
|
||||
post={post}
|
||||
username={channel.username}
|
||||
displayName={channel.displayName}
|
||||
avatarUrl={channel.avatarUrl}
|
||||
now={now}
|
||||
layout="desktop"
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
content = <PostMissing username={username} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
|
|
@ -30,42 +81,8 @@ export function PostTemplate({
|
|||
className="w-full max-w-content"
|
||||
>
|
||||
{/* A link opened on its own goes back to the post's channel (R14). */}
|
||||
<DeskBack
|
||||
parentHref={ROUTES.channel(channel.username)}
|
||||
backToPrevious
|
||||
/>
|
||||
{channel.suspended ? (
|
||||
<ChannelUnavailable context="post" />
|
||||
) : post ? (
|
||||
<>
|
||||
<PostChannelBar
|
||||
channel={channel}
|
||||
layout="desktop"
|
||||
verifiedLabel={t('header.verified')}
|
||||
actions={
|
||||
<PartBoundary name="post-channel-actions">
|
||||
<ChannelActions
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
saleOpen={channel.saleOpen}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
/>
|
||||
<PostView
|
||||
post={post}
|
||||
username={channel.username}
|
||||
displayName={channel.displayName}
|
||||
avatarUrl={channel.avatarUrl}
|
||||
now={now}
|
||||
layout="desktop"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<PostMissing username={channel.username} />
|
||||
)}
|
||||
<DeskBack parentHref={ROUTES.channel(username)} backToPrevious />
|
||||
{content}
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
export { PostSkeleton } from './PostSkeleton';
|
||||
export { PostTemplate } from './PostTemplate';
|
||||
export type { PostTemplateProps } from './types';
|
||||
export type { PostSkeletonProps, PostTemplateProps } from './types';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
import type { PostPayload } from '@lumina/market/features/post';
|
||||
|
||||
export type PostTemplateProps = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** `null`: deleted, unknown, or another channel's. */
|
||||
post: PostPayload | null;
|
||||
/** The channel's username as the API stores it (lower case). */
|
||||
username: string;
|
||||
/** `null`: the address can't name a post, so the post is missing. */
|
||||
postId: string | null;
|
||||
/** «lumina.ir/channels/sara_gold», for the guest's login prompt. */
|
||||
channelUrl: string;
|
||||
/** The render's time: the post's time counts from it. */
|
||||
now: string;
|
||||
/** «lumina.ir», for the channel's not-found state. */
|
||||
siteHost: string;
|
||||
};
|
||||
|
||||
export type PostSkeletonProps = {
|
||||
/** The route's loading: shown only when the wait is long enough to notice. */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { ChannelNotFound } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
|
||||
import type { ChannelMissingProps } from './types';
|
||||
|
||||
/**
|
||||
* No channel at this address, or not any more, in the 640 column. Its creator, before approval,
|
||||
* sees their own tab here instead (C6 ۵.۲); the browser decides.
|
||||
*/
|
||||
export function ChannelMissing({ siteHost }: ChannelMissingProps) {
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox direction="flex-col" className="w-full max-w-content">
|
||||
<ChannelNotFound layout="desktop" siteHost={siteHost} />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
'use client';
|
||||
|
||||
import { Card } from '@lumina/island/molecules/card';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import type { ChannelSkeletonProps } from './types';
|
||||
|
||||
/**
|
||||
* The channel before it arrives, in the 640 column under «بازگشت»: the header panel, the track
|
||||
* record, then a post. The route's loading and the page's own wait share it.
|
||||
*/
|
||||
export function ChannelSkeleton({ delayed }: ChannelSkeletonProps) {
|
||||
const { t } = useTranslation('channel');
|
||||
return (
|
||||
<>
|
||||
<Card padding="lg">
|
||||
<SkeletonPreset
|
||||
preset="header"
|
||||
framed
|
||||
delayed={delayed}
|
||||
label={t('loading')}
|
||||
/>
|
||||
</Card>
|
||||
<SkeletonPreset
|
||||
preset="stats"
|
||||
delayed={delayed}
|
||||
label={t('stats.loading')}
|
||||
/>
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed={delayed}
|
||||
label={t('feed.loading')}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,125 +1,139 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { ApprovedWelcome } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/approved-welcome';
|
||||
import { ChannelActions } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-actions';
|
||||
import { ChannelDeskBack } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-desk-back';
|
||||
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
|
||||
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed';
|
||||
import {
|
||||
ChannelHeader,
|
||||
channelHeaderLabels,
|
||||
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header';
|
||||
import { PendingChannelGate } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
import { ChannelShare } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-share';
|
||||
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats/server';
|
||||
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats';
|
||||
import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-unavailable';
|
||||
import { FollowNotice } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/follow-notice';
|
||||
import { useChannelPage } from '@lumina/market/features/channel';
|
||||
import { creatorStatsLabels } from '@lumina/market/shared/labels';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Suspense } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import { ChannelMissing } from './ChannelMissing';
|
||||
import { ChannelSkeleton } from './ChannelSkeleton';
|
||||
import type { ChannelTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* The channel on desktop: one 640px column, no side rail, under «بازگشت» (R14; none on the
|
||||
* creator's own tab). The header panel renders at once; the first follow's notice and the track
|
||||
* record follow it, then the feed, streaming in reading order, each in its own boundary, and the
|
||||
* action area loads in the browser.
|
||||
* creator's own tab). It renders in the browser only (0070): the server sends the column with
|
||||
* «بازگشت» and the skeleton, which stay until the channel arrives. Then the header panel renders
|
||||
* at once; the first follow's notice and the track record follow it, then the feed, each loading
|
||||
* in its own boundary, and the action area waits for the viewer.
|
||||
*/
|
||||
export function ChannelTemplate({
|
||||
channel,
|
||||
username,
|
||||
channelUrl,
|
||||
now,
|
||||
siteHost,
|
||||
}: ChannelTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
const { t, i18n } = useTranslation('channel');
|
||||
const page = useChannelPage(username);
|
||||
|
||||
// Suspension outranks everything: no header, posts or actions, for anyone (U6 ۵.۳).
|
||||
if (channel.suspended) {
|
||||
return (
|
||||
<FlexBox
|
||||
tag="main"
|
||||
justifyContent="justify-center"
|
||||
className="px-8 py-10"
|
||||
>
|
||||
<FlexBox
|
||||
direction="flex-col"
|
||||
gap="gap-4"
|
||||
className="w-full max-w-content"
|
||||
>
|
||||
<ChannelDeskBack creatorId={channel.creatorId} />
|
||||
<ChannelUnavailable
|
||||
context="channel"
|
||||
channel={channel}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
/>
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
if (page.status === 'not-found')
|
||||
return <ChannelMissing siteHost={siteHost} />;
|
||||
|
||||
const publicChannel = (
|
||||
<>
|
||||
<ApprovedWelcome creatorId={channel.creatorId} layout="desktop" />
|
||||
<ChannelHeader
|
||||
const channel = page.status === 'ok' ? page.channel : null;
|
||||
let content: ReactNode;
|
||||
|
||||
if (!channel) {
|
||||
content = <ChannelSkeleton />;
|
||||
} else if (channel.suspended) {
|
||||
// Suspension outranks everything: no header, posts or actions, for anyone (U6 ۵.۳).
|
||||
content = (
|
||||
<ChannelUnavailable
|
||||
context="channel"
|
||||
channel={channel}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
share={
|
||||
<ChannelShare
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
/>
|
||||
}
|
||||
stats={
|
||||
<>
|
||||
<FollowNotice creatorId={channel.creatorId} />
|
||||
<PartBoundary
|
||||
name="channel-stats"
|
||||
title={t('stats.error-title')}
|
||||
description={t('stats.error-description')}
|
||||
framed
|
||||
>
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonPreset preset="stats" label={t('stats.loading')} />
|
||||
}
|
||||
>
|
||||
<ChannelStats
|
||||
creatorId={channel.creatorId}
|
||||
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
|
||||
/>
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<PartBoundary name="channel-actions">
|
||||
<ChannelActions
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
const publicChannel = (
|
||||
<>
|
||||
<ApprovedWelcome creatorId={channel.creatorId} layout="desktop" />
|
||||
<ChannelHeader
|
||||
channel={channel}
|
||||
layout="desktop"
|
||||
share={
|
||||
<ChannelShare
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
saleOpen={channel.saleOpen}
|
||||
inviteNoteName={channel.displayName}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
|
||||
verified={!channel.verificationPending}
|
||||
/>
|
||||
<PartBoundary name="channel-feed">
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonPreset preset="post" count={2} label={t('feed.loading')} />
|
||||
}
|
||||
>
|
||||
<ChannelFeed channel={channel} now={now} layout="desktop" />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</>
|
||||
);
|
||||
stats={
|
||||
<>
|
||||
<FollowNotice creatorId={channel.creatorId} />
|
||||
<PartBoundary
|
||||
name="channel-stats"
|
||||
title={t('stats.error-title')}
|
||||
description={t('stats.error-description')}
|
||||
framed
|
||||
>
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonPreset preset="stats" label={t('stats.loading')} />
|
||||
}
|
||||
>
|
||||
<ChannelStats
|
||||
creatorId={channel.creatorId}
|
||||
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
|
||||
/>
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<PartBoundary name="channel-actions">
|
||||
<ChannelActions
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="desktop"
|
||||
saleOpen={channel.saleOpen}
|
||||
inviteNoteName={channel.displayName}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
|
||||
verified={!channel.verificationPending}
|
||||
/>
|
||||
<PartBoundary name="channel-feed">
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonPreset
|
||||
preset="post"
|
||||
count={2}
|
||||
label={t('feed.loading')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ChannelFeed channel={channel} layout="desktop" />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</>
|
||||
);
|
||||
content = channel.verificationPending ? (
|
||||
<PendingChannelGate layout="desktop" channelUrl={channelUrl}>
|
||||
{publicChannel}
|
||||
</PendingChannelGate>
|
||||
) : (
|
||||
publicChannel
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
|
|
@ -128,14 +142,8 @@ export function ChannelTemplate({
|
|||
gap="gap-4"
|
||||
className="w-full max-w-content"
|
||||
>
|
||||
<ChannelDeskBack creatorId={channel.creatorId} />
|
||||
{channel.verificationPending ? (
|
||||
<PendingChannelGate layout="desktop" channelUrl={channelUrl}>
|
||||
{publicChannel}
|
||||
</PendingChannelGate>
|
||||
) : (
|
||||
publicChannel
|
||||
)}
|
||||
<ChannelDeskBack creatorId={channel?.creatorId} />
|
||||
{content}
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,2 +1,8 @@
|
|||
export { ChannelMissing } from './ChannelMissing';
|
||||
export { ChannelSkeleton } from './ChannelSkeleton';
|
||||
export { ChannelTemplate } from './ChannelTemplate';
|
||||
export type { ChannelTemplateProps } from './types';
|
||||
export type {
|
||||
ChannelMissingProps,
|
||||
ChannelSkeletonProps,
|
||||
ChannelTemplateProps,
|
||||
} from './types';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
|
||||
export type ChannelTemplateProps = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** The username as the API stores it (lower case). */
|
||||
username: string;
|
||||
/** «lumina.ir/channels/sara_gold». */
|
||||
channelUrl: string;
|
||||
/** The render's time: the posts' relative times count from it. */
|
||||
now: string;
|
||||
/** «lumina.ir», for the not-found state. */
|
||||
siteHost: string;
|
||||
};
|
||||
|
||||
export type ChannelSkeletonProps = {
|
||||
/** The route's loading: shown only when the wait is long enough to notice. */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
||||
export type ChannelMissingProps = {
|
||||
siteHost: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ROUTES, withSearchParams } from '@lumina/market/app/navigation';
|
||||
import { getChannel, readOnServer } from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect, redirect } from 'next/navigation';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
import { CheckoutTemplate } from './templates/checkout-template';
|
||||
|
|
@ -18,10 +17,10 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* Checkout for a creator's channel (U9), reached only from its «اشتراک». The server renders the
|
||||
* same page for everyone: the bar and who is being paid; the investor's own checkout loads in the
|
||||
* browser. Another spelling of the username redirects to the stored one; a suspended channel
|
||||
* sends the visitor to the channel, which says it is unavailable.
|
||||
* Checkout for a creator's channel (U9), reached only from its «اشتراک». It renders in the
|
||||
* browser only (0070): the server reads nothing and sends the bar and the skeleton. Another
|
||||
* spelling of the username redirects to the stored one; a suspended channel sends the visitor to
|
||||
* the channel, which says it is unavailable.
|
||||
*/
|
||||
export default async function CheckoutPage({
|
||||
params,
|
||||
|
|
@ -36,9 +35,6 @@ export default async function CheckoutPage({
|
|||
withSearchParams(ROUTES.checkout(username), await searchParams),
|
||||
);
|
||||
}
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') notFound();
|
||||
if (channel.data.suspended) redirect(ROUTES.channel(username));
|
||||
|
||||
return <CheckoutTemplate channel={channel.data} />;
|
||||
return <CheckoutTemplate username={username} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,75 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
|
||||
import { CheckoutCreator } from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-creator';
|
||||
import { CheckoutPanel } from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-panel';
|
||||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import {
|
||||
PartBoundary,
|
||||
StatusEmptyState,
|
||||
} from '@lumina/market/app/error-boundaries';
|
||||
import { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
|
||||
import {
|
||||
CheckoutCreator,
|
||||
CheckoutCreatorSkeleton,
|
||||
} from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-creator';
|
||||
import {
|
||||
CheckoutPanel,
|
||||
CheckoutSkeleton,
|
||||
} from '@lumina/market/app/screens/(flow)/checkout/[username]/organisms/checkout-panel';
|
||||
import { useCheckoutChannel } from '@lumina/market/features/checkout';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import type { CheckoutTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* Checkout on mobile: a task page pushed from the channel, back · «خرید اشتراک» · support and no
|
||||
* bottom nav (U9 §۲), with the pay block pinned to the bottom of the screen.
|
||||
* bottom nav (U9 §۲), with the pay block pinned to the bottom of the screen. It renders in the
|
||||
* browser only (0070): the bar and the skeleton stay until the channel arrives.
|
||||
*/
|
||||
export function CheckoutTemplate({ channel }: CheckoutTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'payment');
|
||||
export function CheckoutTemplate({ username }: CheckoutTemplateProps) {
|
||||
const { t } = useTranslation('payment');
|
||||
const page = useCheckoutChannel(username);
|
||||
const channelHref = ROUTES.channel(username);
|
||||
|
||||
let content: ReactNode;
|
||||
if (page.status === 'pending') {
|
||||
content = (
|
||||
<CheckoutSkeleton
|
||||
layout="mobile"
|
||||
creator={<CheckoutCreatorSkeleton />}
|
||||
label={t('checkout.loading')}
|
||||
/>
|
||||
);
|
||||
} else if (page.status === 'not-found') {
|
||||
content = (
|
||||
<FlexBox
|
||||
direction="flex-col"
|
||||
justifyContent="justify-center"
|
||||
className="flex-1 px-4"
|
||||
>
|
||||
<StatusEmptyState variant="not-found" size="page" />
|
||||
</FlexBox>
|
||||
);
|
||||
} else {
|
||||
const { channel } = page;
|
||||
content = (
|
||||
<PartBoundary name="checkout" description={t('checkout.error')}>
|
||||
<CheckoutPanel
|
||||
creatorId={channel.creatorId}
|
||||
channelHref={channelHref}
|
||||
layout="mobile"
|
||||
creator={<CheckoutCreator creator={channel} />}
|
||||
creatorName={channel.displayName ?? channel.username}
|
||||
creatorLinks={channel.socialLinks}
|
||||
/>
|
||||
</PartBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
||||
<MobileTopBar
|
||||
title={t('checkout.title')}
|
||||
parentHref={ROUTES.channel(channel.username)}
|
||||
/>
|
||||
<MobileTopBar title={t('checkout.title')} parentHref={channelHref} />
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<PartBoundary name="checkout" description={t('checkout.error')}>
|
||||
<CheckoutPanel
|
||||
creatorId={channel.creatorId}
|
||||
channelHref={ROUTES.channel(channel.username)}
|
||||
layout="mobile"
|
||||
creator={<CheckoutCreator creator={channel} />}
|
||||
creatorName={channel.displayName ?? channel.username}
|
||||
creatorLinks={channel.socialLinks}
|
||||
/>
|
||||
</PartBoundary>
|
||||
{content}
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
|
||||
export type CheckoutTemplateProps = { channel: PublicCreatorPayload };
|
||||
export type CheckoutTemplateProps = {
|
||||
/** The channel's username as the API stores it (lower case). */
|
||||
username: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ import type { ReactNode } from 'react';
|
|||
|
||||
import { i18n } from '../../../i18n';
|
||||
|
||||
// Only the landing is indexed (0071); both tabs inherit this.
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('rules:meta-title'),
|
||||
description: i18n.t('rules:meta-description'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
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>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import { AnalystsDirectory } from '@lumina/market/app/screens/(main)/analysts/organisms/analysts-directory';
|
||||
import { getFeaturedCreators, readOnServer } from '@lumina/market/server';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { i18n } from '../../../i18n';
|
||||
|
|
@ -11,20 +10,15 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* «تحلیلگران منتخب», `/analysts` (J04-3): every featured analyst, read on the server, the same for
|
||||
* every visitor; follow (an investor) and the free registration card (a guest) join in the
|
||||
* browser. Signed-in visitors are not sent anywhere. A failed read is the page's error state with
|
||||
* its retry, never a partial list.
|
||||
* «تحلیلگران منتخب», `/analysts` (J04-3): every featured analyst, read in the browser only
|
||||
* (0070), the same for every visitor; follow (an investor) and the free registration card (a
|
||||
* guest) join once the viewer is known. Signed-in visitors are not sent anywhere. A failed read
|
||||
* is the page's error state with its retry, never a partial list.
|
||||
*/
|
||||
export default async function AnalystsPage() {
|
||||
const featured = await readOnServer(() => getFeaturedCreators());
|
||||
|
||||
export default function AnalystsPage() {
|
||||
return (
|
||||
<AnalystsTemplate>
|
||||
<AnalystsDirectory
|
||||
analysts={featured.status === 'ok' ? featured.data : []}
|
||||
layout="mobile"
|
||||
/>
|
||||
<AnalystsDirectory layout="mobile" />
|
||||
</AnalystsTemplate>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,19 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
import { ChannelSkeleton } from './templates/channel-template';
|
||||
|
||||
/**
|
||||
* The channel before it arrives, in its reading order: the real top bar, the header, the track
|
||||
* record, then a post.
|
||||
* record, then a post. The page shows the same skeleton until its read arrives.
|
||||
*/
|
||||
export default function Loading() {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar title={t('top-bar.channel')} />
|
||||
<MobileTopBar title={i18n.t('channel:top-bar.channel')} />
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
{/* The skeleton draws the header's flush band itself. */}
|
||||
<SkeletonPreset preset="header" delayed label={t('loading')} />
|
||||
<FlexBox direction="flex-col" gap="gap-4" className="p-4">
|
||||
<SkeletonPreset preset="stats" delayed label={t('stats.loading')} />
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed
|
||||
label={t('feed.loading')}
|
||||
/>
|
||||
</FlexBox>
|
||||
<ChannelSkeleton delayed />
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,27 +1,17 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import {
|
||||
ChannelNotFound,
|
||||
ChannelNotFoundTopBar,
|
||||
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { displayUrl } from '../../../../configs';
|
||||
import { i18n } from '../../../../i18n';
|
||||
import { ChannelMissing } from './templates/channel-template';
|
||||
|
||||
export const metadata: Metadata = { robots: { index: false } };
|
||||
|
||||
/**
|
||||
* No channel at this address, or not any more. Its creator, before approval, sees their own tab
|
||||
* here instead (C6 ۱.۲), under their tab bar; both are decided in the browser. The main is flush
|
||||
* for that tab's banner strip and header; the message keeps its own inset.
|
||||
*/
|
||||
/** An address that can't be a username; the page shows the same state for an unknown one. */
|
||||
export default function ChannelNotFoundPage() {
|
||||
return (
|
||||
<>
|
||||
<ChannelNotFoundTopBar title={i18n.t('channel:top-bar.channel')} />
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<ChannelNotFound layout="mobile" siteHost={displayUrl('')} />
|
||||
</FlexBox>
|
||||
</>
|
||||
<ChannelMissing
|
||||
title={i18n.t('channel:top-bar.channel')}
|
||||
siteHost={displayUrl('')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
import { ROUTES, withSearchParams } from '@lumina/market/app/navigation';
|
||||
import {
|
||||
channelMetadata,
|
||||
getChannel,
|
||||
getRequestTime,
|
||||
readOnServer,
|
||||
} from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
|
@ -18,33 +12,26 @@ type ChannelPageProps = {
|
|||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
};
|
||||
|
||||
// The one kind of route whose metadata names its data (0055): it reads through the same per-request
|
||||
// cache as the page, so the first byte, held for the metadata in <head> (0054), waits for that
|
||||
// one read.
|
||||
// From the address alone (0070): the server reads nothing for this page.
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: ChannelPageProps): Promise<Metadata> {
|
||||
const username = toChannelUsername((await params).username);
|
||||
if (!username) return { robots: { index: false } };
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') return { robots: { index: false } };
|
||||
if (channel.data.suspended) {
|
||||
return {
|
||||
title: i18n.t('channel:meta.unavailable-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
return channelMetadata({
|
||||
channel: channel.data,
|
||||
title: i18n.t('channel:meta.title', { username }),
|
||||
description: i18n.t('channel:meta.description', { username }),
|
||||
});
|
||||
return {
|
||||
title: username
|
||||
? i18n.t('channel:meta.title', { username })
|
||||
: i18n.t('channel:meta.unavailable-title'),
|
||||
description: username
|
||||
? i18n.t('channel:meta.description', { username })
|
||||
: undefined,
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A creator's channel, `/channels/username`. The same server render for every visitor: the
|
||||
* header, the track record and the first posts; subscribe, follow and the locked posts' gates
|
||||
* load in the browser. Any other spelling of the username redirects to the one the API stores.
|
||||
* A creator's channel, `/channels/username`. It renders in the browser only (0070), the same for
|
||||
* every visitor: the server reads nothing and sends the skeleton. Any other spelling of the
|
||||
* username redirects to the stored one, keeping an invite link's `?code=` (0059).
|
||||
*/
|
||||
export default async function ChannelPage({
|
||||
params,
|
||||
|
|
@ -53,20 +40,17 @@ export default async function ChannelPage({
|
|||
const segment = (await params).username;
|
||||
const username = toChannelUsername(segment);
|
||||
if (!username) notFound();
|
||||
// An invite link's `?code=` goes along (0059).
|
||||
if (username !== segment) {
|
||||
permanentRedirect(
|
||||
withSearchParams(ROUTES.channel(username), await searchParams),
|
||||
);
|
||||
}
|
||||
const channel = await readOnServer(() => getChannel(username));
|
||||
if (channel.status !== 'ok') notFound();
|
||||
|
||||
return (
|
||||
<ChannelTemplate
|
||||
channel={channel.data}
|
||||
username={username}
|
||||
channelUrl={displayUrl(ROUTES.channel(username))}
|
||||
now={getRequestTime()}
|
||||
siteHost={displayUrl('')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,19 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import { PostSkeleton } from './templates/post-template';
|
||||
|
||||
/**
|
||||
* The post before it arrives, in the real layout (C4b ۱.۵): the live top bar, the channel bar's
|
||||
* band with the author row and the subscribe and follow row, then the post with its media. No lock
|
||||
* is guessed meanwhile.
|
||||
* band, then the post with its media. The page shows the same skeleton until its reads arrive.
|
||||
*/
|
||||
export default function Loading() {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar title={t('top-bar.post')} />
|
||||
<MobileTopBar title={i18n.t('channel:top-bar.post')} />
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<SkeletonRegion
|
||||
delayed
|
||||
label={t('loading')}
|
||||
className="border-b border-border-subtle bg-surface p-4"
|
||||
>
|
||||
<FlexBox
|
||||
alignItems="items-center"
|
||||
gap="gap-3"
|
||||
className="min-h-touch-target"
|
||||
>
|
||||
<Skeleton shape="circle" className="size-10" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
</FlexBox>
|
||||
<FlexBox gap="gap-2">
|
||||
<Skeleton shape="pill" className="h-control-md flex-1" />
|
||||
<Skeleton shape="pill" className="h-control-md w-32" />
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
<FlexBox direction="flex-col" className="p-4">
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed
|
||||
label={t('post.loading')}
|
||||
/>
|
||||
</FlexBox>
|
||||
<PostSkeleton delayed />
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
import { ROUTES } from '@lumina/market/app/navigation';
|
||||
import { POST_ID_PATTERN } from '@lumina/market/features/post';
|
||||
import {
|
||||
getChannel,
|
||||
getRequestTime,
|
||||
getPost,
|
||||
postMetadata,
|
||||
readOnServer,
|
||||
} from '@lumina/market/server';
|
||||
import { toChannelUsername } from '@lumina/market/shared/utils';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound, permanentRedirect } from 'next/navigation';
|
||||
|
|
@ -17,65 +10,37 @@ import { PostTemplate } from './templates/post-template';
|
|||
|
||||
type PostPageProps = { params: Promise<{ username: string; id: string }> };
|
||||
|
||||
/** The channel and the post, read together; a post that isn't this channel's is missing. */
|
||||
async function readPostPage(username: string, id: string) {
|
||||
const [channel, post] = await Promise.all([
|
||||
readOnServer(() => getChannel(username)),
|
||||
POST_ID_PATTERN.test(id)
|
||||
? readOnServer(() => getPost(id))
|
||||
: ({ status: 'not-found' } as const),
|
||||
]);
|
||||
if (channel.status !== 'ok') return null;
|
||||
const found =
|
||||
post.status === 'ok' && post.data.creatorId === channel.data.creatorId
|
||||
? post.data
|
||||
: null;
|
||||
return { channel: channel.data, post: found };
|
||||
}
|
||||
|
||||
// The one kind of route whose metadata names its data (0055): it reads through the same per-request
|
||||
// cache as the page, so the first byte, held for the metadata in <head> (0054), waits for that
|
||||
// one read.
|
||||
// From the address alone (0070): the server reads nothing for this page.
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PostPageProps): Promise<Metadata> {
|
||||
const { username: segment, id } = await params;
|
||||
const username = toChannelUsername(segment);
|
||||
const page = username ? await readPostPage(username, id) : null;
|
||||
if (!page?.post || page.channel.suspended) {
|
||||
return {
|
||||
title: i18n.t('channel:meta.post-missing-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
return postMetadata({
|
||||
channel: page.channel,
|
||||
post: page.post,
|
||||
fallbackTitle: i18n.t('channel:meta.post-title', {
|
||||
username: page.channel.username,
|
||||
}),
|
||||
});
|
||||
const username = toChannelUsername((await params).username);
|
||||
return {
|
||||
title: username
|
||||
? i18n.t('channel:meta.post-title', { username })
|
||||
: i18n.t('channel:meta.post-missing-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* One post, `/channels/username/posts/[id]`: where every shared link lands. The server renders it
|
||||
* as every visitor sees it; a subscriber's or the creator's premium post opens in the browser. A
|
||||
* deleted or unknown post keeps the channel's frame and leads back to the channel.
|
||||
* One post, `/channels/username/posts/[id]`: where every shared link lands. It renders in the
|
||||
* browser only (0070): the server reads nothing and sends the skeleton; a subscriber's or the
|
||||
* creator's premium post arrives open. A deleted or unknown post keeps the channel's frame and
|
||||
* leads back to the channel, as does an id that can't be a post's.
|
||||
*/
|
||||
export default async function PostPage({ params }: PostPageProps) {
|
||||
const { username: segment, id } = await params;
|
||||
const username = toChannelUsername(segment);
|
||||
if (!username) notFound();
|
||||
if (username !== segment) permanentRedirect(ROUTES.post(username, id));
|
||||
const page = await readPostPage(username, id);
|
||||
if (!page) notFound();
|
||||
|
||||
return (
|
||||
<PostTemplate
|
||||
channel={page.channel}
|
||||
post={page.post}
|
||||
username={username}
|
||||
postId={POST_ID_PATTERN.test(id) ? id : null}
|
||||
channelUrl={displayUrl(ROUTES.channel(username))}
|
||||
now={getRequestTime()}
|
||||
siteHost={displayUrl('')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import type { PostSkeletonProps } from './types';
|
||||
|
||||
/**
|
||||
* The post before it arrives, in the real layout (C4b ۱.۵), under the live top bar: the channel
|
||||
* bar's band with the author row and the subscribe and follow row, then the post with its media.
|
||||
* No lock is guessed meanwhile. The route's loading and the page's own wait share it.
|
||||
*/
|
||||
export function PostSkeleton({ delayed }: PostSkeletonProps) {
|
||||
const { t } = useTranslation('channel');
|
||||
return (
|
||||
<>
|
||||
<SkeletonRegion
|
||||
delayed={delayed}
|
||||
label={t('loading')}
|
||||
className="border-b border-border-subtle bg-surface p-4"
|
||||
>
|
||||
<FlexBox
|
||||
alignItems="items-center"
|
||||
gap="gap-3"
|
||||
className="min-h-touch-target"
|
||||
>
|
||||
<Skeleton shape="circle" className="size-10" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
</FlexBox>
|
||||
<FlexBox gap="gap-2">
|
||||
<Skeleton shape="pill" className="h-control-md flex-1" />
|
||||
<Skeleton shape="pill" className="h-control-md w-32" />
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
<FlexBox direction="flex-col" className="p-4">
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed={delayed}
|
||||
label={t('post.loading')}
|
||||
/>
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
|
||||
|
|
@ -6,67 +8,88 @@ import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[
|
|||
import { PostChannelBar } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-channel-bar';
|
||||
import { PostMissing } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-missing';
|
||||
import { PostView } from '@lumina/market/app/screens/(main)/channels/[username]/posts/[id]/organisms/post-view';
|
||||
import { usePostPage } from '@lumina/market/features/post';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../../../i18n';
|
||||
import { ChannelMissing } from '../../../../templates/channel-template';
|
||||
import { PostSkeleton } from './PostSkeleton';
|
||||
import type { PostTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* The post on mobile, pushed from خانه or the channel: the creator with subscribe and follow,
|
||||
* then the post in full. The action area loads in the browser.
|
||||
* then the post in full. It renders in the browser only (0070): the server sends the top bar and
|
||||
* the skeleton, which stay until the channel and the post arrive. The action area waits for the
|
||||
* viewer.
|
||||
*/
|
||||
export function PostTemplate({
|
||||
channel,
|
||||
post,
|
||||
username,
|
||||
postId,
|
||||
channelUrl,
|
||||
now,
|
||||
siteHost,
|
||||
}: PostTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
const { t, i18n } = useTranslation('channel');
|
||||
const page = usePostPage(username, postId);
|
||||
|
||||
if (page.status === 'not-found') {
|
||||
return <ChannelMissing title={t('top-bar.channel')} siteHost={siteHost} />;
|
||||
}
|
||||
|
||||
let content: ReactNode;
|
||||
if (page.status === 'pending') {
|
||||
content = <PostSkeleton />;
|
||||
} else if (page.channel.suspended) {
|
||||
content = <ChannelUnavailable context="post" />;
|
||||
} else if (page.status === 'ok') {
|
||||
const { channel, post, now } = page;
|
||||
content = (
|
||||
<>
|
||||
<PostChannelBar
|
||||
channel={channel}
|
||||
layout="mobile"
|
||||
verifiedLabel={t('header.verified')}
|
||||
actions={
|
||||
<PartBoundary name="post-channel-actions">
|
||||
<ChannelActions
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="mobile"
|
||||
saleOpen={channel.saleOpen}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
/>
|
||||
<FlexBox direction="flex-col" className="p-4">
|
||||
<PostView
|
||||
post={post}
|
||||
username={channel.username}
|
||||
displayName={channel.displayName}
|
||||
avatarUrl={channel.avatarUrl}
|
||||
now={now}
|
||||
layout="mobile"
|
||||
/>
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
content = (
|
||||
<FlexBox direction="flex-col" className="flex-1 bg-surface px-4">
|
||||
<PostMissing username={username} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar
|
||||
title={t('top-bar.post')}
|
||||
previewTitle={i18n.t('content:preview.title')}
|
||||
parentHref={ROUTES.channel(channel.username)}
|
||||
parentHref={ROUTES.channel(username)}
|
||||
backToPrevious
|
||||
/>
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
{channel.suspended ? (
|
||||
<ChannelUnavailable context="post" />
|
||||
) : post ? (
|
||||
<>
|
||||
<PostChannelBar
|
||||
channel={channel}
|
||||
layout="mobile"
|
||||
verifiedLabel={t('header.verified')}
|
||||
actions={
|
||||
<PartBoundary name="post-channel-actions">
|
||||
<ChannelActions
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
channelUrl={channelUrl}
|
||||
layout="mobile"
|
||||
saleOpen={channel.saleOpen}
|
||||
/>
|
||||
</PartBoundary>
|
||||
}
|
||||
/>
|
||||
<FlexBox direction="flex-col" className="p-4">
|
||||
<PostView
|
||||
post={post}
|
||||
username={channel.username}
|
||||
displayName={channel.displayName}
|
||||
avatarUrl={channel.avatarUrl}
|
||||
now={now}
|
||||
layout="mobile"
|
||||
/>
|
||||
</FlexBox>
|
||||
</>
|
||||
) : (
|
||||
<FlexBox direction="flex-col" className="flex-1 bg-surface px-4">
|
||||
<PostMissing username={channel.username} />
|
||||
</FlexBox>
|
||||
)}
|
||||
{content}
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
export { PostSkeleton } from './PostSkeleton';
|
||||
export { PostTemplate } from './PostTemplate';
|
||||
export type { PostTemplateProps } from './types';
|
||||
export type { PostSkeletonProps, PostTemplateProps } from './types';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
import type { PostPayload } from '@lumina/market/features/post';
|
||||
|
||||
export type PostTemplateProps = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** `null`: deleted, unknown, or another channel's. */
|
||||
post: PostPayload | null;
|
||||
/** The channel's username as the API stores it (lower case). */
|
||||
username: string;
|
||||
/** `null`: the address can't name a post, so the post is missing. */
|
||||
postId: string | null;
|
||||
/** «lumina.ir/channels/sara_gold», for the guest's login prompt. */
|
||||
channelUrl: string;
|
||||
/** The render's time: the post's time counts from it. */
|
||||
now: string;
|
||||
/** «lumina.ir», for the channel's not-found state. */
|
||||
siteHost: string;
|
||||
};
|
||||
|
||||
export type PostSkeletonProps = {
|
||||
/** The route's loading: shown only when the wait is long enough to notice. */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import {
|
||||
ChannelNotFound,
|
||||
ChannelNotFoundTopBar,
|
||||
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
|
||||
import type { ChannelMissingProps } from './types';
|
||||
|
||||
/**
|
||||
* No channel at this address, or not any more. Its creator, before approval, sees their own tab
|
||||
* here instead (C6 ۱.۲), under their tab bar; both are decided in the browser. The main is flush
|
||||
* for that tab's banner strip and header; the message keeps its own inset.
|
||||
*/
|
||||
export function ChannelMissing({ title, siteHost }: ChannelMissingProps) {
|
||||
return (
|
||||
<>
|
||||
<ChannelNotFoundTopBar title={title} />
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<ChannelNotFound layout="mobile" siteHost={siteHost} />
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import type { ChannelSkeletonProps } from './types';
|
||||
|
||||
/**
|
||||
* The channel before it arrives, in its reading order, under the real top bar: the header, the
|
||||
* track record, then a post. The route's loading and the page's own wait share it.
|
||||
*/
|
||||
export function ChannelSkeleton({ delayed }: ChannelSkeletonProps) {
|
||||
const { t } = useTranslation('channel');
|
||||
return (
|
||||
<>
|
||||
{/* The skeleton draws the header's flush band itself. */}
|
||||
<SkeletonPreset preset="header" delayed={delayed} label={t('loading')} />
|
||||
<FlexBox direction="flex-col" gap="gap-4" className="p-4">
|
||||
<SkeletonPreset
|
||||
preset="stats"
|
||||
delayed={delayed}
|
||||
label={t('stats.loading')}
|
||||
/>
|
||||
<SkeletonPreset
|
||||
preset="post-media"
|
||||
delayed={delayed}
|
||||
label={t('feed.loading')}
|
||||
/>
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,36 +1,67 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
||||
import { ApprovedWelcome } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/approved-welcome';
|
||||
import { ChannelActions } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-actions';
|
||||
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
|
||||
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed';
|
||||
import {
|
||||
ChannelHeader,
|
||||
channelHeaderLabels,
|
||||
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header';
|
||||
import { PendingChannelGate } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
|
||||
import { ChannelShare } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-share';
|
||||
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats/server';
|
||||
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats';
|
||||
import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-unavailable';
|
||||
import { FollowNotice } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/follow-notice';
|
||||
import { useChannelPage } from '@lumina/market/features/channel';
|
||||
import { creatorStatsLabels } from '@lumina/market/shared/labels';
|
||||
import { Suspense } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { i18n } from '../../../../../../i18n';
|
||||
import { ChannelMissing } from './ChannelMissing';
|
||||
import { ChannelSkeleton } from './ChannelSkeleton';
|
||||
import type { ChannelTemplateProps } from './types';
|
||||
|
||||
/**
|
||||
* The channel on mobile: a page pushed from خانه (the creator's own کانال tab). The header renders
|
||||
* at once; the first follow's notice and the track record open the padded column, then the feed,
|
||||
* streaming in reading order, each in its own boundary, and the action area loads in the browser.
|
||||
* The channel on mobile: a page pushed from خانه (the creator's own کانال tab). It renders in the
|
||||
* browser only (0070): the server sends the top bar and the skeleton, which stay until the
|
||||
* channel arrives. Then the header renders at once; the first follow's notice and the track
|
||||
* record open the padded column, then the feed, each loading in its own boundary, and the action
|
||||
* area waits for the viewer.
|
||||
*/
|
||||
export function ChannelTemplate({
|
||||
channel,
|
||||
username,
|
||||
channelUrl,
|
||||
now,
|
||||
siteHost,
|
||||
}: ChannelTemplateProps) {
|
||||
const t = i18n.getFixedT(null, 'channel');
|
||||
const { t, i18n } = useTranslation('channel');
|
||||
const page = useChannelPage(username);
|
||||
|
||||
if (page.status === 'not-found') {
|
||||
return <ChannelMissing title={t('top-bar.channel')} siteHost={siteHost} />;
|
||||
}
|
||||
|
||||
const channel = page.status === 'ok' ? page.channel : null;
|
||||
const topBar = (
|
||||
<MobileTopBar
|
||||
title={t('top-bar.channel')}
|
||||
tabOwnerId={channel?.creatorId}
|
||||
/>
|
||||
);
|
||||
|
||||
if (!channel) {
|
||||
return (
|
||||
<>
|
||||
{topBar}
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<ChannelSkeleton />
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// Suspension outranks everything: no header, posts or actions, for anyone (U6 ۱.۳). Its creator
|
||||
// sees their suspended tab under their tab bar (C6 ۱.۳); the browser decides. The main is flush
|
||||
|
|
@ -38,10 +69,7 @@ export function ChannelTemplate({
|
|||
if (channel.suspended) {
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar
|
||||
title={t('top-bar.channel')}
|
||||
tabOwnerId={channel.creatorId}
|
||||
/>
|
||||
{topBar}
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
<ChannelUnavailable
|
||||
context="channel"
|
||||
|
|
@ -116,7 +144,7 @@ export function ChannelTemplate({
|
|||
/>
|
||||
}
|
||||
>
|
||||
<ChannelFeed channel={channel} now={now} layout="mobile" />
|
||||
<ChannelFeed channel={channel} layout="mobile" />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
|
|
@ -125,10 +153,7 @@ export function ChannelTemplate({
|
|||
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar
|
||||
title={t('top-bar.channel')}
|
||||
tabOwnerId={channel.creatorId}
|
||||
/>
|
||||
{topBar}
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1">
|
||||
{channel.verificationPending ? (
|
||||
<PendingChannelGate layout="mobile" channelUrl={channelUrl}>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,8 @@
|
|||
export { ChannelMissing } from './ChannelMissing';
|
||||
export { ChannelSkeleton } from './ChannelSkeleton';
|
||||
export { ChannelTemplate } from './ChannelTemplate';
|
||||
export type { ChannelTemplateProps } from './types';
|
||||
export type {
|
||||
ChannelMissingProps,
|
||||
ChannelSkeletonProps,
|
||||
ChannelTemplateProps,
|
||||
} from './types';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,19 @@
|
|||
import type { PublicCreatorPayload } from '@lumina/market/features/channel';
|
||||
|
||||
export type ChannelTemplateProps = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** The username as the API stores it (lower case). */
|
||||
username: string;
|
||||
/** «lumina.ir/channels/sara_gold». */
|
||||
channelUrl: string;
|
||||
/** The render's time: the posts' relative times count from it. */
|
||||
now: string;
|
||||
/** «lumina.ir», for the not-found state. */
|
||||
siteHost: string;
|
||||
};
|
||||
|
||||
export type ChannelSkeletonProps = {
|
||||
/** The route's loading: shown only when the wait is long enough to notice. */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
||||
export type ChannelMissingProps = {
|
||||
/** The top bar's title: «کانال». */
|
||||
title: string;
|
||||
siteHost: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# 0021 A channel's feed starts from the server's first page as initial data
|
||||
|
||||
Status: Proposed · Area: architecture · Date: 2026-10-07 · Decided by: agent
|
||||
Status: Superseded by 0070 · Area: architecture · Date: 2026-10-07 · Decided by: agent
|
||||
|
||||
## Context
|
||||
The channel feed and the post page must be in the server HTML for search and first paint, stay live in the browser (older pages, edits, deletes, a subscriber's unlocked posts), and the platform can't reach the app's per-request `getQueryClient()` to prefetch and dehydrate.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# 0045 The channel's server read carries the public follower count
|
||||
|
||||
Status: Proposed · Area: architecture · Date: 2026-10-09 · Decided by: agent
|
||||
Status: Superseded by 0070 · Area: architecture · Date: 2026-10-09 · Decided by: agent
|
||||
|
||||
## Context
|
||||
The new channel header shows the follower count to everyone and «مشترک فعال» only to the owner (R15).
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# 0055 Static `metadata` everywhere but the channel and post pages
|
||||
|
||||
Status: Accepted · Area: architecture · Date: 2026-10-09 · Decided by: user
|
||||
Status: Superseded by 0070 · Area: architecture · Date: 2026-10-09 · Decided by: user
|
||||
|
||||
## Context
|
||||
Adapted from kasra-pay's decision 0036. Under blocking metadata (0054), any data a `generateMetadata` awaits delays the page's first byte. Almost every Lumina route's title and description is fixed copy from i18next. The channel (`/@username`) and post (`/@username/posts/[id]`) pages are the exception: search results and shared-link previews need the channel's and post's name, image and noindex state.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
# 0070 Render every page except the landing in the browser
|
||||
|
||||
Status: Accepted · Area: architecture · Date: 2026-10-21 · Decided by: user · Supersedes: 0021, 0045, 0055
|
||||
|
||||
## Context
|
||||
|
||||
A creator can announce a post for a set time, and tens of thousands of visitors may open the same channel or post at once. Each server render of a channel cost five back-end reads, a post four. The user wants the Next.js servers free of that pressure, and accepts losing search results and rich link previews for channels and posts.
|
||||
|
||||
## Decision
|
||||
|
||||
- The landing (`/`) is the only page whose content the server renders, all of it in the first flush, with no `loading.tsx`.
|
||||
- Every other page renders its content in the browser, for guests and members alike. The server reads no back-end data: it sends the frame, a same-size skeleton, and the metadata. This now includes `/channels/[username]`, `/channels/[username]/posts/[id]`, `/checkout/[username]` and `/analysts`.
|
||||
- Channel and post pages are `noindex` and keep a `loading.tsx`. Their `generateMetadata` reads only the URL's params; every other page exports static `metadata`.
|
||||
- The server still checks a URL's shape without reading data: a username in another spelling answers 308, a malformed one 404.
|
||||
|
||||
## Alternatives
|
||||
|
||||
- Server-render the channel header and post text from one back-end-cached read (hybrid): keeps link previews and SEO for one cache hit per request. The user chose to keep the server free of reads.
|
||||
- Server metadata only (one read per request) so link previews name the channel: rejected for the same reason.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The back-end load stays: the same reads now come from browsers, with the session's cookies. The back end needs its own cache for public reads before a spike.
|
||||
- Shared channel and post links show the generic site card, and search engines index no channel or post content.
|
||||
- Channel and post content paints later on a first visit: after the JavaScript, then the read.
|
||||
- A missing channel or post answers 200, and its not-found state renders in the browser.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# 0071 Index only the landing
|
||||
|
||||
Status: Accepted · Area: architecture · Date: 2026-10-21 · Decided by: user
|
||||
|
||||
## Context
|
||||
|
||||
After 0070, the landing is the only page whose content the server renders. The user confirmed that no page except the landing needs search engines: channels, posts and the rules pages included.
|
||||
|
||||
## Decision
|
||||
|
||||
- The landing (`/`) is the only indexable page in bull and bear.
|
||||
- Every other page is `noindex`, set in its own or its layout's `metadata`, and has no canonical or JSON-LD. The rules pages (`/terms`, `/terms/subscription`) get it from the `terms` layout.
|
||||
- A new page is `noindex` unless a later decision says otherwise.
|
||||
|
||||
## Alternatives
|
||||
|
||||
- Keep the rules pages indexable: they read no data and render on the server, but the user wants no search presence beyond the landing.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A rendering doc's Index column is `no` for every section outside the landing, and the ready-for-review checks for `primary` and `secondary` rows apply only to the landing.
|
||||
- A sitemap, if one is ever added, lists only `/`.
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
- 0052 Evict the service worker's least recently used entry first, with the key order kept in memory and older-half hits stored again.
|
||||
- 0053 Ship bull and bear with the same worker options and `NEXT_PUBLIC_SERVICE_WORKER_ENABLED`; both serve the manifest from `platforms/market/src/app/manifest`.
|
||||
- 0054 Set `htmlLimitedBots: /.*/` in both apps' `next.config.ts`, so every visitor gets metadata in `<head>`.
|
||||
- 0055 Export static `metadata` from every layout and page; only the channel and post pages use `generateMetadata`, through the page's cached read.
|
||||
- 0057 Back links to `parentHref` and traverses history only when that is the previous entry; `backToPrevious` pages (and pages without `parentHref`) accept any previous page.
|
||||
- 0058 Opening notifications records "seen" and clears the bell; a row stays unread until tapped; creators filter one list by «همه · پیشبینیها · مالی · حساب».
|
||||
- 0059 Checkout and the channel save `?code=` into the per-creator checkout draft on arrival; checkout then strips it from the URL.
|
||||
|
|
@ -28,6 +27,8 @@
|
|||
- 0066 Give every app `INTERNAL_END_POINT` (server calls) and `NEXT_PUBLIC_CLIENT_END_POINT` (the API's public origin, called directly by the browser with credentials), both set in the bootstraps; no `next.config.ts` rewrite.
|
||||
- 0067 Run each app as one container publishing `HTTP_PORT`, with no per-app nginx; `tools/deploy.sh` checks the new release's `/healthz` off to the side, then replaces the old release.
|
||||
- 0068 Keep the previous release as a stopped `<app>-<UTC time>` container with its env folder; `tools/rollback.sh <app>` starts it in place of the serving one.
|
||||
- 0070 Render every page except the landing in the browser: the server reads no data and sends the frame, a skeleton and metadata; channel and post are `noindex`, their metadata from params only.
|
||||
- 0071 Index only the landing in bull and bear; every other page is `noindex` with no canonical or JSON-LD, new pages included.
|
||||
|
||||
## Proposed
|
||||
|
||||
|
|
@ -39,7 +40,6 @@
|
|||
- 0016 architecture: Keep a creator who hasn't finished step 5 out of publishing and pricing through the session's `needsProfile`, with `OnboardingGuard` in those routes' layouts and `GuestGuard`.
|
||||
- 0017 architecture: Give every auth and onboarding route its own `loading.tsx` matching its frame; an index route with nested steps sits in its own route group.
|
||||
- 0020 architecture: Server-rendered platform organisms take their text as `labels` built by the app's template from its server i18n; client organisms use `useTranslation`.
|
||||
- 0021 architecture: A channel's feed and post page start from the server's read as query `initialData`, re-read in the browser for the creator or a subscriber, and update in place after mutations.
|
||||
- 0022 architecture: The API enforces post rules (2000 characters, four JPG/PNG/WebP images of 5 MB, 15-minute edit window, approved creators only); the composer mirrors them in `POST_LIMITS`.
|
||||
- 0023 architecture: On desktop «پست جدید», post edit and «پیشبینی جدید» are dialogs over the page through bear's `@modal` intercepts; slots are emptied by explicit null pages, never a catch-all, and a hard load gets the full page.
|
||||
- 0025 architecture: The investor's داشبورد is a tabbed section, one route per tab in `dashboard/(investor)`, whose layout holds the top bar or heading and `DashboardTabs`; each tab has its own loading.
|
||||
|
|
@ -57,7 +57,6 @@
|
|||
- 0041 architecture: Confirm sign-out, call `auth.logout`, then reload to the landing.
|
||||
- 0042 architecture: When a session ends mid-use, show the session-ended state and keep drafts; only an explicit sign-out clears drafts and `session.*` keys.
|
||||
- 0043 architecture: Freeze every network action offline with island `useOfflineFreeze`, showing the reason.
|
||||
- 0045 architecture: The channel's server read carries the public follower count; the browser keeps it live and shows «مشترک فعال» only to the owner.
|
||||
- 0046 architecture: Serve `/account/profile` in `(flow)` for both roles, switching investor form and creator profile edit in the browser.
|
||||
- 0047 architecture: The pwa lib keeps the browser's install offer; offer install at `/account/install` and once on bull's خانه with a 30-day snooze; the manifest starts at `/feed`.
|
||||
- 0049 design: A page error keeps the page's own bar, derived from the path; route groups without a frame pass `standalone`.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ bull (mobile) and bear (desktop) share one doc per route under `market/`, with b
|
|||
|
||||
## market
|
||||
|
||||
Only `/` is indexable (0071), and it is the only page whose content the server renders (0070). Every other page is `noindex`; all but the rules pages render their content in the browser.
|
||||
|
||||
Layouts and error pages:
|
||||
|
||||
- root layout · [layout.md](market/layout.md) · — · — · browser: NetworkStatus, Toaster, ToastPlacementMarker (bear)
|
||||
|
|
@ -15,19 +17,19 @@ Layouts and error pages:
|
|||
- `(main)/dashboard/(investor)` layout · [layout-dashboard-investor.md](market/layout-dashboard-investor.md) · — · — · browser: notification bell and account avatar (bull)
|
||||
- not-found and error · [not-found.md](market/not-found.md) · noindex · none · browser: not-found top bar, every group `error.tsx`, `global-error.tsx`
|
||||
|
||||
Indexable:
|
||||
Rendered on the server:
|
||||
|
||||
- `/` · [home.md](market/home.md) · index · FAQPage · browser: LandingRedirect
|
||||
- `/channels/[username]` · [channels-username.md](market/channels-username.md) · index; noindex when invalid, missing or suspended · none · browser: MobileTopBar (bull), ApprovedWelcome, ChannelActions, FollowNotice, locked post gate, Load more, PostLightbox
|
||||
- `/channels/[username]/posts/[id]` · [channels-username-posts-id.md](market/channels-username-posts-id.md) · index; noindex when the post is missing, belongs to another channel, or the channel is suspended · none · browser: MobileTopBar (bull), ChannelActions, locked post gate, PreviewBanner, PostLightbox, access-ended toast
|
||||
- `/terms` · [terms.md](market/terms.md) · index · none · browser: none
|
||||
- `/terms/subscription` · [terms-subscription.md](market/terms-subscription.md) · index · none · browser: none
|
||||
- `/terms` · [terms.md](market/terms.md) · noindex · none · browser: none
|
||||
- `/terms/subscription` · [terms-subscription.md](market/terms-subscription.md) · noindex · none · browser: none
|
||||
|
||||
`(main)`:
|
||||
|
||||
- `/channels/[username]` · [channels-username.md](market/channels-username.md) · noindex · none · browser: every section (header, counts, actions, stats, feed, ChannelMissing, ChannelUnavailable), ApprovedWelcome, FollowNotice, Load more, PostLightbox
|
||||
- `/channels/[username]/posts/[id]` · [channels-username-posts-id.md](market/channels-username-posts-id.md) · noindex · none · browser: every section (PostChannelBar, ChannelActions, PostView, PostMissing, ChannelMissing, ChannelUnavailable), PreviewBanner, PostLightbox, access-ended toast
|
||||
- `/feed` · [feed.md](market/feed.md) · noindex · none · browser: top-bar bell/avatar/login, HomeGuard, HomeFeed (featured row, post cards, empty state), PostLightbox, InstallPrompt (bull)
|
||||
- `/search` · [search.md](market/search.md) · noindex · none · browser: top-bar bell/avatar/login, SearchPanel (field, recent searches, featured, results)
|
||||
- `/analysts` · [analysts.md](market/analysts.md) · noindex · none · browser: top-bar title/brand/login, AnalystFollowButton, GuestSignupCard
|
||||
- `/analysts` · [analysts.md](market/analysts.md) · noindex · none · browser: top-bar title/brand/login, AnalystsDirectory (heading, note, AnalystList), AnalystFollowButton, GuestSignupCard
|
||||
- `/notifications` · [notifications.md](market/notifications.md) · noindex · none · browser: top-bar title/login, NotificationCentre (filter chips, rows)
|
||||
- `/account` · [account.md](market/account.md) · noindex · none · browser: top-bar title/login, AccountOverview (identity, lists, sign-out), SupportDialog, SignOutConfirm
|
||||
- `/account/install` · [account-install.md](market/account-install.md) · noindex · none · browser: top-bar title/login, InstallApp
|
||||
|
|
@ -43,7 +45,7 @@ Indexable:
|
|||
`(flow)`:
|
||||
|
||||
- `/account/profile` · [account-profile.md](market/account-profile.md) · noindex · none · browser: AccountProfile (investor form or creator profile edit), LeaveDialog
|
||||
- `/checkout/[username]` · [checkout-username.md](market/checkout-username.md) · noindex · none · browser: CheckoutPanel, CheckoutForm (tiers, code, pay footer), CheckoutHalts, NoCodeSheet
|
||||
- `/checkout/[username]` · [checkout-username.md](market/checkout-username.md) · noindex · none · browser: CheckoutCreator, CheckoutPanel, CheckoutForm (tiers, code, pay footer), CheckoutHalts, NoCodeSheet
|
||||
- `/compose/post` · [compose-post.md](market/compose-post.md) · noindex · none · browser: PostComposer, ComposerForm, LeaveConfirm, PostComposerDialog (bear `@modal`)
|
||||
- `/compose/post/[id]` · [compose-post-id.md](market/compose-post-id.md) · noindex · none · browser: PostComposer, EditComposer, LeaveConfirm, PostComposerDialog (bear `@modal`)
|
||||
- `/compose/prediction` · [compose-prediction.md](market/compose-prediction.md) · noindex · none · browser: PredictionComposer, ComposerPage, SymbolPicker, ConfirmPublish, LeaveConfirm, PredictionComposerDialog (bear `@modal`)
|
||||
|
|
|
|||
|
|
@ -2,31 +2,31 @@
|
|||
|
||||
`/analysts` · `apps/{bull,bear}/src/app/(main)/analysts/page.tsx` · Type: category and brand listing · Layout: [layout-main.md](layout-main.md), [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200`; a failed read shows `(main)/error.tsx` with 200; a 404 or 403 read shows the empty state |
|
||||
| loading.tsx | `(main)/analysts/loading.tsx`: the frame and three analyst cards |
|
||||
| First flush | none: the page entry awaits `getFeaturedCreators()` through `readOnServer`, under `loading.tsx`, so the list streams |
|
||||
| Canonical | none |
|
||||
| H1 | `home:analysts.title` in `PageHeader`; bull: inside `AnalystsDirectory`, shown while the viewer is unknown or a guest, and removed for a member, whose top bar names the page |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
| Field | Value |
|
||||
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200`; a failed read throws to `(main)/error.tsx` in the browser; no 404 or 403 case |
|
||||
| loading.tsx | `(main)/analysts/loading.tsx`: the frame and three analyst cards |
|
||||
| First flush | none: the server reads nothing (0070); `useAnalystsPage` reads `featuredCreatorsQuery()` in the browser, shared with خانه's featured row, and the directory shows `AnalystListSkeleton` (not delayed) until it arrives |
|
||||
| Canonical | none |
|
||||
| H1 | `home:analysts.title` in `PageHeader`; bull: inside `AnalystsDirectory`, shown while the viewer is unknown or a guest, and removed for a member, whose top bar names the page |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
|
||||
## Sections
|
||||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ----------------------------------- | ----------------------- | ----------- | ------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | config | first flush | hydrate | no | a pushed page's bar: back and support |
|
||||
| ↳ Title, brand or login link (bull) | viewer | skeleton | hydrate | no | member: the title; guest: the brand and «ورود/ثبتنام» |
|
||||
| DeskBack, PageHeader (bear) | config | first flush | hydrate | no | «بازگشت» to خانه, or to the landing for a guest |
|
||||
| AnalystsDirectory heading and note | `getFeaturedCreators()` | streamed | hydrate | no | bull's H1 and the «chosen by Lumina, not a ranking» note |
|
||||
| AnalystList | `getFeaturedCreators()` | streamed | hydrate | no | every featured analyst in the admin's order, each card an `<a href>` to `/channels/username`; bull: one column; bear: three; empty: an `EmptyState` card |
|
||||
| ↳ AnalystFollowButton | viewer | none | hydrate | no | investors only, once their follows are known; unfollow asks first |
|
||||
| GuestSignupCard | viewer | none | hydrate | no | guests only: register and login links |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ----------------------------------- | ------------------------- | ----------- | ------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | config | first flush | hydrate | no | a pushed page's bar: back and support |
|
||||
| ↳ Title, brand or login link (bull) | viewer | skeleton | hydrate | no | member: the title; guest: the brand and «ورود/ثبتنام» |
|
||||
| DeskBack, PageHeader (bear) | config | first flush | hydrate | no | «بازگشت» to خانه, or to the landing for a guest |
|
||||
| AnalystsDirectory heading and note | `featuredCreatorsQuery()` | skeleton | hydrate | no | bull's H1 and the «chosen by Lumina, not a ranking» note |
|
||||
| AnalystList | `featuredCreatorsQuery()` | skeleton | hydrate | no | every featured analyst in the admin's order, each card an `<a href>` to `/channels/username`; bull: one column; bear: three; empty: an `EmptyState` card |
|
||||
| ↳ AnalystFollowButton | viewer | none | hydrate | no | investors only, once their follows are known; unfollow asks first |
|
||||
| GuestSignupCard | viewer | none | hydrate | no | guests only: register and login links |
|
||||
|
||||
## Notes
|
||||
|
||||
- The page is `noindex`, but its channel links are server HTML, so crawlers that fetch it can follow them to the indexable channel pages.
|
||||
- The channel links render in the browser, and the channel pages are `noindex` too (0070): this page is no crawl path.
|
||||
|
|
|
|||
|
|
@ -2,39 +2,39 @@
|
|||
|
||||
`/channels/[username]/posts/[id]` · `apps/{bull,bear}/src/app/(main)/channels/[username]/posts/[id]/page.tsx` · Type: blog article · Layout: [layout-main.md](layout-main.md), [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `index; noindex when` the post is missing, belongs to another channel, or the channel is suspended (`generateMetadata`) |
|
||||
| Status | `200`; `308` when the username segment isn't the stored spelling (`ROUTES.post`), and from `/@username/…` (0064); `200` with `not-found.tsx` when the username is invalid or the channel is missing, because `loading.tsx` wraps the page; `200` with `noindex` and `PostMissing` when the post is missing (debt) |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(main)/channels/[username]/posts/[id]/loading.tsx` (debt, Notes) |
|
||||
| First flush | `getChannel(username)` and `getPost(id)` in one `Promise.all` through `readOnServer`, which the page entry and `generateMetadata` await (0055) |
|
||||
| Canonical | `/channels/username/posts/id`, from `postMetadata`; drops `?preview=` |
|
||||
| H1 | none (debt) |
|
||||
| JSON-LD | none (debt, Notes) |
|
||||
| Scripts | none |
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (`generateMetadata`, from the URL's params only: title `پست @username`; no read, 0070) |
|
||||
| Status | `200`; another spelling of the username redirects in the stream (meta refresh) to `ROUTES.post`, because `loading.tsx` wraps the page; `/@username/…` answers a real 308 (0064); a username that can't be one renders the channel's `not-found.tsx` (`ChannelMissing`), 200; an id that can't be a post's, or a missing post, renders `PostMissing` in the channel's frame, 200 |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(main)/channels/[username]/posts/[id]/loading.tsx`: bull: `MobileTopBar` and `PostSkeleton delayed`; bear: `DeskBack` and `PostSkeleton delayed`. The page shows the same `PostSkeleton` (not delayed) until its reads arrive |
|
||||
| First flush | none: the server reads nothing (0070); `usePostPage` reads `channelPageQuery(username)` and `postKeys.detail(id)` in the browser |
|
||||
| Canonical | none |
|
||||
| H1 | none (debt) |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none |
|
||||
|
||||
## Sections
|
||||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------- | ---------------------- | ----------- | ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | back to the channel (`parentHref`, `backToPrevious`, 0057); the title waits for the viewer |
|
||||
| DeskBack (bear) | — | first flush | hydrate | no | «بازگشت» to the channel |
|
||||
| PostChannelBar | `getChannel(username)` | first flush | none | primary | `<a href>` to the channel: avatar, name, `@username` |
|
||||
| ↳ ChannelActions | viewer | skeleton | hydrate | no | follow and subscribe; own `PartBoundary` |
|
||||
| PostView | `getPost(id)` | first flush | hydrate | primary | a free post's caption and images; a premium post's `captionPreview` and media count only; re-read in the browser for the creator or a subscriber (0021) |
|
||||
| ↳ Locked post gate | viewer | skeleton | hydrate | no | guest: login back here; investor: checkout |
|
||||
| ↳ PreviewBanner | viewer | none | hydrate | no | the creator's `?preview=` of their own premium post |
|
||||
| ↳ PostLightbox | — | none | interaction | no | `next/dynamic`, mounted on the first image tap |
|
||||
| ↳ Access-ended toast | viewer | none | hydrate | no | the info toast when access ends mid-read (0050) |
|
||||
| PostMissing | `getChannel(username)` | first flush | hydrate | no | instead of `PostView` when the post is missing; a link back to the channel |
|
||||
| ChannelUnavailable | `getChannel(username)` | first flush | hydrate | no | replaces the bar and post when the channel is suspended |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------- | ---------------------------- | -------- | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | back to the channel (`parentHref` from the URL, `backToPrevious`, 0057); the title waits for the viewer |
|
||||
| DeskBack (bear) | — | streamed | hydrate | no | «بازگشت» to the channel, drawn while the reads load |
|
||||
| PostChannelBar | `channelPageQuery(username)` | skeleton | hydrate | no | `<a href>` to the channel: avatar, name, `@username` |
|
||||
| ↳ ChannelActions | viewer | skeleton | hydrate | no | follow and subscribe; own `PartBoundary` |
|
||||
| PostView | `postKeys.detail(id)` | skeleton | hydrate | no | read with the session, so a subscriber's or the creator's premium post arrives open; read again if the session was restored after it |
|
||||
| ↳ Locked post gate | viewer | skeleton | hydrate | no | guest: login back here; investor: checkout |
|
||||
| ↳ PreviewBanner | viewer | none | hydrate | no | the creator's `?preview=` of their own premium post |
|
||||
| ↳ PostLightbox | — | none | interaction | no | `next/dynamic`, mounted on the first image tap |
|
||||
| ↳ Access-ended toast | viewer | none | hydrate | no | the info toast when access ends mid-read (0050) |
|
||||
| PostMissing | `postKeys.detail(id)` | none | hydrate | no | instead of `PostView` when the post is missing, another channel's, or the id can't be a post's; a link back to the channel |
|
||||
| ChannelMissing | `channelPageQuery(username)` | none | hydrate | no | the channel is unknown |
|
||||
| ChannelUnavailable | `channelPageQuery(username)` | none | hydrate | no | replaces the bar and post when the channel is suspended |
|
||||
|
||||
## Notes
|
||||
|
||||
- bull: under `MobileTopBar`, a padded column; bear: the 640px column under «بازگشت». Both hold the same primary rows.
|
||||
- Debt: `loading.tsx` wraps an indexable entity page: a missing channel answers 200, and past 12,800 bytes the post follows the skeleton. Delete it.
|
||||
- Debt: a missing post answers 200 with `PostMissing` (`PostTemplate.tsx:67`), a soft 404. Call `notFound()` in the page entry and move `PostMissing` into a route `not-found.tsx`.
|
||||
- Debt: no H1. Make the post's first line, the text `postMetadata` titles it with, the H1 in both apps.
|
||||
- Debt: no JSON-LD; an article-type page gets `BreadcrumbList`. The repo has no json-ld lib yet.
|
||||
- bull: under `MobileTopBar`, a padded column; bear: the 640px column under «بازگشت».
|
||||
- A 404 on the post read is the `missing` state, not a boundary; any other failed first read throws to `(main)/error.tsx`. A deleted post's page renders again with `router.refresh()` and reads the post afresh.
|
||||
- 0070's accepted cost: search engines get no post content, and a shared link shows the site card with the `پست @username` title.
|
||||
- Debt: no H1 in either app. Make the post's first line the H1.
|
||||
|
|
|
|||
|
|
@ -2,44 +2,43 @@
|
|||
|
||||
`/channels/[username]` · `apps/{bull,bear}/src/app/(main)/channels/[username]/page.tsx` · Type: seller · Layout: [layout-main.md](layout-main.md), [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Robots | `index; noindex when` the username is invalid, the channel is missing, or it is suspended (`generateMetadata`; `not-found.tsx` `metadata`) |
|
||||
| Status | `200`; `308` when the segment isn't the stored spelling (`toChannelUsername`), keeping the query for `?code=` (0059), and from `/@username/…` (`next.config.ts` redirect, 0064); `200` with `not-found.tsx` and `noindex` when invalid or missing, because `loading.tsx` wraps the page (debt); `200` with `noindex` and `ChannelUnavailable` when suspended |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(main)/channels/[username]/loading.tsx` (debt, Notes) |
|
||||
| First flush | `getChannel(username)` through `readOnServer`, which the page entry and `generateMetadata` await (0055) |
|
||||
| Canonical | `/channels/username`, from `channelMetadata`; drops `?code=` and every other parameter |
|
||||
| H1 | the display name, in `ChannelHeader` |
|
||||
| JSON-LD | none (debt, Notes) |
|
||||
| Scripts | none |
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Robots | `noindex` (`generateMetadata`, from the URL's params only: title `@username`, description `channel:meta.description`; no read, 0070) |
|
||||
| Status | `200`; another spelling of the username redirects in the stream (meta refresh) to the stored one, keeping `?code=` (0059), because `loading.tsx` wraps the page; `/@username/…` answers a real 308 from `next.config.ts` (0064); a username that can't be one renders `not-found.tsx` (`ChannelMissing`), 200; an unknown channel renders `ChannelMissing` in the browser, 200 |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(main)/channels/[username]/loading.tsx`: bull: `MobileTopBar` and `ChannelSkeleton delayed`; bear: `DeskBack` and `ChannelSkeleton delayed`. The page shows the same `ChannelSkeleton` (not delayed) until its read arrives |
|
||||
| First flush | none: the server reads nothing (0070); `channelPageQuery(username)` runs in the browser |
|
||||
| Canonical | none |
|
||||
| H1 | the display name, in `ChannelHeader`, rendered in the browser |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none |
|
||||
|
||||
## Sections
|
||||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------------- | ------------------------------- | ----------- | ----------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | `tabOwnerId`: back and title wait for the viewer; the creator on their own channel gets the tab bar |
|
||||
| ChannelDeskBack (bear) | viewer | first flush | hydrate | no | «بازگشت»; removed for the owner |
|
||||
| ApprovedWelcome | viewer | none | hydrate | no | once, on the creator's first visit after approval; bull: sheet; bear: modal |
|
||||
| ChannelHeader, with the H1 | `getChannel(username)` | first flush | none | primary | avatar, name, `@username`, bio, markets, social links; bear: in a card |
|
||||
| ↳ ChannelShare | — | first flush | hydrate | no | the owner's share sheet opens on click |
|
||||
| ↳ ChannelCounts | `getChannel(username)`, query | first flush | hydrate | no | follower count from the server read as `initialData`, kept live (0045); the owner's «مشترک فعال» is browser-only |
|
||||
| ↳ ChannelActions | viewer | skeleton | hydrate | no | guest prompt, follow, subscribe, sale and invite notes; own `PartBoundary` |
|
||||
| FollowNotice | viewer | none | hydrate | no | after the first follow |
|
||||
| ChannelStats | `getPredictionStats(creatorId)` | streamed | none | secondary | own `<Suspense>` and `PartBoundary`; `CreatorStats`, empty when the record isn't public |
|
||||
| ChannelFeed | `getCreatorPosts(creatorId)` | streamed | hydrate | primary | own `<Suspense>` and `PartBoundary`; an `<a href>` per post, the only links to post pages; re-read in the browser for the creator or a subscriber (0021) |
|
||||
| ↳ Locked post gate | viewer | skeleton | hydrate | no | guest: login back here; investor: checkout |
|
||||
| ↳ Load more | query | none | hydrate | no | a `<button>` that reads the next page |
|
||||
| ↳ PostLightbox | — | none | interaction | no | `next/dynamic`, mounted on the first image tap |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------------- | --------------------------------- | -------- | ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | `tabOwnerId` once the channel is known: the creator on their own channel gets the tab bar |
|
||||
| ChannelDeskBack (bear) | viewer | streamed | hydrate | no | «بازگشت», drawn while the channel loads; removed for the owner |
|
||||
| ApprovedWelcome | viewer | none | hydrate | no | once, on the creator's first visit after approval; bull: sheet; bear: modal |
|
||||
| ChannelHeader, with the H1 | `channelPageQuery(username)` | skeleton | hydrate | no | avatar, name, `@username`, bio, markets, social links; bear: in a card |
|
||||
| ↳ ChannelShare | — | skeleton | hydrate | no | the owner's share sheet opens on click |
|
||||
| ↳ ChannelCounts | `channelPageQuery`, query | skeleton | hydrate | no | the follower count read with the channel, kept live in `channelKeys.followerCount`; the owner's «مشترک فعال» |
|
||||
| ↳ ChannelActions | viewer | skeleton | hydrate | no | guest prompt, follow, subscribe, sale and invite notes; own `PartBoundary` |
|
||||
| FollowNotice | viewer | none | hydrate | no | after the first follow |
|
||||
| ChannelStats | `predictionKeys.stats(creatorId)` | skeleton | hydrate | no | `useCreatorStatsPart`, a suspense query in its own `<Suspense>` and `PartBoundary`; empty when the record isn't public |
|
||||
| ChannelFeed | `postKeys.channelFeed(creatorId)` | skeleton | hydrate | no | `useChannelFeedPart`, a suspense infinite query sent with the session, in its own `<Suspense>` and `PartBoundary`; an `<a href>` per post |
|
||||
| ↳ Locked post gate | viewer | skeleton | hydrate | no | guest: login back here; investor: checkout |
|
||||
| ↳ Load more | query | none | hydrate | no | a `<button>` that reads the next page |
|
||||
| ↳ PostLightbox | — | none | interaction | no | `next/dynamic`, mounted on the first image tap |
|
||||
| ChannelMissing | `channelPageQuery(username)` | none | hydrate | no | an unknown channel; its creator before approval sees their own tab (C6 ۱.۲) |
|
||||
| ChannelUnavailable | `channelPageQuery(username)` | none | hydrate | no | replaces everything when the channel is suspended |
|
||||
|
||||
## Notes
|
||||
|
||||
- bull: under `MobileTopBar`, a padded column; bear: one 640px column under «بازگشت», header in a card. Both hold the same primary and secondary rows.
|
||||
- A channel under review (`verificationPending`) is public and indexable, but `PendingChannelGate` renders the header skeleton for every visitor until the viewer is known, so its server HTML holds no primary content.
|
||||
- 0070 supersedes 0021 and 0045: the feed, the stats and the follower count are browser reads, with no server `initialData`. Mutations update them in the query cache (`replaceCachedPost`, `removeCachedPost`, `applyClosedPrediction`).
|
||||
- bull: under `MobileTopBar`, a padded column; bear: one 640px column under «بازگشت», the header in a card.
|
||||
- A channel under review (`verificationPending`) renders behind `PendingChannelGate`, which decides for its owner in the browser.
|
||||
- bear's `@modal/channels/[username]/page.tsx` returns `null`: it empties the `@modal` slot after publishing lands here (0023).
|
||||
- Debt: `loading.tsx` wraps an indexable entity page: a missing channel answers 200, and past 12,800 bytes the content follows the skeleton. Delete it; the channel's links are `NavLink`s.
|
||||
- Debt: `ChannelFeed` is primary but sits in `<Suspense>` (`ChannelTemplate.tsx`: bull line 110, bear line 113). Await `getCreatorPosts` in the page entry beside `getChannel`.
|
||||
- Debt: older posts are reachable only through «Load more» (`ChannelFeedList.tsx:109`). Add `?page=` pagination with `<a href>` links.
|
||||
- Debt: `PendingChannelGate` (`ChannelTemplate.tsx`: bull line 134, bear line 133) keeps a public channel's primary content out of the server HTML. Render the public channel on the server and swap only for the owner, or set `noindex` while pending.
|
||||
- Debt: no JSON-LD; a seller-type page gets `BreadcrumbList`. The repo has no json-ld lib yet.
|
||||
- 0070's accepted cost: search engines get no channel content, and a shared link shows the site card with the `@username` title and description. The back end needs its own cache for these public reads before a traffic spike.
|
||||
|
|
|
|||
|
|
@ -2,34 +2,35 @@
|
|||
|
||||
`/checkout/[username]` · `apps/{bull,bear}/src/app/(flow)/checkout/[username]/page.tsx` · Type: cart and checkout · Layout: [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200`, because `loading.tsx` streams the page: an invalid or unknown username renders the not-found UI in the stream; another spelling of the username redirects in the stream to the stored one, with `?code=` kept (0059), not a 308; a suspended channel redirects in the stream to the channel |
|
||||
| loading.tsx | `checkout/[username]/loading.tsx`: bull: the bar; bear: the header and title; then `CheckoutSkeleton` with `CheckoutCreatorSkeleton`, `delayed` |
|
||||
| First flush | none: the page entry awaits `getChannel(username)` through `readOnServer` under `loading.tsx`, so the page streams behind the skeleton |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | bull: none (the bar's name isn't a heading); bear: `DesktopPageTitle`, `payment:checkout.title` |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
| Field | Value |
|
||||
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200`, because `loading.tsx` wraps the page: an invalid username renders the not-found UI in the stream; another spelling of the username redirects in the stream to the stored one, with `?code=` kept (0059), not a 308; an unknown channel shows `StatusEmptyState` (not-found) in the page; a suspended channel sends the visitor to the channel with `router.replace` in the browser (`useCheckoutChannel`) |
|
||||
| loading.tsx | `checkout/[username]/loading.tsx`: bull: the bar; bear: the header and title; then `CheckoutSkeleton` with `CheckoutCreatorSkeleton`, `delayed` |
|
||||
| First flush | none: the server reads nothing (0070); `useCheckoutChannel` reads `channelPageQuery(username)` in the browser, and the page shows `CheckoutSkeleton` (not delayed) until it arrives |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | bull: none (the bar's name isn't a heading); bear: `DesktopPageTitle`, `payment:checkout.title` |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
|
||||
## Sections
|
||||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------------------------------------- | ---------------------- | -------- | ------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | config | streamed | hydrate | no | back to the channel; no bottom nav |
|
||||
| DesktopHeader (bear) | viewer | streamed | hydrate | no | rows as in [layout-main.md](layout-main.md) |
|
||||
| DesktopPageTitle (bear) | config | streamed | hydrate | no | back to the channel, beside the title |
|
||||
| CheckoutCreator | `getChannel(username)` | streamed | none | no | avatar, name and @username; a Server Component passed into the client panel, so the skeleton shows it too |
|
||||
| CheckoutPanel | viewer | skeleton | hydrate | no | `AuthGuard role="investor"`: a guest goes to login and back, a creator gets no-access; `useInviteLink` keeps `?code=` for this creator on arrival (0059, 0030); its own `PartBoundary` |
|
||||
| ↳ CheckoutForm: tiers, invite note and code, pay footer | query | skeleton | hydrate | no | `useCheckoutPage`'s browser read; the skeleton stays while a payment left at the bank settles (0033); a reactivation shows the start-today note instead of the code (U11) |
|
||||
| ↳ CheckoutHalts | query | none | hydrate | no | dialogs when the investor can't pay here |
|
||||
| ↳ NoCodeSheet | `getChannel(username)` | none | hydrate | no | «کد ندارم»: where to get a code, from the creator's links; mounts when opened |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------------------------------------- | ---------------------------- | -------- | ------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | config | streamed | hydrate | no | back to the channel (`parentHref` from the URL); no bottom nav |
|
||||
| DesktopHeader (bear) | viewer | streamed | hydrate | no | rows as in [layout-main.md](layout-main.md) |
|
||||
| DesktopPageTitle (bear) | config | streamed | hydrate | no | back to the channel, beside the title |
|
||||
| CheckoutCreator | `channelPageQuery(username)` | skeleton | hydrate | no | avatar, name and @username; `CheckoutCreatorSkeleton` inside the page's skeleton until the read arrives |
|
||||
| CheckoutPanel | viewer | skeleton | hydrate | no | `AuthGuard role="investor"`: a guest goes to login and back, a creator gets no-access; `useInviteLink` keeps `?code=` for this creator on arrival (0059, 0030); its own `PartBoundary` |
|
||||
| ↳ CheckoutForm: tiers, invite note and code, pay footer | query | skeleton | hydrate | no | `useCheckoutPage`'s browser read; the skeleton stays while a payment left at the bank settles (0033); a reactivation shows the start-today note instead of the code (U11) |
|
||||
| ↳ CheckoutHalts | query | none | hydrate | no | dialogs when the investor can't pay here |
|
||||
| ↳ NoCodeSheet | `channelPageQuery(username)` | none | hydrate | no | «کد ندارم»: where to get a code, from the creator's links; mounts when opened |
|
||||
|
||||
## Notes
|
||||
|
||||
- bull pins the pay block to the bottom of the screen; bear sticks it to the bottom of the window in a 480 column. Same sections otherwise.
|
||||
- The redirect and not-found cases run after the skeleton is sent, so they never set the status line. That is fine for a `noindex` page reached only from the channel's «اشتراک».
|
||||
- 0070: the page shares `channelPageQuery` with the channel, so a visitor coming from the channel finds it cached.
|
||||
- Debt: different H1 per app. bull has no `h1`; add a screen-reader `h1` to `CheckoutTemplate` in bull (`apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx:19`).
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `index` |
|
||||
| Status | `200`; prerendered with `force-static` and `revalidate = 600` (0026), so a failed revalidation keeps serving the last good page |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(landing)/loading.tsx` (debt, Notes) |
|
||||
| loading.tsx | `none`: the whole landing is in the first flush (0070) |
|
||||
| First flush | `loadLandingPage()` → `getFeaturedCreators()`, awaited by the page entry at build and at each revalidation; the metadata is fixed, in the `metadata` export (`landingMetadata`) |
|
||||
| Canonical | `/`, from `landingMetadata` |
|
||||
| H1 | `landing:hero.title` from i18n, in `LandingHero` |
|
||||
|
|
@ -37,7 +37,7 @@ In bull's document order. The header and footer belong to `LandingTemplate`, not
|
|||
|
||||
## Notes
|
||||
|
||||
- 0070: the landing is the only page whose content the server renders; every other page reads its data in the browser.
|
||||
- bull: `layout="mobile"`; bear: `layout="desktop"`, which adds the header's section links and opens support as a popover. Both apps hold the same primary and secondary sections.
|
||||
- `force-static` contradicts the skill's "never static rendering"; accepted decision 0026 overrides it. The page reads no session, so the prerender is the same for every visitor.
|
||||
- Debt: `apps/{bull,bear}/src/app/(landing)/loading.tsx` wraps an indexable page. Once the prerendered HTML passes 12,800 bytes, the whole landing follows the skeleton in a hidden `<div>`. Delete it; links to `/` are `NavLink`s.
|
||||
- Debt: `FAQPage` markup (`platforms/market/src/app/seo/landing.ts:31`), which Google no longer shows; the home page gets `Organization` and `WebSite` from config instead. The graph is a raw `Element` script after the template (`apps/{bull,bear}/src/app/(landing)/page.tsx:58`), not one `<JsonLd>` before it: the repo has no json-ld lib or island `JsonLd` yet.
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ Scripts: none.
|
|||
- bull and bear build separately, so a client component that one app renders never ships to the other.
|
||||
- `apps/bear/src/app/(main)/default.tsx` is the `children` default: when a soft navigation lands on a `@modal` intercept with no main page under it, it reloads the URL so the full `/compose/*` page renders.
|
||||
- A failed page shows `(main)/error.tsx`: `PageError` with the page's own bar (0049); bull keeps the BottomNav under it.
|
||||
- Debt: the server HTML links the brand to `/feed`, a `noindex` page behind `AuthGuard`, on every main page, including the indexable channel and post pages (`platforms/market/src/app/navigation/hooks/use-home-href.ts:18`). Link `/` while the viewer is unknown; `LandingRedirect` sends a member on (0027).
|
||||
- Debt: the server HTML links the brand to `/feed`, a `noindex` page behind `AuthGuard`, on every main page (`platforms/market/src/app/navigation/hooks/use-home-href.ts:18`). Low priority since 0070 made every `(main)` page `noindex`. Link `/` while the viewer is unknown; `LandingRedirect` sends a member on (0027).
|
||||
- Debt: the header search is not a `GET` form to `/search`, so it does nothing before hydration (`platforms/market/src/app/navigation/components/desktop-header/DesktopHeader.tsx:46`). It is member-only, so the cost is low.
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
`apps/{bull,bear}/src/app/(flow)/terms/layout.tsx` · wraps `/terms` and `/terms/subscription` · it awaits no read: its text is server i18n (`rules`), so it adds nothing to the first byte
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------------------ | ------ | ----------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | back to where the rules were opened, and support, in the first flush; the title «قوانین لومینا» waits for the viewer |
|
||||
| DesktopHeader (bear) | viewer | skeleton | hydrate | no | brand `<a href>` and support in the first flush; nav, bell, account menu and login wait for the viewer ([layout-main.md](layout-main.md)) |
|
||||
| DesktopPageTitle, with the H1 (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 `rules:title`; bull puts its H1 in each page instead |
|
||||
| RulesTabs | config | first flush | hydrate | primary | `TabLinks`: `<a href>` to `/terms` and `/terms/subscription`; `usePathname` marks the current tab |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------------------ | ------ | ----------- | ------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| MobileTopBar (bull) | viewer | skeleton | hydrate | no | back to where the rules were opened, and support, in the first flush; the title «قوانین لومینا» waits for the viewer |
|
||||
| DesktopHeader (bear) | viewer | skeleton | hydrate | no | brand `<a href>` and support in the first flush; nav, bell, account menu and login wait for the viewer ([layout-main.md](layout-main.md)) |
|
||||
| DesktopPageTitle, with the H1 (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 `rules:title`; bull puts its H1 in each page instead |
|
||||
| RulesTabs | config | first flush | hydrate | no | `TabLinks`: `<a href>` to `/terms` and `/terms/subscription`; `usePathname` marks the current tab |
|
||||
|
||||
Scripts: none.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
Every case below is `noindex`. No page answers 410, and the repo sets up no reverse proxy, so 503 under overload comes from whatever sits in front of the app's port.
|
||||
|
||||
| Case | Status | The server HTML holds |
|
||||
| ----------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| A URL no route matches | 404 | the root `not-found.tsx`: `noindex` from its `metadata`, `StatusEmptyState` (not-found, page size) in the first flush; bull: the `MobileTopBar` behind a same-size frame; bear: the `DesktopHeader` behind one (both read the address in the browser) |
|
||||
| `/@username/…` | 308 to `/channels/username/…` | nothing; `redirects()` in `next.config.ts` answers before any render (0064) |
|
||||
| A channel or post that doesn't exist | 200 | `noindex` and the route's `loading.tsx` skeleton: both routes keep a `loading.tsx`, so `notFound()` runs after the status is sent; the channel's `not-found.tsx` renders in the browser. See [channels-username.md](channels-username.md) and [channels-username-posts-id.md](channels-username-posts-id.md) |
|
||||
| `notFound()` on any other page, all under a `loading.tsx` | 200 | the skeleton and `noindex`; the not-found UI renders in the browser |
|
||||
| A failed read on a page under its `loading.tsx` | 200 | the skeleton and the page's `noindex`; the group's `error.tsx` renders `PageError` in the browser, with its own `noindex` |
|
||||
| A failed read on a page with no `loading.tsx` above it | 500 | `noindex` and an empty `<body>`; the group's `error.tsx` renders in the browser. No page is in this case today: every route keeps a `loading.tsx`. The channel and post pages join it once theirs goes (Notes) |
|
||||
| An error the group boundaries don't catch (root layout, AppShell) | 500 | `global-error.tsx`: its own document with `AppCrash` and `<meta name="robots" content="noindex">`, rendered in the browser |
|
||||
| Case | Status | The server HTML holds |
|
||||
| ----------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| A URL no route matches | 404 | the root `not-found.tsx`: `noindex` from its `metadata`, `StatusEmptyState` (not-found, page size) in the first flush; bull: the `MobileTopBar` behind a same-size frame; bear: the `DesktopHeader` behind one (both read the address in the browser) |
|
||||
| `/@username/…` | 308 to `/channels/username/…` | nothing; `redirects()` in `next.config.ts` answers before any render (0064) |
|
||||
| A channel or post that doesn't exist | 200 | `noindex` and the page's skeleton: the server reads nothing (0070), so the browser's read finds the channel or post missing and renders `ChannelMissing` or `PostMissing` in the page's frame. See [channels-username.md](channels-username.md) and [channels-username-posts-id.md](channels-username-posts-id.md) |
|
||||
| `notFound()` on any other page, all under a `loading.tsx` | 200 | the skeleton and `noindex`; the not-found UI renders in the browser |
|
||||
| A failed browser read of a page's data | 200 | the skeleton and the page's `noindex`; the read throws to the group's `error.tsx`, which renders `PageError` with its own `noindex` |
|
||||
| A failed read on a page with no `loading.tsx` above it | 500 | `noindex` and an empty `<body>`; the group's `error.tsx` renders in the browser. Only the landing reads data on the server, and it is prerendered (0026): a failed revalidation keeps the last good page |
|
||||
| An error the group boundaries don't catch (root layout, AppShell) | 500 | `global-error.tsx`: its own document with `AppCrash` and `<meta name="robots" content="noindex">`, rendered in the browser |
|
||||
|
||||
## Boundaries
|
||||
|
||||
|
|
@ -26,4 +26,4 @@ Every case below is `noindex`. No page answers 410, and the repo sets up no reve
|
|||
## Notes
|
||||
|
||||
- `PageError` and `global-error.tsx` render `<meta name="robots" content="noindex">`; the root `not-found.tsx` sets it in `metadata`.
|
||||
- Debt: the channel and post pages are indexable but keep a `loading.tsx`, so a missing channel or post answers 200 instead of a real 404. See those docs.
|
||||
- A missing channel or post answers 200 by design: both pages are `noindex` and read in the browser (0070).
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Robots | `index` |
|
||||
| Robots | `noindex` (`terms` layout `metadata`, 0071) |
|
||||
| Status | `200` |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(flow)/terms/subscription/loading.tsx` (debt, Notes) |
|
||||
| First flush | none: config, server i18n (`terms`, `auth`) and `getEnv().supportHours` |
|
||||
| Canonical | none set (debt, Notes) |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | bull: `terms:title` «شرایط اشتراک», screen-reader-only, in `SubscriptionTerms`; bear: `rules:title` «قوانین لومینا» from the layout (debt) |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none |
|
||||
|
|
@ -17,14 +17,12 @@
|
|||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------- | ------ | ----------- | ---- | --------- | ---------------------------------------------------------------------------------------------- |
|
||||
| SubscriptionTerms | config | first flush | none | primary | one `<section>` per term with its heading; bear: in a `Card` |
|
||||
| ↳ Support hours and chats | config | first flush | none | secondary | island `SupportSheet` rows: `<a href>` to the Bale and Telegram chats, inside the last section |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------------------- | ------ | ----------- | ---- | ----- | ---------------------------------------------------------------------------------------------- |
|
||||
| SubscriptionTerms | config | first flush | none | no | one `<section>` per term with its heading; bear: in a `Card` |
|
||||
| ↳ Support hours and chats | config | first flush | none | no | island `SupportSheet` rows: `<a href>` to the Bale and Telegram chats, inside the last section |
|
||||
|
||||
## Notes
|
||||
|
||||
- The landing footer links here; checkout, a suspended card and the support sheet open it too.
|
||||
- Debt: `loading.tsx` wraps an indexable page. Delete it.
|
||||
- Debt: no canonical. Add `alternates: { canonical: ROUTES.rules.subscription }` to the page's `metadata`.
|
||||
- Debt: the H1 differs between the apps ([layout-terms.md](layout-terms.md)).
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| Robots | `index` |
|
||||
| Robots | `noindex` (`terms` layout `metadata`, 0071) |
|
||||
| Status | `200` |
|
||||
| loading.tsx | `apps/{bull,bear}/src/app/(flow)/terms/loading.tsx` (debt, Notes) |
|
||||
| First flush | none: config and server i18n (`rules`) |
|
||||
| Canonical | none set (debt, Notes) |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | `rules:title`; bull: a screen-reader-only H1 in `GeneralRules`; bear: `DesktopPageTitle` in the layout |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none |
|
||||
|
|
@ -17,11 +17,8 @@
|
|||
|
||||
In bull's document order.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------ | ------ | ----------- | ---- | ------- | ---------------------------------------------------------------------------------------- |
|
||||
| GeneralRules | config | first flush | none | primary | one `<section>` per rule with its heading, then the last-updated line; bear: in a `Card` |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| ------------ | ------ | ----------- | ---- | ----- | ---------------------------------------------------------------------------------------- |
|
||||
| GeneralRules | config | first flush | none | no | one `<section>` per rule with its heading, then the last-updated line; bear: in a `Card` |
|
||||
|
||||
## Notes
|
||||
|
||||
- Debt: `loading.tsx` wraps an indexable page. Delete it; the tab links are `<a href>` and need no pending skeleton for crawlers.
|
||||
- Debt: no canonical. Add `alternates: { canonical: ROUTES.rules.general }` to the page's `metadata`.
|
||||
|
|
|
|||
|
|
@ -8,26 +8,41 @@ import { EmptyState } from '@lumina/island/molecules/empty-state';
|
|||
import { PageHeader } from '@lumina/island/molecules/page-header';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useAnalystsPage } from '../../../../../../features/discovery';
|
||||
import { useViewerStatus } from '../../../../../../stores/auth';
|
||||
import { AnalystList } from '../../../organisms/analyst-list';
|
||||
import {
|
||||
AnalystList,
|
||||
AnalystListSkeleton,
|
||||
} from '../../../organisms/analyst-list';
|
||||
import { GuestSignupCard } from './components/GuestSignupCard';
|
||||
import type { AnalystsDirectoryProps } from './types';
|
||||
|
||||
/**
|
||||
* «تحلیلگران منتخب» (J04-3): every featured analyst, in the admin's order, no paging, under the
|
||||
* note that Lumina's team chooses them and it is no ranking. The list renders on the server, the
|
||||
* same for everyone; in the browser an investor gets follow on each card, and a guest the free
|
||||
* registration card at the end (3b). On mobile a guest has no title in the bar, so the page keeps
|
||||
* its own heading, also while the viewer is unknown (most visitors are guests).
|
||||
* note that Lumina's team chooses them and it is no ranking. The list is read in the browser
|
||||
* only (0070), the same for everyone, behind the route's skeleton; an investor gets follow on each
|
||||
* card, and a guest the free registration card at the end (3b). On mobile a guest has no title in
|
||||
* the bar, so the page keeps its own heading, also while the viewer is unknown (most visitors are
|
||||
* guests).
|
||||
*/
|
||||
export function AnalystsDirectory({
|
||||
analysts,
|
||||
layout,
|
||||
}: AnalystsDirectoryProps) {
|
||||
export function AnalystsDirectory({ layout }: AnalystsDirectoryProps) {
|
||||
const { t } = useTranslation('home');
|
||||
const status = useViewerStatus();
|
||||
const page = useAnalystsPage();
|
||||
const isDesktop = layout === 'desktop';
|
||||
|
||||
if (page.status === 'pending') {
|
||||
return (
|
||||
<AnalystListSkeleton
|
||||
layout={layout}
|
||||
columns={3}
|
||||
count={3}
|
||||
label={t('analysts.loading')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const { analysts } = page;
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap={isDesktop ? 'gap-4' : 'gap-3'}>
|
||||
{!isDesktop && status !== 'member' && (
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
import type { CreatorSummaryPayload } from '../../../../../../features/discovery';
|
||||
|
||||
export type AnalystsDirectoryLayout = 'mobile' | 'desktop';
|
||||
|
||||
export type AnalystsDirectoryProps = {
|
||||
/** Every featured analyst, in the admin's order, from the server's read. */
|
||||
analysts: CreatorSummaryPayload[];
|
||||
layout: AnalystsDirectoryLayout;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ export function ChannelDeskBack({
|
|||
}: ChannelDeskBackProps) {
|
||||
const account = useCurrentAccount();
|
||||
|
||||
if (account?.id === creatorId) return null;
|
||||
if (creatorId && account?.id === creatorId) return null;
|
||||
return <DeskBack parentHref={parentHref} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export type ChannelDeskBackProps = {
|
||||
/** The channel's creator, who gets no back on their own tab. */
|
||||
creatorId: string;
|
||||
/** The channel's creator, who gets no back on their own tab; unknown while the channel loads. */
|
||||
creatorId?: string;
|
||||
/** Where back goes when nothing of this site is behind the page: a post's channel; else home. */
|
||||
parentHref?: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
import { getCreatorPosts } from '../../../../../../../features/post/caches/server';
|
||||
import { ChannelFeedList } from './components/ChannelFeedList';
|
||||
import type { ChannelFeedProps } from './types';
|
||||
|
||||
/**
|
||||
* The channel's feed part: the first page read on the server, so search engines and the first
|
||||
* paint have the posts, handed to the list that keeps it live in the browser.
|
||||
* The channel's feed part, read in the browser only (0070): it suspends until the first page
|
||||
* arrives, so its `<Suspense>` shows the posts' skeleton.
|
||||
*/
|
||||
export async function ChannelFeed({ channel, now, layout }: ChannelFeedProps) {
|
||||
const firstPage = await getCreatorPosts(channel.creatorId);
|
||||
export function ChannelFeed({ channel, layout }: ChannelFeedProps) {
|
||||
return (
|
||||
<ChannelFeedList
|
||||
creatorId={channel.creatorId}
|
||||
username={channel.username}
|
||||
displayName={channel.displayName}
|
||||
avatarUrl={channel.avatarUrl}
|
||||
firstPage={firstPage}
|
||||
now={now}
|
||||
layout={layout}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const PostLightbox = dynamic(() =>
|
|||
|
||||
/**
|
||||
* The channel's posts, newest first, locked premium posts in their place among the free ones. The
|
||||
* server renders the first page as every visitor sees it; the gates wait for the viewer, and a
|
||||
* browser reads them with the visitor's session (0070); the gates wait for the viewer, and a
|
||||
* subscriber's or the creator's locked posts open in place. Older pages load on request; one that
|
||||
* fails shows an inline retry at the end while the posts stay. The creator's newest premium post
|
||||
* says when no one subscribes yet (C5 ۱.۴), in the browser only.
|
||||
|
|
@ -43,8 +43,6 @@ export function ChannelFeedList({
|
|||
username,
|
||||
displayName,
|
||||
avatarUrl,
|
||||
firstPage,
|
||||
now,
|
||||
layout,
|
||||
}: ChannelFeedListProps) {
|
||||
const { t } = useTranslation(['channel', 'errors']);
|
||||
|
|
@ -52,12 +50,15 @@ export function ChannelFeedList({
|
|||
const entitled = useChannelEntitled(creatorId);
|
||||
const gate = useChannelGate(creatorId);
|
||||
const standing = useChannelStanding(creatorId);
|
||||
const { posts, isEmpty, hasMore, loadMore, isLoadingMore, loadMoreError } =
|
||||
useChannelFeedPart({
|
||||
creatorId,
|
||||
firstPage,
|
||||
entitled,
|
||||
});
|
||||
const {
|
||||
posts,
|
||||
isEmpty,
|
||||
hasMore,
|
||||
loadMore,
|
||||
isLoadingMore,
|
||||
loadMoreError,
|
||||
now,
|
||||
} = useChannelFeedPart({ creatorId, entitled });
|
||||
// The last image tapped stays after the viewer closes, so it closes in place: it fades out and
|
||||
// focus goes back to the image.
|
||||
const [viewed, setViewed] = useState<ViewedImage | null>(null);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,2 @@
|
|||
import 'server-only';
|
||||
|
||||
export { ChannelFeed } from './ChannelFeed';
|
||||
export type { ChannelFeedLayout, ChannelFeedProps } from './types';
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
import type { PublicCreatorPayload } from '../../../../../../../features/channel';
|
||||
import type { PostPagePayload } from '../../../../../../../features/post';
|
||||
|
||||
export type ChannelFeedLayout = 'mobile' | 'desktop';
|
||||
|
||||
export type ChannelFeedProps = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** What the posts' relative times count from: the server render's time. */
|
||||
now: string;
|
||||
layout: ChannelFeedLayout;
|
||||
};
|
||||
|
||||
|
|
@ -15,8 +12,6 @@ export type ChannelFeedListProps = {
|
|||
username: string;
|
||||
displayName: string | null;
|
||||
avatarUrl: string | null;
|
||||
firstPage: PostPagePayload;
|
||||
now: string;
|
||||
layout: ChannelFeedLayout;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export type ChannelHeaderLabels = {
|
|||
};
|
||||
|
||||
export type ChannelHeaderProps = {
|
||||
/** Its `followerCount`, from the server's `getChannel`, renders the follower count at once. */
|
||||
/** Its `followerCount`, read with the channel, renders the follower count at once. */
|
||||
channel: PublicCreatorPayload;
|
||||
/**
|
||||
* @deprecated No longer shown: the sub-line is @username (DS v6.1, R15). Kept so the callers
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
'use client';
|
||||
|
||||
import { CreatorStats } from '@lumina/island/organisms/creator-stats';
|
||||
|
||||
import { getPredictionStats } from '../../../../../../../features/prediction/caches/server';
|
||||
import { useCreatorStatsPart } from '../../../../../../../features/prediction';
|
||||
import type { ChannelStatsProps } from './types';
|
||||
|
||||
/**
|
||||
* The creator's track record in the header, the same for every visitor. All or nothing: below the
|
||||
* API's threshold (`public: false`) it renders nothing, never zeros, and the header closes the gap.
|
||||
* The creator's track record in the header, the same for every visitor and read in the browser
|
||||
* (0070). All or nothing: below the API's threshold (`public: false`) it renders nothing, never
|
||||
* zeros, and the header closes the gap. It suspends while reading, so its `<Suspense>` shows the
|
||||
* stats skeleton.
|
||||
*/
|
||||
export async function ChannelStats({ creatorId, labels }: ChannelStatsProps) {
|
||||
const stats = await getPredictionStats(creatorId);
|
||||
export function ChannelStats({ creatorId, labels }: ChannelStatsProps) {
|
||||
const { stats } = useCreatorStatsPart(creatorId);
|
||||
return (
|
||||
<CreatorStats
|
||||
stats={stats.isPublic ? stats : null}
|
||||
trendOrder="oldest-first"
|
||||
labels={labels}
|
||||
/>
|
||||
<CreatorStats stats={stats} trendOrder="oldest-first" labels={labels} />
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,2 @@
|
|||
import 'server-only';
|
||||
|
||||
export { ChannelStats } from './ChannelStats';
|
||||
export type { ChannelStatsProps } from './types';
|
||||
|
|
@ -3,7 +3,7 @@ import type { ReactNode } from 'react';
|
|||
import type { PublicCreatorPayload } from '../../../../../../../../../features/channel';
|
||||
|
||||
export type PostChannelBarProps = {
|
||||
/** Its `followerCount`, from the server's `getChannel`, renders the follower count at once. */
|
||||
/** Its `followerCount`, read with the channel, renders the follower count at once. */
|
||||
channel: PublicCreatorPayload;
|
||||
/** mobile: a card in a padded strip under the top bar. desktop: a panel in the 640 column. */
|
||||
layout: 'mobile' | 'desktop';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export type PostViewProps = {
|
|||
/** The creator's display name for the card's header; absent, @username alone. */
|
||||
displayName?: string | null;
|
||||
avatarUrl: string | null;
|
||||
/** What the time counts from: the server render's time. */
|
||||
/** What the time counts from: when the post was read. */
|
||||
now: string;
|
||||
layout: 'mobile' | 'desktop';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
/** Search results cut titles and descriptions around these lengths. */
|
||||
export const TITLE_MAX_LENGTH = 60;
|
||||
export const DESCRIPTION_MAX_LENGTH = 160;
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { ROUTES } from '../navigation/navigation';
|
||||
import { DESCRIPTION_MAX_LENGTH, TITLE_MAX_LENGTH } from './constants';
|
||||
import type { ChannelMetadataArgs, PostMetadataArgs } from './types';
|
||||
|
||||
/** Cut at a word, with «…», when it runs past `max`. */
|
||||
function clip(text: string, max: number): string {
|
||||
if (text.length <= max) return text;
|
||||
const cut = text.slice(0, max - 1);
|
||||
const space = cut.lastIndexOf(' ');
|
||||
return `${(space > max / 2 ? cut.slice(0, space) : cut).trimEnd()}…`;
|
||||
}
|
||||
|
||||
/** A channel's title, description, canonical `/channels/username` and profile card. */
|
||||
export function channelMetadata({
|
||||
channel,
|
||||
title,
|
||||
description,
|
||||
}: ChannelMetadataArgs): Metadata {
|
||||
const url = ROUTES.channel(channel.username);
|
||||
const summary = clip(
|
||||
channel.bio?.replace(/\s+/g, ' ') ?? description,
|
||||
DESCRIPTION_MAX_LENGTH,
|
||||
);
|
||||
return {
|
||||
title,
|
||||
description: summary,
|
||||
alternates: { canonical: url },
|
||||
openGraph: {
|
||||
type: 'profile',
|
||||
title,
|
||||
description: summary,
|
||||
url,
|
||||
username: channel.username,
|
||||
images: channel.avatarUrl ? [channel.avatarUrl] : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A post's metadata from what every visitor may read: a premium post's teaser, never its full
|
||||
* text, and never its images, which are paywalled. The first line of text names it.
|
||||
*/
|
||||
export function postMetadata({
|
||||
channel,
|
||||
post,
|
||||
fallbackTitle,
|
||||
}: PostMetadataArgs): Metadata {
|
||||
const text = (post.locked ? post.captionPreview : post.caption)?.trim();
|
||||
const firstLine = text
|
||||
?.split('\n')
|
||||
.find((line) => line.trim())
|
||||
?.trim();
|
||||
const title = firstLine ? clip(firstLine, TITLE_MAX_LENGTH) : fallbackTitle;
|
||||
const description = text
|
||||
? clip(text.replace(/\s+/g, ' '), DESCRIPTION_MAX_LENGTH)
|
||||
: undefined;
|
||||
const url = ROUTES.post(channel.username, post.id);
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
alternates: { canonical: url },
|
||||
openGraph: {
|
||||
type: 'article',
|
||||
title,
|
||||
description,
|
||||
url,
|
||||
publishedTime: post.publishedAt ?? undefined,
|
||||
authors: [ROUTES.channel(channel.username)],
|
||||
images: channel.avatarUrl ? [channel.avatarUrl] : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
import 'server-only';
|
||||
|
||||
export { faqJsonLd, landingMetadata } from './landing';
|
||||
export { channelMetadata, postMetadata } from './metadata';
|
||||
export type {
|
||||
ChannelMetadataArgs,
|
||||
FaqJsonLdItem,
|
||||
LandingMetadataArgs,
|
||||
PostMetadataArgs,
|
||||
} from './types';
|
||||
export type { FaqJsonLdItem, LandingMetadataArgs } from './types';
|
||||
|
|
|
|||
|
|
@ -1,21 +1,3 @@
|
|||
import type { PublicCreatorPayload } from '../../features/channel';
|
||||
import type { PostPayload } from '../../features/post';
|
||||
|
||||
export type ChannelMetadataArgs = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** «@sara_gold»; the root layout adds « · لومینا». */
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type PostMetadataArgs = {
|
||||
channel: PublicCreatorPayload;
|
||||
/** As every visitor sees it: a premium post is its teaser. */
|
||||
post: PostPayload;
|
||||
/** When the post has no text to name it: «پست @sara_gold». */
|
||||
fallbackTitle: string;
|
||||
};
|
||||
|
||||
export type LandingMetadataArgs = {
|
||||
/** The whole title, brand included: «لومینا — …». */
|
||||
title: string;
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import { cache } from 'react';
|
||||
|
||||
import { channelRepository } from '../repositories/channel';
|
||||
import type { PublicCreatorPayload } from '../repositories/channel';
|
||||
import { getPublicTiers } from './public-tiers';
|
||||
|
||||
/**
|
||||
* The channel at `/channels/username`, once per render per username: the page and its metadata
|
||||
* share one request. Pass the username as the API stores it (lower case). 404 reaches the caller.
|
||||
* It carries the public follower count for the header (a failed count is left to the browser) and
|
||||
* whether anything can be bought (J05-1g): an approved creator with a priced tier. Failed tiers
|
||||
* leave the sale open, so checkout decides.
|
||||
*/
|
||||
export const getChannel = cache(
|
||||
async (username: string): Promise<PublicCreatorPayload> => {
|
||||
const channel = await channelRepository.getCreatorByUsername({ username });
|
||||
// A suspended channel shows no header, so no count.
|
||||
if (channel.suspended) return channel;
|
||||
const [followerCount, hasPricedTier] = await Promise.all([
|
||||
channelRepository
|
||||
.getFollowerCount({ creatorId: channel.creatorId })
|
||||
.catch(() => null),
|
||||
getPublicTiers(channel.creatorId).then(
|
||||
(tiers) => tiers.some((tier) => (tier.priceToman ?? 0) > 0),
|
||||
() => true,
|
||||
),
|
||||
]);
|
||||
const saleOpen = !channel.verificationPending && hasPricedTier;
|
||||
return { ...channel, followerCount, saleOpen };
|
||||
},
|
||||
);
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import { cache } from 'react';
|
||||
|
||||
import { channelRepository } from '../repositories/channel';
|
||||
import type { PublicCreatorPayload } from '../repositories/channel';
|
||||
|
||||
/** An approved creator's public profile, once per render per id. 404 reaches the caller. */
|
||||
export const getPublicCreator = cache(
|
||||
(creatorId: string): Promise<PublicCreatorPayload> =>
|
||||
channelRepository.getCreator({ creatorId }),
|
||||
);
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import { cache } from 'react';
|
||||
|
||||
import { channelRepository } from '../repositories/channel';
|
||||
import type { PublicTierPayload } from '../repositories/channel';
|
||||
|
||||
/** A creator's active tiers, once per render per id; the channel and checkout share it. */
|
||||
export const getPublicTiers = cache(
|
||||
(creatorId: string): Promise<PublicTierPayload[]> =>
|
||||
channelRepository.listTiers({ creatorId }),
|
||||
);
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
export { getChannel } from './channel';
|
||||
export { getPublicCreator } from './public-creator';
|
||||
export { getPublicTiers } from './public-tiers';
|
||||
|
|
@ -18,6 +18,8 @@ export type {
|
|||
ChannelCountsPartModel,
|
||||
UseChannelCountsPartOptions,
|
||||
} from './models/channel-counts';
|
||||
export { channelPageQuery, useChannelPage } from './models/channel-page';
|
||||
export type { ChannelPageModel } from './models/channel-page';
|
||||
export { syncFollowCaches } from './models/follow-caches';
|
||||
export { useFollowingPart } from './models/following';
|
||||
export type { FollowingPartModel } from './models/following';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
import { classifyError } from '@lumina/libs/error-handler';
|
||||
import { queryOptions } from '@tanstack/react-query';
|
||||
|
||||
import { channelKeys, channelRepository } from '../../repositories/channel';
|
||||
import type { PublicCreatorPayload } from '../../repositories/channel';
|
||||
|
||||
/**
|
||||
* The channel at `/channels/username` with its public follower count (a failed count is left to
|
||||
* the header) and whether anything can be bought (J05-1g): an approved creator with a priced
|
||||
* tier. Failed tiers leave the sale open, so checkout decides. `null` when no channel has this
|
||||
* username; any other failure rejects to the page's boundary.
|
||||
*/
|
||||
async function readChannelPage(
|
||||
username: string,
|
||||
signal: AbortSignal,
|
||||
): Promise<PublicCreatorPayload | null> {
|
||||
let channel: PublicCreatorPayload;
|
||||
try {
|
||||
channel = await channelRepository.getCreatorByUsername(
|
||||
{ username },
|
||||
{ signal },
|
||||
);
|
||||
} catch (error) {
|
||||
if (classifyError(error).read === 'not-found') return null;
|
||||
throw error;
|
||||
}
|
||||
// A suspended channel shows no header, so no count.
|
||||
if (channel.suspended) return channel;
|
||||
const [followerCount, hasPricedTier] = await Promise.all([
|
||||
channelRepository
|
||||
.getFollowerCount({ creatorId: channel.creatorId }, { signal })
|
||||
.catch(() => null),
|
||||
channelRepository
|
||||
.listTiers({ creatorId: channel.creatorId }, { signal })
|
||||
.then(
|
||||
(tiers) => tiers.some((tier) => (tier.priceToman ?? 0) > 0),
|
||||
() => true,
|
||||
),
|
||||
]);
|
||||
const saleOpen = !channel.verificationPending && hasPricedTier;
|
||||
return { ...channel, followerCount, saleOpen };
|
||||
}
|
||||
|
||||
/** The channel page's one read, shared by the channel, its posts and checkout (0070). */
|
||||
export const channelPageQuery = (username: string) =>
|
||||
queryOptions({
|
||||
queryKey: channelKeys.page(username),
|
||||
queryFn: ({ signal }) => readChannelPage(username, signal),
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export { channelPageQuery } from './channel-page-query';
|
||||
export { useChannelPage } from './use-channel-page';
|
||||
export type { ChannelPageModel } from './types';
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import type { PublicCreatorPayload } from '../../repositories/channel';
|
||||
|
||||
export type ChannelPageModel =
|
||||
/** Still reading: the page keeps its skeleton. */
|
||||
| { status: 'pending' }
|
||||
/** No channel has this username, or not any more. */
|
||||
| { status: 'not-found' }
|
||||
| { status: 'ok'; channel: PublicCreatorPayload };
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { channelPageQuery } from './channel-page-query';
|
||||
import type { ChannelPageModel } from './types';
|
||||
|
||||
/**
|
||||
* The channel a page shows, read in the browser only (0070): the server render has no data, so it
|
||||
* sends the page's skeleton, which stays until this read arrives. The same for every visitor.
|
||||
*/
|
||||
export function useChannelPage(username: string): ChannelPageModel {
|
||||
const { data } = useQuery(channelPageQuery(username));
|
||||
// A failed first read throws to the page's boundary, so no data means it is still loading.
|
||||
if (data === undefined) return { status: 'pending' };
|
||||
if (data === null) return { status: 'not-found' };
|
||||
return { status: 'ok', channel: data };
|
||||
}
|
||||
|
|
@ -21,6 +21,8 @@ export const channelKeys = {
|
|||
[...channelKeys.creator(creatorId), 'follower-count'] as const,
|
||||
byUsername: (username: string) =>
|
||||
[...channelKeys.all, 'username', username] as const,
|
||||
/** The channel page's read: the header with its follower count and sale state, or `null`. */
|
||||
page: (username: string) => [...channelKeys.all, 'page', username] as const,
|
||||
/** The signed-in investor's follow and subscription with this creator. */
|
||||
standing: (creatorId: string) =>
|
||||
[...channelKeys.creator(creatorId), 'standing'] as const,
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ export type PublicCreatorPayload = {
|
|||
verificationPending?: boolean;
|
||||
/**
|
||||
* Whether anything can be bought: the creator is approved and has a priced tier. Read with the
|
||||
* channel only by the server's `getChannel`, for every visitor's action area; `true` when the
|
||||
* channel only by `channelPageQuery`, for every visitor's action area; `true` when the
|
||||
* tiers couldn't be read, so checkout stays the gate. An investor's own checkout screen says it
|
||||
* again (`ChannelStanding.saleClosed`).
|
||||
*/
|
||||
saleOpen?: boolean;
|
||||
/**
|
||||
* The public follower count, read with the channel only by the server's `getChannel`, so the
|
||||
* header renders it: absent from every other read, and `null` when that read failed. Either
|
||||
* way the header reads it again in the browser.
|
||||
* The public follower count, read with the channel only by `channelPageQuery`, so the header
|
||||
* renders it with the channel: absent from every other read, and `null` when that read failed,
|
||||
* which the header then reads on its own.
|
||||
*/
|
||||
followerCount?: number | null;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ export type {
|
|||
CodeSource,
|
||||
UseCheckoutPageOptions,
|
||||
} from './models/checkout';
|
||||
export { useCheckoutChannel } from './models/checkout-channel';
|
||||
export type { CheckoutChannelModel } from './models/checkout-channel';
|
||||
export { useInviteLink } from './models/invite-link';
|
||||
export type { InviteLinkModel } from './models/invite-link';
|
||||
export { usePaymentResultPage } from './models/payment-result';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
export { useCheckoutChannel } from './use-checkout-channel';
|
||||
export type { CheckoutChannelModel } from './types';
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import type { ChannelPageModel } from '../../../channel';
|
||||
|
||||
/** The channel being paid; a suspended one stays `pending` while the page leaves for it. */
|
||||
export type CheckoutChannelModel = ChannelPageModel;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { useRouter } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { ROUTES } from '../../../../app/navigation/navigation';
|
||||
import { useChannelPage } from '../../../channel';
|
||||
import type { CheckoutChannelModel } from './types';
|
||||
|
||||
/**
|
||||
* Who is being paid on `/checkout/username`, read in the browser only (0070), the same for every
|
||||
* visitor. A suspended channel sends the visitor to the channel, which says it is unavailable;
|
||||
* the page keeps its skeleton meanwhile.
|
||||
*/
|
||||
export function useCheckoutChannel(username: string): CheckoutChannelModel {
|
||||
const router = useRouter();
|
||||
const page = useChannelPage(username);
|
||||
const suspended = page.status === 'ok' && page.channel.suspended;
|
||||
|
||||
useEffect(() => {
|
||||
if (suspended) router.replace(ROUTES.channel(username));
|
||||
}, [suspended, router, username]);
|
||||
|
||||
return suspended ? { status: 'pending' } : page;
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ export type {
|
|||
AnalystFollowState,
|
||||
UseAnalystFollowPartOptions,
|
||||
} from './models/analyst-follow';
|
||||
export { useAnalystsPage } from './models/analysts-page';
|
||||
export type { AnalystsPageModel } from './models/analysts-page';
|
||||
export {
|
||||
isSearchable,
|
||||
SEARCH_MIN_LENGTH,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
export { useAnalystsPage } from './use-analysts-page';
|
||||
export type { AnalystsPageModel } from './types';
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import type { CreatorSummaryPayload } from '../../repositories/discovery';
|
||||
|
||||
export type AnalystsPageModel =
|
||||
/** Still reading: the page keeps its skeleton. */
|
||||
| { status: 'pending' }
|
||||
/** Every featured analyst, in the admin's order. */
|
||||
| { status: 'ok'; analysts: CreatorSummaryPayload[] };
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { featuredCreatorsQuery } from '../featured-creators/featured-creators-query';
|
||||
import type { AnalystsPageModel } from './types';
|
||||
|
||||
/**
|
||||
* «تحلیلگران منتخب» (J04-3): every featured analyst, read in the browser only (0070), the same
|
||||
* for every visitor and shared with خانه's featured row. A failed read is the page's error state
|
||||
* with its retry, never a partial list.
|
||||
*/
|
||||
export function useAnalystsPage(): AnalystsPageModel {
|
||||
const { data } = useQuery(featuredCreatorsQuery());
|
||||
// A failed first read throws to the page's boundary, so no data means it is still loading.
|
||||
return data === undefined
|
||||
? { status: 'pending' }
|
||||
: { status: 'ok', analysts: data };
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import { cache } from 'react';
|
||||
|
||||
import { POST_PAGE_LIMIT, postRepository } from '../repositories/post';
|
||||
import type { PostPagePayload } from '../repositories/post';
|
||||
|
||||
/**
|
||||
* A channel's first page as every visitor sees it: server reads carry no session, so drafts are
|
||||
* left out and premium posts come locked. The creator's drafts and a subscriber's unlocked posts
|
||||
* load in the browser, in the auth-dependent part that replaces this page. Later pages load on the
|
||||
* client with the same `POST_PAGE_LIMIT`.
|
||||
*/
|
||||
export const getCreatorPosts = cache(
|
||||
async (creatorId: string): Promise<PostPagePayload> =>
|
||||
postRepository.listByCreator({
|
||||
creatorId,
|
||||
page: 1,
|
||||
limit: POST_PAGE_LIMIT,
|
||||
}),
|
||||
);
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
import { cache } from 'react';
|
||||
|
||||
import { postRepository } from '../repositories/post';
|
||||
import type { PostPayload } from '../repositories/post';
|
||||
|
||||
/**
|
||||
* One post as every visitor sees it: server reads carry no session, so a premium post comes locked
|
||||
* and the full post loads in the browser for a subscriber. A missing post or any draft, the
|
||||
* creator's own included, rejects with a 404 for `readOnServer`; the creator opens a draft from a
|
||||
* page that reads it in the browser.
|
||||
*/
|
||||
export const getPost = cache(
|
||||
async (id: string): Promise<PostPayload> => postRepository.get(id),
|
||||
);
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
import 'server-only';
|
||||
|
||||
export { getCreatorPosts } from './creator-posts';
|
||||
export { getPost } from './post';
|
||||
|
|
@ -50,6 +50,8 @@ export type {
|
|||
UseOwnPostsPartOptions,
|
||||
} from './models/own-posts';
|
||||
export { usePostPart } from './models/post';
|
||||
export { usePostPage } from './models/post-page';
|
||||
export type { PostPageModel } from './models/post-page';
|
||||
export { usePublishAccess } from './models/publish-access';
|
||||
export type {
|
||||
BlockedStanding,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import type { PostPagePayload, PostPayload } from '../../repositories/post';
|
||||
import type { PostPayload } from '../../repositories/post';
|
||||
import type { PostListModel } from '../post-list';
|
||||
|
||||
export type UseChannelFeedPartOptions = {
|
||||
/** The creator's account id. */
|
||||
creatorId: string;
|
||||
/** The first page as the server read it: every visitor's view, premium posts locked. */
|
||||
firstPage: PostPagePayload;
|
||||
/** The creator or an active subscriber: the pages are read again with their session. */
|
||||
/** The creator or an active subscriber: the pages are read again once their session is known. */
|
||||
entitled: boolean;
|
||||
};
|
||||
|
||||
export type ChannelFeedPartModel = PostListModel<PostPayload>;
|
||||
export type ChannelFeedPartModel = PostListModel<PostPayload> & {
|
||||
/** When the first page was read: the posts' relative times count from it. */
|
||||
now: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import {
|
||||
POST_PAGE_LIMIT,
|
||||
|
|
@ -9,18 +9,17 @@ import { usePostList } from '../post-list';
|
|||
import type { ChannelFeedPartModel, UseChannelFeedPartOptions } from './types';
|
||||
|
||||
/**
|
||||
* A channel's posts, page after page. The first page comes from the server render, which carries
|
||||
* no session, so premium posts arrive locked; for the creator or a subscriber the loaded pages are
|
||||
* read again in the browser and those posts open in place. Drafts reach only the creator and
|
||||
* stay out of the channel. A post read in full stays open while the list is mounted (C5 §۵), as
|
||||
* `usePostList` keeps it.
|
||||
* A channel's posts, page after page, read in the browser only (0070) with the visitor's session,
|
||||
* so a subscriber's premium posts arrive open. A session restored after the first read makes the
|
||||
* creator or a subscriber entitled, and the loaded pages are read again for them. Drafts reach
|
||||
* only the creator and stay out of the channel. A post read in full stays open while the list is
|
||||
* mounted (C5 §۵), as `usePostList` keeps it.
|
||||
*/
|
||||
export function useChannelFeedPart({
|
||||
creatorId,
|
||||
firstPage,
|
||||
entitled,
|
||||
}: UseChannelFeedPartOptions): ChannelFeedPartModel {
|
||||
const feed = useInfiniteQuery({
|
||||
const feed = useSuspenseInfiniteQuery({
|
||||
queryKey: postKeys.channelFeed(creatorId),
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
postRepository.listByCreator(
|
||||
|
|
@ -30,8 +29,10 @@ export function useChannelFeedPart({
|
|||
initialPageParam: 1,
|
||||
getNextPageParam: ({ page, limit, total }) =>
|
||||
page * limit < total ? page + 1 : undefined,
|
||||
initialData: { pages: [firstPage], pageParams: [1] },
|
||||
});
|
||||
|
||||
return usePostList({ query: feed, entitled });
|
||||
return {
|
||||
...usePostList({ query: feed, entitled }),
|
||||
now: new Date(feed.dataUpdatedAt).toISOString(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,8 @@ export function useOwnerPostPart({
|
|||
setIsConfirmingDelete(false);
|
||||
removeCachedPost(queryClient, post);
|
||||
showToast({ tone: 'success', message: t('post.delete.deleted') });
|
||||
// The channel's first page and track record are rendered on the server: the page it goes
|
||||
// to is read fresh, and one it stays on renders again. Refreshed before leaving, the post
|
||||
// page would flash its «deleted» state first.
|
||||
// The post page it stays on renders again and reads the post afresh, which is now missing.
|
||||
// Refreshed before leaving, the post page would flash its «deleted» state first.
|
||||
if (onDeleted) onDeleted();
|
||||
else router.refresh();
|
||||
};
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue