For posts, comments, and other objects, the `published` attribute is a string containing an ISO 8601 timestamp. This timestamp is UTC, though it is not explicit in the string's contents. When the `Date` constructor is used on such strings, they are parsed as though they are local timestamps. According to [1]: > When the time zone offset is absent, date-only forms are > interpreted as a UTC time and date-time forms are interpreted as local > time. This is due to a historical spec error that was not consistent > with ISO 8601 but could not be changed due to web > compatibility. This patch explicitly appends a 'Z' to the `published` string when it is used as the argument to the `Date` constructor. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
66 lines
2.4 KiB
Svelte
66 lines
2.4 KiB
Svelte
<script lang="ts">
|
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
|
import { getClient } from '$lib/lemmy.js'
|
|
import type { SiteView, Tagline } from 'lemmy-js-client'
|
|
import {
|
|
Calendar,
|
|
ChatBubbleOvalLeftEllipsis,
|
|
Icon,
|
|
Newspaper,
|
|
PencilSquare,
|
|
UserGroup,
|
|
} from 'svelte-hero-icons'
|
|
|
|
export let site: SiteView
|
|
export let taglines: Tagline[] | undefined = undefined
|
|
</script>
|
|
|
|
<StickyCard>
|
|
<div class="flex flex-row gap-3 items-center">
|
|
{#if site.site.icon}
|
|
<Avatar width={42} url={site.site.icon} alt={site.site.name} />
|
|
{/if}
|
|
<div class="flex flex-col">
|
|
<h1 class="font-bold text-base">{site.site.name}</h1>
|
|
<span class="text-sm opacity-60">
|
|
{new URL(site.site.actor_id).hostname}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<span class="flex flex-row items-center gap-1 text-sm">
|
|
<Icon src={Calendar} width={16} height={16} mini />
|
|
<RelativeDate date={new Date(site.site.published + 'Z')} />
|
|
</span>
|
|
<div class="text-sm flex flex-row flex-wrap gap-3">
|
|
<span class="flex flex-row items-center gap-1">
|
|
<Icon src={UserGroup} width={16} height={16} mini />
|
|
<FormattedNumber number={site.counts.users} />
|
|
</span>
|
|
<span class="flex flex-row items-center gap-1">
|
|
<Icon src={PencilSquare} width={16} height={16} mini />
|
|
<FormattedNumber number={site.counts.posts} />
|
|
</span>
|
|
<span class="flex flex-row items-center gap-1">
|
|
<Icon src={ChatBubbleOvalLeftEllipsis} width={16} height={16} mini />
|
|
<FormattedNumber number={site.counts.comments} />
|
|
</span>
|
|
<span class="flex flex-row items-center gap-1">
|
|
<Icon src={Newspaper} width={16} height={16} mini />
|
|
<FormattedNumber number={site.counts.communities} />
|
|
</span>
|
|
</div>
|
|
{#if taglines && taglines.length > 0}
|
|
<Markdown
|
|
source={taglines[Math.floor(Math.random() * taglines.length)].content}
|
|
/>
|
|
<hr class="border-slate-300 dark:border-zinc-700" />
|
|
{/if}
|
|
<Markdown source={site.site.description} />
|
|
<hr class="border-slate-300 dark:border-zinc-700" />
|
|
<Markdown source={site.site.sidebar} />
|
|
</StickyCard>
|