corrected misindex issue

This commit is contained in:
Paul Wilde 2024-10-16 15:03:08 +01:00
parent 69af1f42c6
commit 0c53b754f3
3 changed files with 6 additions and 1 deletions

Binary file not shown.

View file

@ -41,6 +41,7 @@ proc createRouter(): Router =
router.get("/", pageHandler)
router.get("/new/*", pageHandler)
router.get("/video.*/*", videoHandler)
router.get("/video.*/*/*", videoHandler)
router.get("/video.*/*/*/*", videoHandler)
router.get("/favicon.ico", staticFileHandler)
router.get("/favicon.png", staticFileHandler)

View file

@ -103,7 +103,11 @@ proc compilePage(content: string, video_uri: string = "", search_query: string =
var
vid_url, vid_thumb: string
vid_url = url.replace("THUMBNUM","0")
vid_thumb = thumbs[idx].replace("THUMBNUM","1")
if thumbs.len > idx:
vid_thumb = thumbs[idx].replace("THUMBNUM","1")
else:
vid_url = url.replace("THUMBNUM","1")
vid_thumb = thumbs[^1].replace("THUMBNUM","1")
let title = vid_url.split("/")[^1].replace("_"," ")
page &= fmt"""<div><a href="{vid_url}"><img src="{vid_thumb}"/><br/>{title}</a></div>"""
page &= "</section>"