feat: sửa poster dọc ngang ở home

This commit is contained in:
ngthanhvu
2026-07-30 21:38:01 -04:00
parent 310b1d0949
commit 2ab5766e02
4 changed files with 210 additions and 136 deletions
+26 -2
View File
@@ -11,15 +11,39 @@ function extractEpisodeNumber(value?: string): number {
export function getEpisodeDisplay(
episode?: string,
episodeTotal?: string,
prefix = 'Tập',
): string | undefined {
if (!episode) return undefined
const trimmed = episode.trim()
// "Hoàn tất" status
if (/hoan.t|hoàn.t/.test(trimmed)) {
return 'Hoàn tất'
}
// Extract "X/Y" pattern anywhere in the string (with or without spaces)
const slashMatch = trimmed.match(/(\d+)\s*\/\s*(\d+)/)
if (slashMatch) {
const epNum = Number(slashMatch[1])
const totalNum = Number(slashMatch[2])
if (epNum > 0 && totalNum > 0 && epNum < totalNum) {
return `${prefix} ${epNum}/${totalNum}`
}
return `${prefix} ${totalNum}`
}
// Single number
const totalNum = extractEpisodeNumber(episodeTotal)
const epNum = extractEpisodeNumber(episode)
if (totalNum > 0 && epNum > 0 && epNum !== totalNum) {
return `Tập ${epNum}/${totalNum}`
return `${prefix} ${epNum}/${totalNum}`
}
return episode
if (epNum > 0) {
return `${prefix} ${epNum}`
}
return trimmed
}