Skip to content

Commit 1335b2a

Browse files
committed
Tighten up code
1 parent 5d7abd2 commit 1335b2a

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

_includes/web-share.html

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1-
<p><button class="btn btn--secondary btn--full" id=jsShareButton>Share this</button></p>
1+
<p>
2+
<button id="jsShareButton"
3+
class="btn btn--secondary btn--full"
4+
type="button">
5+
Share this
6+
</button>
7+
</p>
28

3-
<script type=module>
9+
<script type="module">
10+
11+
const shareButton = document.getElementById('jsShareButton');
412

513
if (!navigator.share) {
6-
shareButton.style.display = 'none';
14+
shareButton.hidden = true;
715
} else {
816

9-
const shareButton = document.getElementById('jsShareButton');
17+
/**
18+
* This is very non-standard, but Bluesky’s Web Share is broken so I have
19+
* to bundle everything into text:
20+
*
21+
* https://github.com/bluesky-social/social-app/issues/5051
22+
*/
1023
const shareData = {
11-
/**
12-
* This is very non-standard, but Bluesky’s Web Share is broken so I have
13-
* to bundle everything into `text`:
14-
*
15-
* https://github.com/bluesky-social/social-app/issues/5051
16-
*/
17-
18-
//title: "{{ page.title }}",
19-
//url: "https://csswizardry.com{{ page.url }}",
20-
text: 'I really enjoyed ‘{{ page.title }}’ by @csswizardry! https://csswizardry.com{{ page.url }} '
24+
text: `I really enjoyed ‘{{ page.title | escape }}` +
25+
`’ by @csswizardry! https://csswizardry.com{{ page.url }}`
26+
//title: "{{ page.title | escape }}",
27+
//url: "https://csswizardry.com{{ page.url }}" */
2128
};
2229

2330
shareButton.addEventListener('click', async () => {
2431
try {
2532
await navigator.share(shareData);
26-
} catch (err) { }
33+
} catch (_) {
34+
}
2735
});
2836
}
2937

3038
</script>
31-

0 commit comments

Comments
 (0)