File
Blob: src/shared/page-cover.ts
| 1 | export const GRADIENT_PRESETS = [ |
| 2 | "linear-gradient(135deg, #5e3497 0%, #2a2729 100%)", |
| 3 | "linear-gradient(135deg, #4d2a7c 0%, #1b181a 100%)", |
| 4 | "linear-gradient(135deg, #423f42 0%, #2a2729 100%)", |
| 5 | "linear-gradient(135deg, #7241b8 0%, #423f42 100%)", |
| 6 | "linear-gradient(135deg, #2a2729 0%, #5e3497 50%, #2a2729 100%)", |
| 7 | "linear-gradient(135deg, #3d2d4a 0%, #1b181a 100%)", |
| 8 | "linear-gradient(135deg, #2a2729 0%, #352530 100%)", |
| 9 | "linear-gradient(135deg, #423f42 0%, #3d2d4a 50%, #2a2729 100%)", |
| 10 | "linear-gradient(135deg, #8854d4 0%, #2a2729 100%)", |
| 11 | "linear-gradient(135deg, #1b181a 0%, #423f42 100%)", |
| 12 | "linear-gradient(135deg, #352530 0%, #423f42 100%)", |
| 13 | "linear-gradient(135deg, #2a2729 0%, #4d2a7c 50%, #1b181a 100%)", |
| 14 | ] as const; |
| 15 | |
| 16 | export type GradientPreset = (typeof GRADIENT_PRESETS)[number]; |
| 17 | |
| 18 | const GRADIENT_PRESET_SET = new Set<string>(GRADIENT_PRESETS); |
| 19 | const UPLOAD_COVER_URL = /^\/uploads\/([A-Za-z0-9_-]+)$/; |
| 20 | |
| 21 | export function isGradientPreset(value: string): value is GradientPreset { |
| 22 | return GRADIENT_PRESET_SET.has(value); |
| 23 | } |
| 24 | |
| 25 | export function parseUploadCoverUrl(coverUrl: string): string | null { |
| 26 | return UPLOAD_COVER_URL.exec(coverUrl)?.[1] ?? null; |
| 27 | } |