forked from hplush/slowreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts.svelte
More file actions
43 lines (39 loc) · 1.04 KB
/
posts.svelte
File metadata and controls
43 lines (39 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<script lang="ts">
import type { LoadedSyncMap, SyncMapStore } from '@logux/client'
import {
getPopupId,
getPostPopupParam,
getPostTitle,
openedPost,
type OriginPost,
type PostValue,
router
} from '@slowreader/core'
import { getPopupHash } from '../stores/url-router.ts'
import Links from './links.svelte'
let {
autoread,
list
}: {
autoread?: boolean
list: readonly (LoadedSyncMap<SyncMapStore<PostValue>> | OriginPost)[]
} = $props()
let links = $derived(
list.map(i => {
let post = ('get' in i ? i.get() : i) as OriginPost | PostValue
let param = getPostPopupParam(post, autoread)
return {
controls: getPopupId('post', param),
href: getPopupHash($router, 'post', param),
id: 'id' in post ? post.id : post.originId,
item: post,
variant: 'id' in post && post.read ? ('read' as const) : undefined
}
})
)
</script>
<Links current={$openedPost} {links}>
{#snippet item(post)}
{getPostTitle(post)}
{/snippet}
</Links>