web button support

This commit is contained in:
2026-04-11 19:10:35 +01:00
parent accce8066a
commit ec181145b0
12 changed files with 736 additions and 67 deletions
+12
View File
@@ -0,0 +1,12 @@
[
{
"name":"paw",
"url":"",
"path":"paw.png"
},
{
"name":"catgirl",
"url":"",
"path":"catgirl.gif"
}
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

+50
View File
@@ -0,0 +1,50 @@
<script lang="ts" module>
import json from "./dic.json";
const imageModules = import.meta.glob(
"./imgs/*.{avif,AVIF,heif,HEIF,jpeg,JPEG,jpg,JPG,png,PNG,tiff,TIFF,webp,WEBP}",
{
eager: true,
import: "default",
query: {
enhanced: true,
},
},
);
const gifModules = import.meta.glob("./imgs/*.{gif,GIF}", {
eager: true,
import: "default",
});
function getImageUrl(name: string): any {
let query = "./imgs/" + name;
return imageModules[query] || gifModules[query];
}
export { WebButtons };
</script>
{#snippet WebButtons()}
{#each json as web_button}
<a
class="web_button_container"
title="{web_button.name} web button (88x31)"
href={web_button.url}
>
<enhanced:img
class="web_button_img"
src={getImageUrl(web_button.path)}
alt="88x31 web button"
loading="lazy"
/>
</a>
{/each}
{/snippet}
<style>
.web_button_div {
display: flex;
flex-direction: row;
}
.web_button_container {
}
.web_button_img {
}
</style>