Files
2026-01-06 18:23:50 +02:00

32 lines
816 B
Python

from pathlib import Path
def load_slides(root_path):
shots_dir = Path(root_path) / "static" / "img" / "screenshots"
if not shots_dir.exists():
return []
slides = []
for path in shots_dir.iterdir():
if not path.is_file():
continue
if path.suffix.lower() not in {".png", ".jpg", ".jpeg", ".webp", ".gif"}:
continue
stem = path.stem
num = int(stem) if stem.isdigit() else None
slides.append(
{
"filename": f"img/screenshots/{path.name}",
"key": stem,
"num": num,
}
)
slides.sort(
key=lambda item: (
item["num"] is None,
item["num"] if item["num"] is not None else item["key"],
)
)
return slides