fixes rich-preview
All checks were successful
CI / deploy (push) Successful in 6m0s

This commit is contained in:
2025-02-16 16:31:53 +01:00
parent 7b9143c26d
commit c0415561ee
2 changed files with 14 additions and 41 deletions

View File

@@ -1,40 +0,0 @@
const title = `${document.querySelector('title').textContent}`
const dexcription = ` Easy to use online dice rolling with customizable overlays.`
function url() {
return window.location.protocol + '//' + window.location.hostname + (window.location.port?.length > 0 ? ':' + window.location.port : '');
}
const image = url() + '/rich.png'
function createMetaTag(name, property, content) {
let tag = document.createElement('meta');
if (name) {
tag.setAttribute('name', name)
}
if (property) {
tag.setAttribute('property', property)
}
tag.setAttribute('content', content)
return tag;
}
function createTags() {
return [
createMetaTag('description', undefined, dexcription),
createMetaTag(undefined, 'og:url', url()),
createMetaTag(undefined, 'og:image', image),
createMetaTag(undefined, 'og:description', dexcription),
createMetaTag(undefined, 'og:title', title),
createMetaTag(undefined, 'og:site_name', title),
createMetaTag(undefined, 'og:type', 'website'),
createMetaTag(undefined, 'twitter:url', url()),
createMetaTag(undefined, 'twitter:domain', document.location.hostname),
createMetaTag('twitter:title', undefined, title),
createMetaTag('twitter:image', undefined, image),
createMetaTag('twitter:card', undefined, 'summary_large_image'),
createMetaTag('twitter:description', undefined, dexcription),
]
}
document.addEventListener("DOMContentLoaded", async () => {
createTags().forEach(tag => document.head.appendChild(tag))
})