clean up
Browse files- index.html +20 -6
index.html
CHANGED
@@ -15,21 +15,33 @@
|
|
15 |
Alpine.data('modelsData', () => ({
|
16 |
async init() {
|
17 |
const data = await this.getModels(this.page)
|
18 |
-
this.models = data.models
|
|
|
|
|
|
|
|
|
|
|
19 |
this.totalPages = data.totalPages
|
20 |
},
|
|
|
21 |
models: [],
|
22 |
page: 1,
|
23 |
totalPages: -1,
|
24 |
getModels(page) {
|
25 |
-
return fetch(`
|
|
|
26 |
.then((res) => res.json())
|
27 |
},
|
28 |
nextPage() {
|
29 |
if (this.page < this.totalPages) {
|
30 |
this.page += 1
|
31 |
this.getModels(this.page).then((data) => {
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
})
|
34 |
}
|
35 |
},
|
@@ -48,7 +60,7 @@
|
|
48 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button>
|
49 |
</div>
|
50 |
<template x-for="model in models" :key="model.id">
|
51 |
-
<template x-if="model.images.length">
|
52 |
<a :href="`https://huggingface.co/${model.id}`"
|
53 |
class="block bg-gray-900 rounded-xl overflow-hidden relative group aspect-square text-white" target="_blank">
|
54 |
<div
|
@@ -68,8 +80,10 @@
|
|
68 |
</div>
|
69 |
</div>
|
70 |
<div class="group-hover:brightness-90 h-full">
|
71 |
-
<
|
72 |
-
|
|
|
|
|
73 |
</div>
|
74 |
</a>
|
75 |
</template>
|
|
|
15 |
Alpine.data('modelsData', () => ({
|
16 |
async init() {
|
17 |
const data = await this.getModels(this.page)
|
18 |
+
this.models = data.models.map(model => ({
|
19 |
+
id: model.id,
|
20 |
+
likes: model.likes,
|
21 |
+
images: model.images.filter(image => image && image.endsWith('.jpg'))
|
22 |
+
}))
|
23 |
+
|
24 |
this.totalPages = data.totalPages
|
25 |
},
|
26 |
+
ASSETS_URL: 'https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/',
|
27 |
models: [],
|
28 |
page: 1,
|
29 |
totalPages: -1,
|
30 |
getModels(page) {
|
31 |
+
// return fetch(`http://localhost:8000/api/models?page=${page}`)
|
32 |
+
return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`)
|
33 |
.then((res) => res.json())
|
34 |
},
|
35 |
nextPage() {
|
36 |
if (this.page < this.totalPages) {
|
37 |
this.page += 1
|
38 |
this.getModels(this.page).then((data) => {
|
39 |
+
const models = data.models.map(model => ({
|
40 |
+
id: model.id,
|
41 |
+
likes: model.likes,
|
42 |
+
images: model.images.filter(image => image && image.endsWith('.jpg'))
|
43 |
+
}))
|
44 |
+
this.models = this.models.concat(models)
|
45 |
})
|
46 |
}
|
47 |
},
|
|
|
60 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button>
|
61 |
</div>
|
62 |
<template x-for="model in models" :key="model.id">
|
63 |
+
<template x-if="model.images.length > 0">
|
64 |
<a :href="`https://huggingface.co/${model.id}`"
|
65 |
class="block bg-gray-900 rounded-xl overflow-hidden relative group aspect-square text-white" target="_blank">
|
66 |
<div
|
|
|
80 |
</div>
|
81 |
</div>
|
82 |
<div class="group-hover:brightness-90 h-full">
|
83 |
+
<template x-if="model.images[0]">
|
84 |
+
<img :src="()=> ASSETS_URL + model.images[model.images.length * Math.random() | 0]" :alt="model.id" alt=""
|
85 |
+
loading="lazy" class="w-full h-full object-cover group-hover:scale-[1.01] transition" />
|
86 |
+
</template>
|
87 |
</div>
|
88 |
</a>
|
89 |
</template>
|