setup for fediverse script changed
All checks were successful
/ weblog.lol (push) Successful in 12s

This commit is contained in:
Gordon Pedersen 2024-05-11 09:01:03 +10:00
parent 535e9451a8
commit 3005376521
4 changed files with 21 additions and 19 deletions

View file

@ -25,7 +25,10 @@
</aside> </aside>
<i data-emoji="{emoji}"></i> <i data-emoji="{emoji}"></i>
{body} {body}
<aside class="post-info"><a class="status_url" href="{status_url}"><i class="omg-icon omg-prami"></i> via status.lol</a><a class="external_url" href="{external_url}"><i class="omg-icon omg-fediverse"></i> Reply on the Fediverse</a></aside> <aside class="post-info">
<a class="status_url" href="{status_url}"><i class="omg-icon omg-prami"></i> via status.lol</a>
<a class="external_url" href="{external_url}"><i class="omg-icon omg-fediverse"></i> Interact on the Fediverse</a>
</aside>
<aside class="post-tags"> <aside class="post-tags">
{tags} {tags}
</aside> </aside>
@ -44,18 +47,13 @@
</footer> </footer>
<script src="https://cdn.jsdelivr.net/npm/luxon/build/global/luxon.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/luxon/build/global/luxon.min.js" crossorigin="anonymous"></script>
<script src="/share.js"></script> <script src="/fediverse.js"></script>
<script> <script>
document.querySelectorAll('time:not(.dt-start):not(.dt-end)').forEach(time => { document.querySelectorAll('time:not(.dt-start):not(.dt-end)').forEach(time => {
const datetime = luxon.DateTime.fromISO(time.getAttribute('datetime')) const datetime = luxon.DateTime.fromISO(time.getAttribute('datetime'))
time.innerText = datetime.toRelative() time.innerText = datetime.toRelative()
}); });
document.querySelectorAll("a.external_url:not([href='{external_url}'])").forEach(el => { fediverse()
el.addEventListener('click', e => {
e.preventDefault()
share(el.href)
})
})
</script> </script>
</body> </body>

View file

@ -1,8 +1,8 @@
/*/ /*/
Type: file Type: file
Content-Type: application/javascript Content-Type: application/javascript
Title: Share script Title: Fediverse script
Location: /share.js Location: /fediverse.js
/**/ /**/
const SUBSCRIBE_LINK_REL = 'http://ostatus.org/schema/1.0/subscribe' const SUBSCRIBE_LINK_REL = 'http://ostatus.org/schema/1.0/subscribe'
@ -40,3 +40,12 @@ function share(uri, handle) {
} }
} }
} }
function fediverse() {
document.querySelectorAll("a.external_url:not([href='{external_url}'])").forEach(el => {
el.addEventListener('click', e => {
e.preventDefault()
share(el.href)
})
})
}

View file

@ -36,18 +36,13 @@ Title: Landing Page Template
</footer> </footer>
<script src="https://cdn.jsdelivr.net/npm/luxon/build/global/luxon.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/luxon/build/global/luxon.min.js" crossorigin="anonymous"></script>
<script src="/share.js"></script> <script src="/fediverse.js"></script>
<script> <script>
document.querySelectorAll('time:not(.dt-start):not(.dt-end)').forEach(time => { document.querySelectorAll('time:not(.dt-start):not(.dt-end)').forEach(time => {
const datetime = luxon.DateTime.fromISO(time.getAttribute('datetime')) const datetime = luxon.DateTime.fromISO(time.getAttribute('datetime'))
time.innerText = datetime.toRelative() time.innerText = datetime.toRelative()
});
document.querySelectorAll("a.external_url:not([href='{external_url}'])").forEach(el => {
el.addEventListener('click', e => {
e.preventDefault()
share(el.href)
})
}) })
fediverse()
</script> </script>
</body> </body>

View file

@ -9,7 +9,7 @@ Title: Post Template
{body} {body}
<aside class="post-info"> <aside class="post-info">
<a class="status_url" href="{status_url}"><i class="omg-icon omg-prami"></i> via status.lol</a> <a class="status_url" href="{status_url}"><i class="omg-icon omg-prami"></i> via status.lol</a>
<a class="external_url" href="{external_url}"><i class="omg-icon omg-fediverse"></i> Reply on the Fediverse</a> <a class="external_url" href="{external_url}"><i class="omg-icon omg-fediverse"></i> Interact on the Fediverse</a>
</aside> </aside>
<aside class="post-tags"> <aside class="post-tags">
{tags} {tags}