Update hash removal pattern

This commit is contained in:
thiloho
2025-04-27 11:01:21 +02:00
parent a4c4a17bfb
commit 3606edd967

View File

@@ -8,18 +8,20 @@ const albumCovers = await Astro.glob("../content/album-covers/*");
const processedAlbumCovers = albumCovers.map((cover) => {
const filePathWithoutParams = cover.default.src.split("?")[0];
let filename = parse(filePathWithoutParams).name;
const lastDotIndex = filename.lastIndexOf(".");
if (lastDotIndex !== -1) {
filename = filename.substring(0, lastDotIndex);
}
const filename = parse(filePathWithoutParams).name;
const lastDashIndex = filename.lastIndexOf(" - ");
const artists =
lastDashIndex !== -1 ? filename.substring(0, lastDashIndex) : filename;
const title =
lastDashIndex !== -1 ? filename.substring(lastDashIndex + 3) : "";
let title = lastDashIndex !== -1 ? filename.substring(lastDashIndex + 3) : "";
const lastDotIndex = title.lastIndexOf(".");
if (lastDotIndex !== -1 && import.meta.env.PROD) {
title = filename.substring(0, lastDotIndex);
}
return { cover, filename, artists, title };
});