You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

20 lines
449 B

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { url: String }
async share() {
const url = this.urlValue || window.location.origin
if (navigator.share) {
try {
await navigator.share({ url })
return
} catch (e) {
if (e.name === "AbortError") return
}
}
try {
await navigator.clipboard.writeText(url)
} catch {}
}
}