mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 02:11:35 +01:00
Update hash removal pattern
This commit is contained in:
@@ -7,19 +7,17 @@ const albumCovers = await Astro.glob("../content/album-covers/*");
|
|||||||
|
|
||||||
const processedAlbumCovers = albumCovers.map((cover) => {
|
const processedAlbumCovers = albumCovers.map((cover) => {
|
||||||
const filePathWithoutParams = cover.default.src.split("?")[0];
|
const filePathWithoutParams = cover.default.src.split("?")[0];
|
||||||
|
|
||||||
const filename = parse(filePathWithoutParams).name;
|
const filename = parse(filePathWithoutParams).name;
|
||||||
|
|
||||||
const lastDashIndex = filename.lastIndexOf(" - ");
|
const lastDashIndex = filename.lastIndexOf(" - ");
|
||||||
|
|
||||||
const artists =
|
let artists =
|
||||||
lastDashIndex !== -1 ? filename.substring(0, lastDashIndex) : filename;
|
lastDashIndex !== -1 ? filename.substring(0, lastDashIndex) : filename;
|
||||||
|
|
||||||
let title = lastDashIndex !== -1 ? filename.substring(lastDashIndex + 3) : "";
|
let title = lastDashIndex !== -1 ? filename.substring(lastDashIndex + 3) : "";
|
||||||
|
|
||||||
if (import.meta.env.PROD) {
|
if (import.meta.env.PROD) {
|
||||||
const lastDotIndex = filename.lastIndexOf(".");
|
title = title.replace(/\..{8}$/, "");
|
||||||
title = lastDotIndex !== -1 ? filename.substring(0, lastDotIndex) : "";
|
artists = artists.replaceAll("_", ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
return { cover, filename, artists, title };
|
return { cover, filename, artists, title };
|
||||||
@@ -46,7 +44,7 @@ const sortedAlbumCovers = processedAlbumCovers.sort((a, b) =>
|
|||||||
sortedAlbumCovers.map(({ cover, filename, artists, title }) => (
|
sortedAlbumCovers.map(({ cover, filename, artists, title }) => (
|
||||||
<figure>
|
<figure>
|
||||||
<a
|
<a
|
||||||
href={`https://music.youtube.com/search?q=${encodeURIComponent(filename)}`}
|
href={`https://music.youtube.com/search?q=${encodeURIComponent(`${title} - ${artists}`)}`}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={cover.default}
|
src={cover.default}
|
||||||
|
|||||||
Reference in New Issue
Block a user