Update index.html
Browse files- index.html +47 -30
index.html
CHANGED
|
@@ -5,47 +5,64 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width" />
|
| 6 |
<title>Diffusers gallery</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
| 9 |
|
| 10 |
<script>
|
| 11 |
async function fetchFirstImage(url) {
|
| 12 |
const response = await fetch(url);
|
| 13 |
const text = await response.text();
|
| 14 |
-
const imageRegex =
|
| 15 |
const match = text.match(imageRegex);
|
| 16 |
return match ? match[1] : null;
|
| 17 |
}
|
| 18 |
</script>
|
| 19 |
</head>
|
| 20 |
-
<body>
|
| 21 |
-
<
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
>
|
| 33 |
-
<div
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
</div>
|
| 39 |
-
<div
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
</body>
|
| 51 |
</html>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width" />
|
| 6 |
<title>Diffusers gallery</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script defer="" src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
| 9 |
|
| 10 |
<script>
|
| 11 |
async function fetchFirstImage(url) {
|
| 12 |
const response = await fetch(url);
|
| 13 |
const text = await response.text();
|
| 14 |
+
const imageRegex = /(https?:\/\/.*\.(?:png|jpg))(\?.*)?/i;
|
| 15 |
const match = text.match(imageRegex);
|
| 16 |
return match ? match[1] : null;
|
| 17 |
}
|
| 18 |
</script>
|
| 19 |
</head>
|
| 20 |
+
<body class="py-10">
|
| 21 |
+
<section
|
| 22 |
+
class="container grid grid-cols-3 2xl:grid-cols-4 gap-4 mx-auto"
|
| 23 |
+
x-data="{models: [], fetchFirstImage, }"
|
| 24 |
+
x-init="{models} = await fetch('https://huggingface.co/models-json?pipeline_tag=text-to-image&sort=likes').then(data => data.json())"
|
| 25 |
+
>
|
| 26 |
+
<template x-for="model in models.reverse()">
|
| 27 |
+
<a
|
| 28 |
+
:href="`https://huggingface.co/${model.id}`"
|
| 29 |
+
class="block bg-gray-100 rounded-xl overflow-hidden relative group aspect-square"
|
| 30 |
+
target="_blank"
|
| 31 |
+
>
|
| 32 |
+
<div
|
| 33 |
+
class="absolute bottom-0 p-4 bg-gradient-to-t text-white pt-10 from-black/90 via-black/70 to-transparent w-full z-10"
|
| 34 |
>
|
| 35 |
+
<div class="text-sm flex items-center group-hover:translate-x-0.5 transition">
|
| 36 |
+
<svg
|
| 37 |
+
class="mr-1 text-red-500"
|
| 38 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 39 |
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
| 40 |
+
aria-hidden="true"
|
| 41 |
+
focusable="false"
|
| 42 |
+
role="img"
|
| 43 |
+
width="1em"
|
| 44 |
+
height="1em"
|
| 45 |
+
preserveAspectRatio="xMidYMid meet"
|
| 46 |
+
viewBox="0 0 32 32"
|
| 47 |
+
fill="currentColor"
|
| 48 |
+
>
|
| 49 |
+
<path
|
| 50 |
+
d="M22.5,4c-2,0-3.9,0.8-5.3,2.2L16,7.4l-1.1-1.1C12,3.3,7.2,3.3,4.3,6.2c0,0-0.1,0.1-0.1,0.1c-3,3-3,7.8,0,10.8L16,29l11.8-11.9c3-3,3-7.8,0-10.8C26.4,4.8,24.5,4,22.5,4z"
|
| 51 |
+
></path>
|
| 52 |
+
</svg>
|
| 53 |
+
<span x-text="model.likes"></span>
|
| 54 |
</div>
|
| 55 |
+
<div x-text="model.id" class="text-xl font-semibold group-hover:translate-x-0.5 transition"></div>
|
| 56 |
+
</div>
|
| 57 |
+
<div
|
| 58 |
+
class="group-hover:brightness-90 h-full"
|
| 59 |
+
x-data="{img: ''}"
|
| 60 |
+
x-init="img = await fetchFirstImage(`https://huggingface.co/${model.id}/raw/main/README.md`)"
|
| 61 |
+
>
|
| 62 |
+
<img :src="img" alt="" class="w-full h-full object-cover" />
|
| 63 |
+
</div>
|
| 64 |
+
</a>
|
| 65 |
+
</template>
|
| 66 |
+
</section>
|
| 67 |
</body>
|
| 68 |
</html>
|