diff --git a/apps/bear/src/app/(flow)/checkout/[username]/page.tsx b/apps/bear/src/app/(flow)/checkout/[username]/page.tsx index f2acc2f..b373cc3 100644 --- a/apps/bear/src/app/(flow)/checkout/[username]/page.tsx +++ b/apps/bear/src/app/(flow)/checkout/[username]/page.tsx @@ -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 ; + return ; } diff --git a/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx b/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx index e582f6f..deb4b09 100644 --- a/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx +++ b/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx @@ -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 = ( + } + label={t('checkout.loading')} + /> + ); + } else if (page.status === 'not-found') { + content = ; + } else { + const { channel } = page; + content = ( + + } + creatorName={channel.displayName ?? channel.username} + creatorLinks={channel.socialLinks} + /> + + ); + } return ( @@ -33,22 +77,9 @@ export function CheckoutTemplate({ channel }: CheckoutTemplateProps) { > - - } - creatorName={channel.displayName ?? channel.username} - creatorLinks={channel.socialLinks} - /> - + {content} diff --git a/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts b/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts index efd0409..222517b 100644 --- a/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts +++ b/apps/bear/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts @@ -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; +}; diff --git a/apps/bear/src/app/(flow)/terms/layout.tsx b/apps/bear/src/app/(flow)/terms/layout.tsx index 4c7d63c..147aef5 100644 --- a/apps/bear/src/app/(flow)/terms/layout.tsx +++ b/apps/bear/src/app/(flow)/terms/layout.tsx @@ -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 }, }; /** diff --git a/apps/bear/src/app/(landing)/loading.tsx b/apps/bear/src/app/(landing)/loading.tsx deleted file mode 100644 index eb42715..0000000 --- a/apps/bear/src/app/(landing)/loading.tsx +++ /dev/null @@ -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 ( - - - - - - - - - - - - - - ); -} diff --git a/apps/bear/src/app/(main)/analysts/page.tsx b/apps/bear/src/app/(main)/analysts/page.tsx index 0754b2e..46f5fb6 100644 --- a/apps/bear/src/app/(main)/analysts/page.tsx +++ b/apps/bear/src/app/(main)/analysts/page.tsx @@ -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 ( - + ); } diff --git a/apps/bear/src/app/(main)/channels/[username]/loading.tsx b/apps/bear/src/app/(main)/channels/[username]/loading.tsx index 0c3ad06..0e7045e 100644 --- a/apps/bear/src/app/(main)/channels/[username]/loading.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/loading.tsx @@ -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 ( - - - - - + ); diff --git a/apps/bear/src/app/(main)/channels/[username]/not-found.tsx b/apps/bear/src/app/(main)/channels/[username]/not-found.tsx index 768d041..006c488 100644 --- a/apps/bear/src/app/(main)/channels/[username]/not-found.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/not-found.tsx @@ -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 ( - - - - - - ); + return ; } diff --git a/apps/bear/src/app/(main)/channels/[username]/page.tsx b/apps/bear/src/app/(main)/channels/[username]/page.tsx index edacdf2..e629ba8 100644 --- a/apps/bear/src/app/(main)/channels/[username]/page.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/page.tsx @@ -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>; }; -// 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 (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 { 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 ( ); } diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/loading.tsx b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/loading.tsx index 4064449..8556098 100644 --- a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/loading.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/loading.tsx @@ -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 ( - - - - - - - - - - - - - + ); diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/page.tsx b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/page.tsx index 77b9af3..18c93b0 100644 --- a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/page.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/page.tsx @@ -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 (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 { - 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 ( ); } diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx new file mode 100644 index 0000000..744ecaa --- /dev/null +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx @@ -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 ( + <> + + + + + + + + + + + + + + + ); +} diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx index 92e38cb..4f1a5c8 100644 --- a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx @@ -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 ; + + let content: ReactNode; + if (page.status === 'pending') { + content = ; + } else if (page.channel.suspended) { + content = ; + } else if (page.status === 'ok') { + const { channel, post, now } = page; + content = ( + <> + + + + } + /> + + + ); + } else { + content = ; + } return ( @@ -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). */} - - {channel.suspended ? ( - - ) : post ? ( - <> - - - - } - /> - - - ) : ( - - )} + + {content} ); diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts index cde4663..bbd09cb 100644 --- a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts @@ -1,2 +1,3 @@ +export { PostSkeleton } from './PostSkeleton'; export { PostTemplate } from './PostTemplate'; -export type { PostTemplateProps } from './types'; +export type { PostSkeletonProps, PostTemplateProps } from './types'; diff --git a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts index 2a98c6a..4cab66b 100644 --- a/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts +++ b/apps/bear/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts @@ -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; }; diff --git a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx new file mode 100644 index 0000000..e3f64a4 --- /dev/null +++ b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx @@ -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 ( + + + + + + ); +} diff --git a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx new file mode 100644 index 0000000..2d9a35a --- /dev/null +++ b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx @@ -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 ( + <> + + + + + + + ); +} diff --git a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx index 1a4728c..4d60600 100644 --- a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx +++ b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx @@ -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 ( - - - - - - - ); - } + if (page.status === 'not-found') + return ; - const publicChannel = ( - <> - - ; + } else if (channel.suspended) { + // Suspension outranks everything: no header, posts or actions, for anyone (U6 ۵.۳). + content = ( + - } - stats={ - <> - - - - } - > - - - - - } - actions={ - - + ); + } else { + const publicChannel = ( + <> + + - - } - labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))} - verified={!channel.verificationPending} - /> - - } - > - - - - - ); + stats={ + <> + + + + } + > + + + + + } + actions={ + + + + } + labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))} + verified={!channel.verificationPending} + /> + + + } + > + + + + + ); + content = channel.verificationPending ? ( + + {publicChannel} + + ) : ( + publicChannel + ); + } return ( @@ -128,14 +142,8 @@ export function ChannelTemplate({ gap="gap-4" className="w-full max-w-content" > - - {channel.verificationPending ? ( - - {publicChannel} - - ) : ( - publicChannel - )} + + {content} ); diff --git a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/index.ts b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/index.ts index 2c54681..882d356 100644 --- a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/index.ts +++ b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/index.ts @@ -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'; diff --git a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/types.ts b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/types.ts index d2c5bbe..0d9b5a9 100644 --- a/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/types.ts +++ b/apps/bear/src/app/(main)/channels/[username]/templates/channel-template/types.ts @@ -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; }; diff --git a/apps/bull/src/app/(flow)/checkout/[username]/page.tsx b/apps/bull/src/app/(flow)/checkout/[username]/page.tsx index f2acc2f..b373cc3 100644 --- a/apps/bull/src/app/(flow)/checkout/[username]/page.tsx +++ b/apps/bull/src/app/(flow)/checkout/[username]/page.tsx @@ -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 ; + return ; } diff --git a/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx b/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx index 7289815..33cb1b3 100644 --- a/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx +++ b/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/CheckoutTemplate.tsx @@ -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 = ( + } + label={t('checkout.loading')} + /> + ); + } else if (page.status === 'not-found') { + content = ( + + + + ); + } else { + const { channel } = page; + content = ( + + } + creatorName={channel.displayName ?? channel.username} + creatorLinks={channel.socialLinks} + /> + + ); + } return ( - + - - } - creatorName={channel.displayName ?? channel.username} - creatorLinks={channel.socialLinks} - /> - + {content} ); diff --git a/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts b/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts index efd0409..222517b 100644 --- a/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts +++ b/apps/bull/src/app/(flow)/checkout/[username]/templates/checkout-template/types.ts @@ -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; +}; diff --git a/apps/bull/src/app/(flow)/terms/layout.tsx b/apps/bull/src/app/(flow)/terms/layout.tsx index 3bc7f25..08e65ce 100644 --- a/apps/bull/src/app/(flow)/terms/layout.tsx +++ b/apps/bull/src/app/(flow)/terms/layout.tsx @@ -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 }, }; /** diff --git a/apps/bull/src/app/(landing)/loading.tsx b/apps/bull/src/app/(landing)/loading.tsx deleted file mode 100644 index 43b3c72..0000000 --- a/apps/bull/src/app/(landing)/loading.tsx +++ /dev/null @@ -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 ( - - - - - - - - - - - ); -} diff --git a/apps/bull/src/app/(main)/analysts/page.tsx b/apps/bull/src/app/(main)/analysts/page.tsx index 7fb83f1..ba246ef 100644 --- a/apps/bull/src/app/(main)/analysts/page.tsx +++ b/apps/bull/src/app/(main)/analysts/page.tsx @@ -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 ( - + ); } diff --git a/apps/bull/src/app/(main)/channels/[username]/loading.tsx b/apps/bull/src/app/(main)/channels/[username]/loading.tsx index 9cca49e..1470887 100644 --- a/apps/bull/src/app/(main)/channels/[username]/loading.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/loading.tsx @@ -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 ( <> - + - {/* The skeleton draws the header's flush band itself. */} - - - - - + ); diff --git a/apps/bull/src/app/(main)/channels/[username]/not-found.tsx b/apps/bull/src/app/(main)/channels/[username]/not-found.tsx index c96d8d1..0b96530 100644 --- a/apps/bull/src/app/(main)/channels/[username]/not-found.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/not-found.tsx @@ -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 ( - <> - - - - - + ); } diff --git a/apps/bull/src/app/(main)/channels/[username]/page.tsx b/apps/bull/src/app/(main)/channels/[username]/page.tsx index edacdf2..e629ba8 100644 --- a/apps/bull/src/app/(main)/channels/[username]/page.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/page.tsx @@ -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>; }; -// 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 (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 { 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 ( ); } diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/loading.tsx b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/loading.tsx index f8fe67d..339285e 100644 --- a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/loading.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/loading.tsx @@ -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 ( <> - + - - - - - - - - - - - - - + ); diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/page.tsx b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/page.tsx index 77b9af3..18c93b0 100644 --- a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/page.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/page.tsx @@ -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 (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 { - 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 ( ); } diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx new file mode 100644 index 0000000..b339680 --- /dev/null +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostSkeleton.tsx @@ -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 ( + <> + + + + + + + + + + + + + + + ); +} diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx index f4d5ac2..8a41f85 100644 --- a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/PostTemplate.tsx @@ -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 ; + } + + let content: ReactNode; + if (page.status === 'pending') { + content = ; + } else if (page.channel.suspended) { + content = ; + } else if (page.status === 'ok') { + const { channel, post, now } = page; + content = ( + <> + + + + } + /> + + + + + ); + } else { + content = ( + + + + ); + } return ( <> - {channel.suspended ? ( - - ) : post ? ( - <> - - - - } - /> - - - - - ) : ( - - - - )} + {content} ); diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts index cde4663..bbd09cb 100644 --- a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/index.ts @@ -1,2 +1,3 @@ +export { PostSkeleton } from './PostSkeleton'; export { PostTemplate } from './PostTemplate'; -export type { PostTemplateProps } from './types'; +export type { PostSkeletonProps, PostTemplateProps } from './types'; diff --git a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts index 2a98c6a..4cab66b 100644 --- a/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts +++ b/apps/bull/src/app/(main)/channels/[username]/posts/[id]/templates/post-template/types.ts @@ -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; }; diff --git a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx new file mode 100644 index 0000000..6b71e33 --- /dev/null +++ b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelMissing.tsx @@ -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 ( + <> + + + + + + ); +} diff --git a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx new file mode 100644 index 0000000..e79a915 --- /dev/null +++ b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelSkeleton.tsx @@ -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. */} + + + + + + + ); +} diff --git a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx index d6c6cc5..7326c87 100644 --- a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx +++ b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/ChannelTemplate.tsx @@ -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 ; + } + + const channel = page.status === 'ok' ? page.channel : null; + const topBar = ( + + ); + + if (!channel) { + return ( + <> + {topBar} + + + + + ); + } // 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 ( <> - + {topBar} } > - + @@ -125,10 +153,7 @@ export function ChannelTemplate({ return ( <> - + {topBar} {channel.verificationPending ? ( diff --git a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/index.ts b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/index.ts index 2c54681..882d356 100644 --- a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/index.ts +++ b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/index.ts @@ -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'; diff --git a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/types.ts b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/types.ts index d2c5bbe..06efa53 100644 --- a/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/types.ts +++ b/apps/bull/src/app/(main)/channels/[username]/templates/channel-template/types.ts @@ -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; }; diff --git a/docs/decisions/0021-channel-feed-starts-from-the-server-page.md b/docs/decisions/0021-channel-feed-starts-from-the-server-page.md index 70432c2..d6a61a1 100644 --- a/docs/decisions/0021-channel-feed-starts-from-the-server-page.md +++ b/docs/decisions/0021-channel-feed-starts-from-the-server-page.md @@ -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. diff --git a/docs/decisions/0045-channel-read-carries-follower-count.md b/docs/decisions/0045-channel-read-carries-follower-count.md index 282c325..7be24aa 100644 --- a/docs/decisions/0045-channel-read-carries-follower-count.md +++ b/docs/decisions/0045-channel-read-carries-follower-count.md @@ -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). diff --git a/docs/decisions/0055-static-metadata-except-channel-and-post.md b/docs/decisions/0055-static-metadata-except-channel-and-post.md index 7bac403..9030659 100644 --- a/docs/decisions/0055-static-metadata-except-channel-and-post.md +++ b/docs/decisions/0055-static-metadata-except-channel-and-post.md @@ -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. diff --git a/docs/decisions/0070-render-every-page-except-the-landing-in-the-browser.md b/docs/decisions/0070-render-every-page-except-the-landing-in-the-browser.md new file mode 100644 index 0000000..15f9d57 --- /dev/null +++ b/docs/decisions/0070-render-every-page-except-the-landing-in-the-browser.md @@ -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. diff --git a/docs/decisions/0071-index-only-the-landing.md b/docs/decisions/0071-index-only-the-landing.md new file mode 100644 index 0000000..6d75e6a --- /dev/null +++ b/docs/decisions/0071-index-only-the-landing.md @@ -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 `/`. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 1952990..fea1f0b 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -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 ``. -- 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 `-` container with its env folder; `tools/rollback.sh ` 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`. diff --git a/docs/pages/README.md b/docs/pages/README.md index 9044a48..0e34535 100644 --- a/docs/pages/README.md +++ b/docs/pages/README.md @@ -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`) diff --git a/docs/pages/market/analysts.md b/docs/pages/market/analysts.md index d4a7026..54360ec 100644 --- a/docs/pages/market/analysts.md +++ b/docs/pages/market/analysts.md @@ -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 `` 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 `` 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. diff --git a/docs/pages/market/channels-username-posts-id.md b/docs/pages/market/channels-username-posts-id.md index 127998b..3982ce0 100644 --- a/docs/pages/market/channels-username-posts-id.md +++ b/docs/pages/market/channels-username-posts-id.md @@ -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 | `` 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 | `` 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. diff --git a/docs/pages/market/channels-username.md b/docs/pages/market/channels-username.md index 944223b..f3f34ff 100644 --- a/docs/pages/market/channels-username.md +++ b/docs/pages/market/channels-username.md @@ -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 `` and `PartBoundary`; `CreatorStats`, empty when the record isn't public | -| ChannelFeed | `getCreatorPosts(creatorId)` | streamed | hydrate | primary | own `` and `PartBoundary`; an `` 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 `