-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathMessageOgpList.vue
More file actions
56 lines (49 loc) · 1.07 KB
/
MessageOgpList.vue
File metadata and controls
56 lines (49 loc) · 1.07 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
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<div :class="$style.container">
<MessageOgpListItem
v-for="(item, index) in ogpItems"
:key="`${item.url}-${index}`"
:class="$style.item"
:url="item.url"
:ogp-data="item.ogpData"
/>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { useMessagesStore } from '/@/store/entities/messages'
import MessageOgpListItem from './MessageOgpListItem.vue'
const props = withDefaults(
defineProps<{
externalUrls?: string[]
}>(),
{
externalUrls: () => []
}
)
const { ogpDataMap } = useMessagesStore()
const ogpItems = computed(() =>
props.externalUrls.flatMap(url => {
const ogpData = ogpDataMap.value.get(url)
if (!ogpData?.title) {
return []
}
return [{ url, ogpData }]
})
)
</script>
<style lang="scss" module>
.container {
display: flex;
flex-direction: column;
}
.item {
// アイテムが消える可能性があるのでこちらにmarginをつける
&:first-child {
margin-top: 1rem;
}
&:not(:last-child) {
margin-bottom: 1rem;
}
}
</style>