feat: media & music file name
This commit is contained in:
@@ -19,6 +19,16 @@ export function formatDuration(seconds?: number | null): string {
|
||||
return toFa(`${m}:${String(s).padStart(2, "0")}`);
|
||||
}
|
||||
|
||||
// Derive a clean title from an uploaded file name: drop the extension and turn
|
||||
// underscores/dashes into spaces (e.g. "morning_calm-01.mp3" -> "morning calm 01").
|
||||
export function fileNameToTitle(name: string): string {
|
||||
return name
|
||||
.replace(/\.[^./\\]+$/, "")
|
||||
.replace(/[_-]+/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
// Minutes -> Persian label. Media and music store `duration` in minutes.
|
||||
export function formatMinutes(minutes?: number | null): string {
|
||||
if (minutes === null || minutes === undefined) return "—";
|
||||
|
||||
Reference in New Issue
Block a user