feat: update creator route

This commit is contained in:
Amiram_se 2026-10-16 15:30:43 +04:00
parent 73eb571530
commit d31903b4c0
34 changed files with 90 additions and 103 deletions

View File

@ -48,10 +48,6 @@ const nextConfig: NextConfig = {
'@lumina/libs',
'@lumina/tools',
],
// `/@{username}` is the public channel URL. A folder named `@…` is a
// parallel-route slot in the App Router, so the routes live under
// `channels/[username]` and the public URL is rewritten onto them.
//
// The browser calls the API on this site's origin (`/api/v1/…`, `/api/files/…`), and the API
// calls are proxied to the gateway, so there is no CORS and the session cookies are this site's
// (0018).
@ -61,10 +57,6 @@ const nextConfig: NextConfig = {
source: `${API_PROXY_PATH}/:path*`,
destination: `${apiInternalUrl()}/:path*`,
},
{
source: '/@:username/:path*',
destination: '/channels/:username/:path*',
},
];
},
async headers() {
@ -86,12 +78,13 @@ const nextConfig: NextConfig = {
},
];
},
// One canonical URL per channel: send direct `/channels/…` hits to `/@…`.
// A channel lives at `/channels/username` only (0064). Links people kept or were sent as
// `/@username` (the old address, still in SMS and notifications) move there for good, query kept.
async redirects() {
return [
{
source: '/channels/:username/:path*',
destination: '/@:username/:path*',
source: '/@:username/:path*',
destination: '/channels/:username/:path*',
permanent: true,
},
];

View File

@ -42,9 +42,9 @@ export async function generateMetadata({
}
/**
* A creator's channel, `/@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`. 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.
*/
export default async function ChannelPage({
params,

View File

@ -58,9 +58,9 @@ export async function generateMetadata({
}
/**
* One post, `/@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. 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.
*/
export default async function PostPage({ params }: PostPageProps) {
const { username: segment, id } = await params;

View File

@ -5,7 +5,7 @@ export type PostTemplateProps = {
channel: PublicCreatorPayload;
/** `null`: deleted, unknown, or another channel's. */
post: PostPayload | null;
/** «lumina.ir/@sara_gold», for the guest's login prompt. */
/** «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;

View File

@ -2,7 +2,7 @@ import type { PublicCreatorPayload } from '@lumina/market/features/channel';
export type ChannelTemplateProps = {
channel: PublicCreatorPayload;
/** «lumina.ir/@sara_gold». */
/** «lumina.ir/channels/sara_gold». */
channelUrl: string;
/** The render's time: the posts' relative times count from it. */
now: string;

View File

@ -1,6 +1,9 @@
import { clientEnv } from '../env';
/** A path on this site as people read and type it, without the scheme: «lumina.ir/@sara_gold». */
/**
* A path on this site as people read and type it, without the scheme:
* «lumina.ir/channels/sara_gold».
*/
export function displayUrl(path: string): string {
return `${new URL(clientEnv.NEXT_PUBLIC_SITE_URL).host}${path}`;
}

View File

@ -48,10 +48,6 @@ const nextConfig: NextConfig = {
'@lumina/libs',
'@lumina/tools',
],
// `/@{username}` is the public channel URL. A folder named `@…` is a
// parallel-route slot in the App Router, so the routes live under
// `channels/[username]` and the public URL is rewritten onto them.
//
// The browser calls the API on this site's origin (`/api/v1/…`, `/api/files/…`), and the API
// calls are proxied to the gateway, so there is no CORS and the session cookies are this site's
// (0018).
@ -61,10 +57,6 @@ const nextConfig: NextConfig = {
source: `${API_PROXY_PATH}/:path*`,
destination: `${apiInternalUrl()}/:path*`,
},
{
source: '/@:username/:path*',
destination: '/channels/:username/:path*',
},
];
},
async headers() {
@ -86,12 +78,13 @@ const nextConfig: NextConfig = {
},
];
},
// One canonical URL per channel: send direct `/channels/…` hits to `/@…`.
// A channel lives at `/channels/username` only (0064). Links people kept or were sent as
// `/@username` (the old address, still in SMS and notifications) move there for good, query kept.
async redirects() {
return [
{
source: '/channels/:username/:path*',
destination: '/@:username/:path*',
source: '/@:username/:path*',
destination: '/channels/:username/:path*',
permanent: true,
},
];

View File

@ -42,9 +42,9 @@ export async function generateMetadata({
}
/**
* A creator's channel, `/@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`. 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.
*/
export default async function ChannelPage({
params,

View File

@ -58,9 +58,9 @@ export async function generateMetadata({
}
/**
* One post, `/@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. 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.
*/
export default async function PostPage({ params }: PostPageProps) {
const { username: segment, id } = await params;

View File

@ -5,7 +5,7 @@ export type PostTemplateProps = {
channel: PublicCreatorPayload;
/** `null`: deleted, unknown, or another channel's. */
post: PostPayload | null;
/** «lumina.ir/@sara_gold», for the guest's login prompt. */
/** «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;

View File

@ -2,7 +2,7 @@ import type { PublicCreatorPayload } from '@lumina/market/features/channel';
export type ChannelTemplateProps = {
channel: PublicCreatorPayload;
/** «lumina.ir/@sara_gold». */
/** «lumina.ir/channels/sara_gold». */
channelUrl: string;
/** The render's time: the posts' relative times count from it. */
now: string;

View File

@ -1,6 +1,9 @@
import { clientEnv } from '../env';
/** A path on this site as people read and type it, without the scheme: «lumina.ir/@sara_gold». */
/**
* A path on this site as people read and type it, without the scheme:
* «lumina.ir/channels/sara_gold».
*/
export function displayUrl(path: string): string {
return `${new URL(clientEnv.NEXT_PUBLIC_SITE_URL).host}${path}`;
}

View File

@ -0,0 +1,17 @@
# 0064 Channels live at /channels/username
Status: Accepted · Area: architecture · Date: 2026-10-16 · Decided by: user
## Context
The public channel URL was `/@username`, rewritten onto `channels/[username]` because an `@…` folder is a parallel-route slot, with `/channels/…` redirected back to `/@…`. The user chose to stop handling «@» in the path.
## Decision
- A channel and its pages live at `/channels/username` (`/posts/[id]`, `/track-record`), the canonical URL. Build links only with `ROUTES.channel`, `ROUTES.post` and `ROUTES.trackRecord`.
- `next.config.ts` in bull and bear permanently redirects `/@:username/:path*` to `/channels/:username/:path*`, keeping the query (`?code=`). This is the only place «@» is read.
- A username segment is never stripped of a leading «@»: `/channels/@user` and `/checkout/@user` are 404.
## Alternatives
- Keep `/@username` with the rewrite: shorter to type and share, but two spellings of each channel to keep in step.
## Consequences
Search engines move the old URLs over through the 308. The back end still builds `/@username` links (SMS, notifications, admin invite URLs); they work through the redirect until changed there. Records 0044, 0055 and 0059 still name the old form.

View File

@ -25,6 +25,7 @@
- 0059 Checkout and the channel save `?code=` into the per-creator checkout draft on arrival; checkout then strips it from the URL.
- 0060 Composers send a creator who can't publish to their own channel with the locked dialog; every publish carries a stable `Idempotency-Key`.
- 0061 Build the admin panel as `apps/wall-street-plaza` with `platforms/garden-roof`, tagged `scope:admin`; it calls only the back end's `admin-api`, through its own `/api` rewrite.
- 0064 Serve a channel at `/channels/username`, built only through `ROUTES`; both apps 308-redirect `/@username/…` there, and no other code reads «@» in a path.
## Proposed

View File

@ -154,7 +154,7 @@ type PostCardBaseProps = {
onCopyLink?: () => void;
/**
* The post's link as the desktop share popover shows it, without the scheme:
* `lumina.ir/@sara_gold/posts/1042`. Read in the browser; only an open popover shows it.
* `lumina.ir/channels/sara_gold/posts/1042`. Read in the browser; only an open popover shows it.
*/
shareUrl?: string;
/**

View File

@ -1,7 +1,6 @@
import {
ACCOUNT_PATH,
CHANNEL_PREFIX,
CHANNEL_ROUTE_PREFIX,
DASHBOARD_PATH,
NOTIFICATIONS_PATH,
SEARCH_PATH,
@ -12,17 +11,12 @@ import type { NavTabName } from './types';
const isUnder = (pathname: string, path: string): boolean =>
pathname === path || pathname.startsWith(`${path}/`);
/**
* The creator's own channel or a page under it, by its public path or the route it is rewritten
* onto, depending on who reads it.
*/
/** The creator's own channel or a page under it. */
export function isOwnChannelPath(
pathname: string,
ownUsername: string,
): boolean {
return [CHANNEL_PREFIX, CHANNEL_ROUTE_PREFIX].some((prefix) =>
isUnder(pathname, `${prefix}${ownUsername}`),
);
return isUnder(pathname, `${CHANNEL_PREFIX}${ownUsername}`);
}
/**

View File

@ -1,8 +1,5 @@
/** The public channel URL prefix; next.config rewrites `/@username` onto `channels/[username]`. */
export const CHANNEL_PREFIX = '/@';
/** The App Router's own path for a channel, which `/@username` is rewritten onto. */
export const CHANNEL_ROUTE_PREFIX = '/channels/';
/** A channel's path prefix: `/channels/username` (0064). */
export const CHANNEL_PREFIX = '/channels/';
/**
* `?locked=post|prediction` on a creator's own channel: a composer they may not use sent them here,

View File

@ -17,7 +17,7 @@ import type { ChannelNotFoundProps } from './types';
function typedUsername(segment: string | undefined): string {
if (!segment) return '';
try {
return decodeURIComponent(segment).replace(/^@/, '');
return decodeURIComponent(segment);
} catch {
return segment;
}

View File

@ -4,26 +4,19 @@ import {
useCurrentAccount,
useViewerStatus,
} from '../../../../../../../../stores/auth';
import {
CHANNEL_PREFIX,
CHANNEL_ROUTE_PREFIX,
} from '../../../../../../../navigation/constants';
import { CHANNEL_PREFIX } from '../../../../../../../navigation/constants';
import type { OwnAddress } from '../types';
/** The username an address names, whichever form the router reports it in. */
/** The username an address names. */
function usernameIn(pathname: string): string | null {
for (const prefix of [CHANNEL_PREFIX, CHANNEL_ROUTE_PREFIX]) {
if (pathname.startsWith(prefix)) {
const segment = pathname.slice(prefix.length).split('/')[0];
// A malformed escape names no channel anyone owns.
try {
return decodeURIComponent(segment).toLowerCase();
} catch {
return null;
}
}
if (!pathname.startsWith(CHANNEL_PREFIX)) return null;
const segment = pathname.slice(CHANNEL_PREFIX.length).split('/')[0];
// A malformed escape names no channel anyone owns.
try {
return decodeURIComponent(segment).toLowerCase();
} catch {
return null;
}
return null;
}
/**

View File

@ -4,7 +4,7 @@ export type ChannelShareProps = {
/** The creator's account id: they get the caption sheet, everyone else the link. */
creatorId: string;
username: string;
/** «lumina.ir/@sara_gold», shown read-only in the creator's sheet. */
/** «lumina.ir/channels/sara_gold», shown read-only in the creator's sheet. */
channelUrl: string;
/** mobile: share sheets and a bottom sheet. desktop: copying and a popover. */
layout: 'mobile' | 'desktop';

View File

@ -5,7 +5,7 @@ export type ChannelUnavailableProps = {
context: 'channel' | 'post';
/** The channel page passes it, so its own creator sees their suspended tab (C6 ۱.۳). */
channel?: PublicCreatorPayload;
/** «lumina.ir/@sara_gold». */
/** «lumina.ir/channels/sara_gold». */
channelUrl?: string;
layout?: 'mobile' | 'desktop';
};

View File

@ -1,8 +1,4 @@
import {
ACCOUNT_PATH,
CHANNEL_PREFIX,
CHANNEL_ROUTE_PREFIX,
} from '../../../navigation/constants';
import { ACCOUNT_PATH, CHANNEL_PREFIX } from '../../../navigation/constants';
import { ROUTES } from '../../../navigation/navigation';
import { TAB_BARS } from './constants';
import type { PageBar } from './types';
@ -12,10 +8,7 @@ export function pageBar(pathname: string): PageBar {
if (pathname === ROUTES.landing) return { kind: 'root' };
const tab = TAB_BARS[pathname];
if (tab) return tab;
if (
pathname.startsWith(CHANNEL_PREFIX) ||
pathname.startsWith(CHANNEL_ROUTE_PREFIX)
) {
if (pathname.startsWith(CHANNEL_PREFIX)) {
return { kind: 'pushed', title: 'nav.channel' };
}
if (pathname === ACCOUNT_PATH || pathname.startsWith(`${ACCOUNT_PATH}/`)) {

View File

@ -14,7 +14,7 @@ function clip(text: string, max: number): string {
return `${(space > max / 2 ? cut.slice(0, space) : cut).trimEnd()}…`;
}
/** A channel's title, description, canonical `/@username` and profile card. */
/** A channel's title, description, canonical `/channels/username` and profile card. */
export function channelMetadata({
channel,
title,

View File

@ -7,8 +7,8 @@ import type { PublicCreatorPayload } from '../repositories/channel';
import { getPublicTiers } from './public-tiers';
/**
* The channel at `/@username`, once per render per username: the page and its metadata share one
* request. Pass the username as the API stores it (no «@», lower case). 404 reaches the caller.
* The channel at `/channels/username`, once per render per username: the page and its metadata
* share one request. Pass the username as the API stores it (lower case). 404 reaches the caller.
* It carries the public follower count for the header (a failed count is left to the browser) and
* whether anything can be bought (J05-1g): an approved creator with a priced tier. Failed tiers
* leave the sale open, so checkout decides.

View File

@ -1,14 +1,14 @@
export type ShareLinkArgs = {
/** What is shared: it picks the copied toast. */
kind: 'channel' | 'post';
/** A path on this site: `/@sara_gold`, `/@sara_gold/posts/…`. */
/** A path on this site: `/channels/sara_gold`, `/channels/sara_gold/posts/…`. */
path: string;
/** Mobile: the device's share sheet when it has one. Desktop: copy the link. */
native: boolean;
};
export type UseChannelShareSheetOptions = {
/** The channel's path on this site: `/@sara_gold`. */
/** The channel's path on this site: `/channels/sara_gold`. */
path: string;
/** Mobile: «اشتراک‌گذاری» hands caption and link to the device's share sheet. */
native: boolean;

View File

@ -5,8 +5,8 @@ const subscribe = () => () => undefined;
/**
* A path on this site as a share popover shows it, the host and the path without the scheme:
* `lumina.ir/@sara_gold/posts/1042`, the address `useShareLink` copies. Undefined in the server
* render, which can't know the host the visitor uses.
* `lumina.ir/channels/sara_gold/posts/1042`, the address `useShareLink` copies. Undefined in the
* server render, which can't know the host the visitor uses.
*/
export function useDisplayLink(path: string): string | undefined {
const host = useSyncExternalStore(

View File

@ -20,5 +20,5 @@ export const PAYMENT_POLL_MS = 2_000;
*/
export const PAYMENT_CONFIRM_TIMEOUT_MS = 30_000;
/** An invite link's query parameter: `/@username?code=REZA-2024` (J06-1b). */
/** An invite link's query parameter: `/channels/username?code=REZA-2024` (J06-1b). */
export const INVITE_CODE_PARAM = 'code';

View File

@ -9,8 +9,8 @@ import { INVITE_CODE_PARAM } from '../../constants';
import type { InviteLinkModel } from './types';
/**
* A channel opened from an invite link (`/@username?code=…`, J06-1b/1c): the code is kept for
* this creator, across a detour and a guest's login, until a paid subscription to them. It is
* A channel opened from an invite link (`/channels/username?code=…`, J06-1b/1c): the code is kept
* for this creator, across a detour and a guest's login, until a paid subscription to them. It is
* never shown or checked here; checkout applies it. Checkout reads its own `?code=` the same way
* and then strips it (0059); the channel's link keeps it, as the creator shared it.
*/

View File

@ -16,5 +16,5 @@ export const CAPACITY_NOTE_MAX_LENGTH = 200;
/** How long «درخواست شما تأیید شد» stays on the card after the team's decision (J10-2g). */
export const CAPACITY_APPROVED_SHOW_DAYS = 7;
/** The query parameter the shared channel link carries the code in: `/@username?code=…`. */
/** The query parameter the shared channel link carries the code in: `/channels/username?code=…`. */
export const REFERRAL_CODE_PARAM = 'code';

View File

@ -84,9 +84,9 @@ export type InviteCodePartModel = {
/** `null` before approval: the creator has no code yet, so there is no card (J10-1e). */
card: ReferralCardPayload | null;
view: InviteCodeView;
/** The shared link with the code: `https://lumina.ir/@user?code=…`. */
/** The shared link with the code: `https://lumina.ir/channels/user?code=…`. */
link: string;
/** The link as people read it, without the scheme: `lumina.ir/@user?code=…`. */
/** The link as people read it, without the scheme: `lumina.ir/channels/user?code=…`. */
displayLink: string;
/** A request waits for the team: its banner replaces «درخواست افزایش ظرفیت» (J10-2f). */
isRequestPending: boolean;

View File

@ -68,8 +68,8 @@ function outcomeOf(
/**
* طرح‌های اشتراک › «کد دعوت» (J10-2): the creator's code with copy, its capacity, and the channel
* link that carries it (`/@username?code=…`, from the site's configured address) to share or copy.
* A full code stays shareable and can ask the team for more seats, and shows the team's answer
* link that carries it (`/channels/username?code=…`, from the site's configured address) to share
* or copy. A full code stays shareable and can ask the team for more seats, and shows the team's answer
* (2g, 2h); with no priced plan the card is dimmed and frozen (J10-1d); an admin's switch-off
* keeps it readable with the reason (2i). The capacity is set by the Lumina team only. Browser only.
*/

View File

@ -29,7 +29,7 @@ export type CapacityRequestPayload = {
/** What the «کد دعوت» card shows (J10-2). */
export type ReferralCardPayload = {
code: string;
/** For the link `/@{username}?code={code}`; `null` when the profile has none. */
/** For the link `/channels/{username}?code={code}`; `null` when the profile has none. */
username: string | null;
used: number;
maxUses: number;

View File

@ -3,8 +3,8 @@ import * as v from 'valibot';
import { usernameSchema } from '../validations';
/**
* A channel URL's username segment as the API stores it: decoded, without a leading «@», in lower
* case. `null` when it can't be a username, so the page answers 404 without asking the API.
* A channel URL's username segment as the API stores it: decoded, in lower case. `null` when it
* can't be a username, so the page answers 404 without asking the API.
*/
export function toChannelUsername(segment: string): string | null {
let decoded: string;
@ -13,6 +13,6 @@ export function toChannelUsername(segment: string): string | null {
} catch {
return null;
}
const parsed = v.safeParse(usernameSchema, decoded.trim().replace(/^@/, ''));
const parsed = v.safeParse(usernameSchema, decoded.trim());
return parsed.success ? parsed.output : null;
}

View File

@ -28,8 +28,8 @@ export type PaymentSettlement = {
export type CheckoutDraftState = {
draft: CheckoutDraft | null;
/**
* Invite codes that came with an invite link (`/@username?code=…`) or a checkout link
* (`/checkout/@username?code=…`, 0059), by the creator's account id, until a paid subscription to
* Invite codes that came with an invite link (`/channels/username?code=…`) or a checkout link
* (`/checkout/username?code=…`, 0059), by the creator's account id, until a paid subscription to
* that creator or logout. Never shown or checked on the channel.
*/
inviteCodes: Record<string, string>;