update
Browse files7 unmodified lines891011121314151617181920212223242526272829303 unmodified lines3435363738394011 unmodified lines52535455565758596061626364656667687 unmodified lines<script defer="" src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script>async function fetchFirstImage(url) {const response = await fetch(url);const text = await response.text();const imageRegex = /(https?:\/\/.*\.(?:png|jpg))(\?.*)?/i;const match = text.match(imageRegex);return match ? match[1] : null;}</script></head><body class="py-10"><sectionclass="container grid grid-cols-3 2xl:grid-cols-4 gap-4 mx-auto"x-data="{models: [], fetchFirstImage, }"x-init="{models} = await fetch('https://huggingface.co/models-json?pipeline_tag=text-to-image&sort=likes').then(data => data.json())"><template x-for="model in models.reverse()"><a:href="`https://huggingface.co/${model.id}`"class="block bg-gray-100 rounded-xl overflow-hidden relative group aspect-square"target="_blank"3 unmodified lines><div class="text-sm flex items-center group-hover:translate-x-0.5 transition"><svgclass="mr-1 text-red-500"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"aria-hidden="true"11 unmodified lines</svg><span x-text="model.likes"></span></div><div x-text="model.id" class="text-xl font-semibold group-hover:translate-x-0.5 transition"></div></div><divclass="group-hover:brightness-90 h-full"x-data="{img: ''}"x-init="img = await fetchFirstImage(`https://huggingface.co/${model.id}/raw/main/README.md`)"><img :src="img" alt="" class="w-full h-full object-cover" /></div></a></template></section></body></html>7 unmodified lines891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253543 unmodified lines5859606162636411 unmodified lines76777879808182838485868788899091927 unmodified lines<script defer="" src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script>function getModels(page) {return fetch(`https://huggingface.co/models-json?pipeline_tag=text-to-image&p=${page}&sort=likes`).then((data) => data.json().then((res) => res.models));}function getModelCard(modelId) {return fetch(`https://huggingface.co/${modelId}/raw/main/README.md`).then((data) => data.text());}function findImage(text) {const imageRegex = /(https?:\/\/.*\.(?:png|jpg))(\?.*)?/i;const match = text.match(imageRegex);return match ? match[1] : null;}function onIntersection(targetEl, callback) {const observer = new IntersectionObserver(([entry]) => {if (entry.isIntersecting) {callback();}});observer.observe(targetEl);}</script></head><body class="py-10 bg-gray-100"><sectionclass="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto"x-data="{models: [], page: 0}"x-init="models = await getModels();onIntersection($refs.scrollSentinel, async () => {models = [...models, ...await getModels(page+1)]page++;})"><template x-for="model in models" :key="model.id"><ax-data="{img: null}"x-init="img = await getModelCard(model.id).then(findImage)":href="`https://huggingface.co/${model.id}`"class="block bg-gray-100 rounded-xl overflow-hidden relative group aspect-square"target="_blank"3 unmodified lines><div class="text-sm flex items-center group-hover:translate-x-0.5 transition"><svgclass="mr-1.5 text-white/70"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"aria-hidden="true"11 unmodified lines</svg><span x-text="model.likes"></span></div><divx-text="model.id"class="text-base md:text-lg lg:text-xl font-semibold group-hover:translate-x-0.5 transition"></div></div><div class="group-hover:brightness-90 h-full"><img :src="img" alt="" class="w-full h-full object-cover group-hover:scale-[1.01] transition" /></div></a></template><div class="h-12" x-ref="scrollSentinel"></div></section></body></html>
index.html+40-16