Adds native share button

Replaces the existing share buttons with a native share button implemented using the Web Share API.

This simplifies the code, removes dependency on external libraries, and provides a more consistent user experience across different platforms.
The old share buttons are removed from the config file.
This commit is contained in:
fundor333
2025-08-22 21:32:03 +02:00
parent c1c2cb2e02
commit d7bfe0cc23
4 changed files with 37 additions and 589 deletions

29
static/js/share-button.js Normal file
View File

@@ -0,0 +1,29 @@
class ShareButton extends HTMLElement {
static register(tagName) {
if ("customElements" in window && window.navigator.share) {
customElements.define(tagName || "share-button", ShareButton);
}
}
connectedCallback() {
this.button.addEventListener("click", this.share);
}
get button() {
return this.querySelector("button");
}
share = () => {
const root = this.getRootNode();
window.navigator
.share({
title: root.title,
text: root.title,
url: window.location.href,
})
.then(() => console.log("Page was succesffuly shared"))
.catch((error) => console.log(error));
};
}
ShareButton.register();