Files
anwar-pi-website/web/src/lib/format.ts
T
AHMED 0161924088 Free early-access launch: LAUNCH_MODE policy, CRO, pipeline hardening, AI-SEO, ops
- launch.ts policy: LAUNCH_MODE=free_early_access default; effective access =
  published && (free || early); intended tier (access) never rewritten
- Billing off server-side: /api/subscribe 503 honest copy; subscribe CTAs
  render disabled 'قريباً' from first paint; /subscription early-access panel
  + /api/notify (LaunchNotifications) with honest 503 when mail transport off
- Signup trust: verification email at signup (Users afterChange), no
  confirm-password, 429 message fidelity, typo suggestion, live password hint
- Agent pipeline: pickFields strips access/readingMinutes, sourceId dedup,
  secret-scan 422 (pattern names only), string-content rejected (was silently
  replaced), publish stays explicit opt-in
- lexical.ts: root unwrap fix — lexicalToText/countLexicalWords returned 0
  for real serialized trees (secret scan + readingMinutes were inert)
- llms-full.txt: fetchIndexDocs(true) — bodies were never selected
- Content honesty: contentType/authorName/sourceId fields + migration,
  readingMinutes computed at write (160 wpm) + backfill script, byline,
  'حُدّث' freshness
- SEO/AI-SEO: metadata rewrite (published-only, og:image 1200x630), Article +
  BreadcrumbList + FAQPage + Organization JSON-LD, isAccessibleForFree honest,
  table renderer, robots AI-crawler policy (10 named bots), llms.txt +
  llms-full.txt, /topics/* hubs + sitemap, noindex auth pages, www 301
- Ops: backup-db.sh (restore rehearsed on VPS), docs copies (launch
  readiness + marketing audit + owner-inputs for L-03), GLOSSARY.md entries

Verified: tsc --noEmit 0, npm run build 0, local smoke (ghost VIP read,
subscribe/notify/agent APIs, signup token, 429 on 6th, llms/topics/sitemap,
og:image/JSON-LD)
2026-10-10 18:03:45 +03:00

41 lines
1.7 KiB
TypeScript

/* Western digits everywhere for consistency with reading times, prices and code. */
const dateFormat = new Intl.DateTimeFormat('ar-u-nu-latn', { day: 'numeric', month: 'long', year: 'numeric' })
const numberFormat = new Intl.NumberFormat('en-US')
export function formatDate(value: string | Date | null | undefined): string {
if (!value) return ''
const date = value instanceof Date ? value : new Date(value)
return Number.isNaN(date.getTime()) ? '' : dateFormat.format(date)
}
export const formatNumber = (value: number | null | undefined) => numberFormat.format(value ?? 0)
/* Single source for the displayed membership price. */
export const MEMBERSHIP_PRICE = '$10'
/* Arabic count agreement for «دليل»: 1 دليل، 2 دليلان، 3–10 أدلة، 11+ دليلاً. */
export function guidesLabel(n: number): string {
if (n === 0) return 'لا أدلة'
if (n === 1) return 'دليل واحد'
if (n === 2) return 'دليلان'
return `${formatNumber(n)} ${n <= 10 ? 'أدلة' : 'دليلاً'}`
}
export function minutesLabel(n: number | null | undefined): string {
const value = n ?? 0
if (value === 1) return 'دقيقة واحدة'
if (value === 2) return 'دقيقتان'
return `${formatNumber(value)} ${value % 100 >= 3 && value % 100 <= 10 ? 'دقائق' : 'دقيقة'}`
}
/* Content-type badge labels (L-09). Null for unset/unknown — no byline invented. */
export function contentTypeLabel(value: string | null | undefined): string | null {
switch (value) {
case 'note': return 'ملاحظة تقنية'
case 'tutorial': return 'دليل عملي'
case 'case_study': return 'تجربة موثقة'
case 'comparison': return 'مقارنة'
default: return null
}
}