Files
buzz-sheet/lib/guides/publication.ts
T
gunshiz 9896e8a4ad
CI / Verify (push) Successful in 1m35s
CI / Build immutable images and deploy (push) Successful in 5m27s
feat(guides) : add safer publishing and discovery
2026-09-19 13:32:57 +07:00

21 lines
1002 B
TypeScript

export interface PublicationCheckInput {
exists: boolean;
overview: string;
coverReady: boolean;
catalogVersion: string | null;
renderableSectionCount: number;
version: number;
expectedVersion: number;
}
export function publicationIssues(input: PublicationCheckInput): string[] {
if (!input.exists) return ["ไม่พบ Guide"];
const issues: string[] = [];
if (!input.overview.trim()) issues.push("กรุณากรอก Overview");
if (!input.coverReady) issues.push("รูปปกยังไม่พร้อมใช้งาน");
if (!input.catalogVersion) issues.push("กรุณา Sync Catalog ก่อนเผยแพร่");
if (input.renderableSectionCount === 0) issues.push("กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section");
if (input.version !== input.expectedVersion) issues.push("Guide ถูกแก้ไขแล้ว กรุณาลองใหม่");
return issues;
}