Improve video title display by separating artist and song
Refactors the video card component to use a new utility function for parsing video titles, accurately separating artist and song information for improved display. Adds `client/src/lib/title-parser.ts`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 45a1dcfc-f8a2-475a-a6b9-96fbb841dc27 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/45a1dcfc-f8a2-475a-a6b9-96fbb841dc27/cSLTj2G
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Utility to parse video titles into artist and song parts
|
||||
* Handles various dash characters: hyphen (-), en dash (–), em dash (—)
|
||||
*/
|
||||
|
||||
export interface ParsedTitle {
|
||||
artist: string;
|
||||
song: string;
|
||||
}
|
||||
|
||||
export function parseArtistTitle(title: string): ParsedTitle {
|
||||
// Match various dash types with optional spaces
|
||||
const dashRegex = /\s*[-–—]\s*/;
|
||||
const parts = title.split(dashRegex);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
// Found a delimiter - split into artist and song
|
||||
const artist = parts[0].trim();
|
||||
const song = parts.slice(1).join(' - ').trim(); // Rejoin if multiple dashes
|
||||
|
||||
return {
|
||||
artist: artist || 'video.folx.tv',
|
||||
song: song || title
|
||||
};
|
||||
}
|
||||
|
||||
// No delimiter found - use full title as artist, empty song
|
||||
return {
|
||||
artist: title || 'video.folx.tv',
|
||||
song: ''
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user