Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/pages/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ if (id) {
<SmolResults id={id as string} client:only="svelte" />
</div>

{lyricsDisplay && (
<button
id="copy-lyrics-button"
class="fixed bottom-4 right-4 z-40 rounded-md border border-white/20 bg-black/60 px-3 py-1.5 text-xs font-medium text-white backdrop-blur hover:bg-black/75 transition-colors"
type="button"
aria-label="Copy lyrics"
data-lyrics={lyricsDisplay}
>
Copy lyrics
</button>
)}
<!-- SSR Content for SEO (Visible but unobtrusive) -->
<!-- SSR Content for SEO -->
<div class="sr-only">
Expand All @@ -173,4 +184,29 @@ if (id) {
</section>
</div>
</div>

<script is:inline>
const copyLyricsButton = document.getElementById("copy-lyrics-button");

if (copyLyricsButton) {
copyLyricsButton.addEventListener("click", async () => {
const lyrics = copyLyricsButton.getAttribute("data-lyrics") || "";
if (!lyrics) return;

try {
await navigator.clipboard.writeText(lyrics);
copyLyricsButton.textContent = "Copied";
setTimeout(() => {
copyLyricsButton.textContent = "Copy lyrics";
}, 1200);
} catch {
copyLyricsButton.textContent = "Copy failed";
setTimeout(() => {
copyLyricsButton.textContent = "Copy lyrics";
}, 1200);
}
});
}
</script>

</Layout>