mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 16:47:46 +00:00
feat: sửa poster dọc ngang ở home
This commit is contained in:
+26
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user