feat: add opengraph metadata

This commit is contained in:
dusk 2023-05-09 17:57:53 +03:00
parent 54ddf32e21
commit 2fc154f8a4
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
3 changed files with 24 additions and 0 deletions

View File

@ -6,6 +6,8 @@ node_modules
.env .env
.env.* .env.*
!.env.example !.env.example
/result
/.direnv
# Ignore files for PNPM, NPM and YARN # Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml pnpm-lock.yaml

View File

@ -78,6 +78,8 @@
message: `Fetched ${count} tracks`, message: `Fetched ${count} tracks`,
background: 'variant-filled-success' background: 'variant-filled-success'
}); });
comm.close();
}); });
</script> </script>

View File

@ -13,6 +13,21 @@
export let data; export let data;
function getAlbumArtistInfo() {
const hasArtist = data.info.artist;
const hasAlbum = data.info.album;
if (hasArtist && hasAlbum) {
return `from ${data.info.album} by ${data.info.artist}`;
} else if (hasArtist) {
return `by ${data.info.artist}`;
} else if (hasAlbum) {
return `from ${data.info.album}`;
} else {
return '';
}
}
let showIcon = false; let showIcon = false;
let isError = false; let isError = false;
@ -25,6 +40,10 @@
<svelte:head> <svelte:head>
<title>{data.info.title} {data.info.artist !== '' ? `- ${data.info.artist}` : ''}</title> <title>{data.info.title} {data.info.artist !== '' ? `- ${data.info.artist}` : ''}</title>
<meta property="og:title" content={data.info.title} />
<meta property="og:description" content={getAlbumArtistInfo()} />
<meta property="og:image" content={data.thumbnail_url} />
<meta property="og:audio" content={data.audio_url} />
</svelte:head> </svelte:head>
<div <div
@ -40,6 +59,7 @@
bind:paused bind:paused
bind:currentTime bind:currentTime
bind:duration bind:duration
on:loadstart={(event) => event.currentTarget.play()}
/> />
<button <button
class="relative rounded placeholder w-16 h-16" class="relative rounded placeholder w-16 h-16"