48 lines
2.3 KiB
HTML
48 lines
2.3 KiB
HTML
<section
|
|
class="container mx-auto px-6 mb-12"
|
|
x-data="{ postsResource: { status: 'loading' } }"
|
|
x-init="postsResource = await fetch('{{ site.Params.tickerApiURL }}?origin={{ site.Params.tickerClientURL }}&limit=3')
|
|
.then(res => res.json())
|
|
.then(json => {
|
|
const data = json.data?.messages ?? null
|
|
return data === null
|
|
? { status: 'error' }
|
|
: { status: 'success', data }
|
|
})
|
|
.catch(error => { status: 'error', error })"
|
|
>
|
|
<template x-if="postsResource.status == 'loading'">
|
|
<div class="text-center">{{ i18n "loading" }}</div>
|
|
</template>
|
|
<template x-if="postsResource.status == 'error'">
|
|
<div class="text-center">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-8 mx-auto mb-2">
|
|
<path fill="none" d="M0 0h24v24H0z"/>
|
|
<path fill="currentColor" d="M12 2c5.523 0 10 4.477 10 10 0 .727-.077 1.435-.225 2.118l-1.782-1.783a8 8 0 1 0-4.375 6.801 3.997 3.997 0 0 0 1.555 1.423A9.956 9.956 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2zm7 12.172l1.414 1.414a2 2 0 1 1-2.93.11l.102-.11L19 14.172zM12 15c1.466 0 2.785.631 3.7 1.637l-.945.86C13.965 17.182 13.018 17 12 17c-1.018 0-1.965.183-2.755.496l-.945-.86A4.987 4.987 0 0 1 12 15zm-3.5-5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zm7 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3z"/>
|
|
</svg>
|
|
<p>Něco se pokazilo</p>
|
|
</div>
|
|
</template>
|
|
<template x-if="postsResource.status == 'success'">
|
|
<div>
|
|
<h2 class="text-3xl font-bold mb-8">{{ i18n "news" }}</h2>
|
|
<ol class="grid gap-6" style="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))">
|
|
<template x-for="post in postsResource.data">
|
|
<li class="mb-4">
|
|
<article class="text-sm text-balance">
|
|
<time
|
|
class="text-gray-600 dark:text-gray-400 text-xs block mb-1"
|
|
x-bind:datetime="post.createdAt"
|
|
x-text="new Date(post.createdAt).toLocaleString()"
|
|
></time>
|
|
<p x-text="post.text" class="mb-1"></p>
|
|
</article>
|
|
</li>
|
|
</template>
|
|
</ol>
|
|
{{ with site.Params.tickerClientURL }}
|
|
<a class="link text-sm font-semibold" href="https://{{ . }}" target="_blank">{{ i18n "show_older_news" }}</a>
|
|
{{ end }}
|
|
</div>
|
|
</template>
|
|
</section>
|