1
1
<script lang="ts" setup>
2
2
import type { Option } from ' ../../types.ts'
3
3
import type { OptionsDatabase , Posts } from ' @devprotocol/clubs-plugin-posts'
4
- import {type ClubsProfile , decode } from ' @devprotocol/clubs-core'
4
+ import { type ClubsProfile , decode } from ' @devprotocol/clubs-core'
5
5
import { onMounted , ref } from ' vue'
6
- import Profile from ' ../Votes/Profile.vue' ;
7
- import IconLock from ' ../../assets/images/icon-lock.png' ;
8
- import {remark } from ' remark' ;
6
+ import Profile from ' ../Votes/Profile.vue'
7
+ import IconLock from ' ../../assets/images/icon-lock.png'
8
+ import { remark } from ' remark'
9
9
import strip from ' strip-markdown'
10
10
11
11
type Props = {
@@ -27,8 +27,8 @@ type Polls = {
27
27
type PostsPlus = Posts & {
28
28
image: string
29
29
profile: Promise <{
30
- readonly profile: ClubsProfile | undefined ;
31
- readonly error: Error | undefined ;
30
+ readonly profile: ClubsProfile | undefined
31
+ readonly error: Error | undefined
32
32
}>
33
33
stripedMarkdown: string
34
34
}
@@ -48,34 +48,37 @@ const fetchPolls = async (feed: OptionsDatabase): Promise<Polls> => {
48
48
const json = await res .json ()
49
49
50
50
return {
51
- title: title ? title : feedId .value ,
52
- values: decode (json .contents )
51
+ title: title ? title : feedId .value ,
52
+ values: decode (json .contents ),
53
53
}
54
54
}
55
55
56
56
onMounted (async () => {
57
- await Promise .all (feeds .map (async (feed ) => {
58
- const data = await fetchPolls (feed )
59
-
60
- data .values = data .values .map ((post ) => {
61
- post .updated_at = new Date (post .updated_at ).toLocaleString (' ja-JP' )
62
-
63
- const images = post .options .find ((item ) => item .key === ' #images' )
64
- if (images && images .value .length > 0 ) {
65
- post .image = images .value [0 ]
66
- }
67
-
68
- remark ()
69
- .use (strip )
70
- .process (post .content ).then ((text ) => {
57
+ await Promise .all (
58
+ feeds .map (async (feed ) => {
59
+ const data = await fetchPolls (feed )
60
+
61
+ data .values = data .values .map ((post ) => {
62
+ post .updated_at = new Date (post .updated_at ).toLocaleString (' ja-JP' )
63
+
64
+ const images = post .options .find ((item ) => item .key === ' #images' )
65
+ if (images && images .value .length > 0 ) {
66
+ post .image = images .value [0 ]
67
+ }
68
+
69
+ remark ()
70
+ .use (strip )
71
+ .process (post .content )
72
+ .then ((text ) => {
71
73
post .stripedMarkdown = text .toString ()
72
- })
74
+ })
73
75
74
- return post
75
- })
76
+ return post
77
+ })
76
78
77
- polls .value = [... polls .value , data ]
78
- }))
79
+ polls .value = [... polls .value , data ]
80
+ }),
81
+ )
79
82
})
80
83
</script >
81
84
@@ -98,7 +101,10 @@ onMounted(async () => {
98
101
<p v-if =" true" class =" flex-grow flex-wrap text-lg truncate" >
99
102
{{ post.stripedMarkdown }}
100
103
</p >
101
- <div v-else class =" flex flex-col justify-center items-center flex-grow p-2 bg-gray-200 rounded" >
104
+ <div
105
+ v-else
106
+ class =" flex flex-col justify-center items-center flex-grow p-2 bg-gray-200 rounded"
107
+ >
102
108
<img
103
109
class =" mb-1 w-5"
104
110
:src =" IconLock.src"
@@ -109,14 +115,16 @@ onMounted(async () => {
109
115
</div >
110
116
</div >
111
117
<figure v-if =" !isMasked && post.image" >
112
- <img :src =" post.image" class =" rounded max-w-20 max-h-20 object-cover object-center" alt =" post image" />
118
+ <img
119
+ :src =" post.image"
120
+ class =" rounded max-w-20 max-h-20 object-cover object-center"
121
+ alt =" post image"
122
+ />
113
123
</figure >
114
124
</div >
115
125
</a >
116
126
<div v-if =" poll.length < 1" class =" mb-4 p-2 bg-gray-100 rounded" >
117
- <p class =" w-full text-gray-400 text-center" >
118
- Empty :)
119
- </p >
127
+ <p class =" w-full text-gray-400 text-center" >Empty :)</p >
120
128
</div >
121
129
</div >
122
130
</div >
0 commit comments