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

This commit is contained in:
Arindy 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))
})

View File

@ -12,8 +12,21 @@
<link rel="icon" type="image/png" href="/favicon.png">
<script src="/vendor/color-picker.js"></script>
<script type="module" src="/dice-preview.js"></script>
<script type="text/javascript" src="/rich-preview.js"></script>
<script type="text/javascript" src="/app.js"></script>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Dice-Tower">
<meta name="twitter:image" content="{http:request.scheme}://{http:request.authority}/rich.png">
<meta name="description" content="Easy to use online dice rolling with customizable overlays.">
<meta name="twitter:description" content="Easy to use online dice rolling with customizable overlays.">
<meta property="og:url" content="{http:request.absoluteURI}">
<meta property="og:image" content="{http:request.scheme}://{http:request.authority}/rich.png">
<meta property="og:description" content="Easy to use online dice rolling with customizable overlays.">
<meta property="og:title" content="Dice-Tower">
<meta property="og:site_name" content="Dice-Tower">
<meta property="og:type" content="website">
<meta property="twitter:url" content="{http:request.absoluteURI}">
<meta property="twitter:domain" content="{http:request.authority}">
</head>
<body class="w3-theme-l1">
<div class="w3-container w3-content"