Guest publishes remain share-by-link but stay out of the catalog and sitemap, and their pages send noindex until claimed. The published-rule view now uses heading and list markup matching Markdown export, and top banners sit below the header so Share is not covered. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
960 B
TypeScript
25 lines
960 B
TypeScript
import type { Prisma } from "@prisma/client";
|
|
|
|
/**
|
|
* Access model for published CommunityRules:
|
|
*
|
|
* - **Readable without sign-in:** every published row is share-by-link at
|
|
* `/rules/[id]` and `GET /api/rules/[id]`.
|
|
* - **Listed** (public catalog `GET /api/rules`, sitemap, indexable): owned
|
|
* rows, and ownerless rows that are *not* waiting on a guest claim
|
|
* (including rules orphaned when an account is deleted).
|
|
* - **Unlisted** (omitted from the catalog and sitemap, `noindex`): guest
|
|
* publishes with `userId` null and `claimTokenHash` set, until claimed.
|
|
*/
|
|
export function isListedPublishedRule(row: {
|
|
userId: string | null;
|
|
claimTokenHash: string | null;
|
|
}): boolean {
|
|
return row.userId != null || row.claimTokenHash == null;
|
|
}
|
|
|
|
/** Prisma `where` for the public catalog and sitemap. */
|
|
export const LISTED_PUBLISHED_RULE_WHERE: Prisma.PublishedRuleWhereInput = {
|
|
OR: [{ userId: { not: null } }, { claimTokenHash: null }],
|
|
};
|