Replace additional date by optional description

This commit is contained in:
Adrien Maston
2026-02-20 17:18:53 +01:00
parent 4e53000bc3
commit 1d07e10650
4 changed files with 22 additions and 39 deletions
@@ -4,42 +4,11 @@ export default class extends BridgeComponent {
static component = "share"
share() {
const type = this.bridgeElement.bridgeAttribute("share-type")
switch (type) {
case "card-url":
this.send("shareCardUrl", this.#data(type))
break
default:
this.send("shareUrl", this.#data(type))
}
}
#data(type) {
return {
const description = this.bridgeElement.bridgeAttribute("share-description")
this.send("share", {
title: document.title,
url: window.location.href,
...this.#additionalDataFor(type)
}
}
#additionalDataFor(type) {
switch (type) {
case "card-url":
return {
author: this.#author,
dateAdded: this.#dateAdded
}
default:
return null
}
}
get #author() {
return document.querySelector(".card__meta-text--author strong")?.textContent?.trim() ?? null
}
get #dateAdded() {
const timestamp = document.querySelector(".card__meta-text--added time")?.dateTime
return parseInt(timestamp) || null
description
})
}
}