|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <ul> |
| 4 | + <li v-for="topic in topicData.topics"> |
| 5 | + <a |
| 6 | + :href="`https://discourse-earthcode.eox.at/t/${topic.slug}`" |
| 7 | + target="_blank" |
| 8 | + > |
| 9 | + <span class="title">{{ topic.unicode_title || topic.title }}</span> |
| 10 | + <span class="excerpt">{{ |
| 11 | + topic.excerpt?.replace("&hellip\;", " ...") |
| 12 | + }}</span> |
| 13 | + <span class="date">{{ |
| 14 | + new Date(topic.bumped_at).toLocaleDateString() |
| 15 | + }}</span> |
| 16 | + <span class="posts"> |
| 17 | + <img |
| 18 | + v-for="avatar in new Set([ |
| 19 | + ...topicData.posts |
| 20 | + .filter((p) => p.topic_id === topic.id) |
| 21 | + .map((p) => p.avatar_template), |
| 22 | + ])" |
| 23 | + :src="`https://discourse-earthcode.eox.at${avatar.replace( |
| 24 | + '{size}', |
| 25 | + '28' |
| 26 | + )}`" |
| 27 | + /> |
| 28 | + {{ topicData.posts.filter((p) => p.topic_id === topic.id).length }} |
| 29 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 30 | + <title>message-text-outline</title> |
| 31 | + <path |
| 32 | + fill="#C2C8CC" |
| 33 | + d="M20,2A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H6L2,22V4C2,2.89 2.9,2 4,2H20M4,4V17.17L5.17,16H20V4H4M6,7H18V9H6V7M6,11H15V13H6V11Z" |
| 34 | + /> |
| 35 | + </svg> |
| 36 | + {{ topic.posts_count }} |
| 37 | + </span> |
| 38 | + </a> |
| 39 | + </li> |
| 40 | + </ul> |
| 41 | + <i> |
| 42 | + <span v-if="topicData.topics?.length < 1"> |
| 43 | + No related topics found? |
| 44 | + </span> |
| 45 | + <span v-else> Didn't find what you were looking for? </span> |
| 46 | + <a |
| 47 | + :href="`https://discourse-earthcode.eox.at/new-topic?title=${ |
| 48 | + stacData.title |
| 49 | + }&category=Data & Workflows&tags=${capitalize( |
| 50 | + stacData['osc:type'] |
| 51 | + )},${stacData.keywords?.join(',')},STAC`" |
| 52 | + target="_blank" |
| 53 | + ><strong>Start a new topic on the EarthCODE forum</strong></a |
| 54 | + >!</i |
| 55 | + > |
| 56 | + </div> |
| 57 | +</template> |
| 58 | + |
| 59 | +<script> |
| 60 | +export default { |
| 61 | + props: { |
| 62 | + stacData: { |
| 63 | + type: Object, |
| 64 | + default: {}, |
| 65 | + }, |
| 66 | + topicData: { |
| 67 | + type: Object, |
| 68 | + default: {}, |
| 69 | + }, |
| 70 | + }, |
| 71 | + methods: { |
| 72 | + capitalize(s) { |
| 73 | + return String(s[0]).toUpperCase() + String(s).slice(1); |
| 74 | + }, |
| 75 | + }, |
| 76 | +}; |
| 77 | +</script> |
| 78 | + |
| 79 | +<style scoped> |
| 80 | +ul { |
| 81 | + padding: 0; |
| 82 | +} |
| 83 | +li { |
| 84 | + list-style: none; |
| 85 | +} |
| 86 | +li a { |
| 87 | + background: #fff; |
| 88 | + border: 1px solid #c2c8cc; |
| 89 | + border-radius: 8px; |
| 90 | + padding: 24px; |
| 91 | + margin-bottom: 12px; |
| 92 | + display: grid; |
| 93 | + grid-template-areas: |
| 94 | + "title" |
| 95 | + "date" |
| 96 | + "posts" |
| 97 | + "excerpt"; |
| 98 | + gap: 16px; |
| 99 | + transition: all ease-in-out 0.3s; |
| 100 | + text-decoration: none; |
| 101 | +} |
| 102 | +.title { |
| 103 | + font-family: NotesESAbold, sans-serif; |
| 104 | + font-size: 18px; |
| 105 | + line-height: 27px; |
| 106 | + grid-area: title; |
| 107 | + margin-bottom: 8px; |
| 108 | +} |
| 109 | +.date { |
| 110 | + grid-area: date; |
| 111 | + color: #647078; |
| 112 | + font-size: 16px; |
| 113 | + line-height: 25px; |
| 114 | +} |
| 115 | +.excerpt { |
| 116 | + grid-area: excerpt; |
| 117 | + color: #8a969e; |
| 118 | + font-size: 16px; |
| 119 | + line-height: 25px; |
| 120 | +} |
| 121 | +.posts { |
| 122 | + grid-area: posts; |
| 123 | + display: flex; |
| 124 | + align-items: center; |
| 125 | + font-size: 16px; |
| 126 | + line-height: 25px; |
| 127 | +} |
| 128 | +.posts img { |
| 129 | + width: 28px; |
| 130 | + height: 28px; |
| 131 | + border-radius: 50%; |
| 132 | + margin-right: 8px; |
| 133 | +} |
| 134 | +.posts img:nth-child(n + 2) { |
| 135 | + margin-left: -20px; |
| 136 | +} |
| 137 | +.posts svg { |
| 138 | + margin-left: 16px; |
| 139 | + margin-right: 8px; |
| 140 | + height: 28px; |
| 141 | +} |
| 142 | +@media (min-width: 640px) { |
| 143 | + li a { |
| 144 | + grid-template-areas: |
| 145 | + "title date" |
| 146 | + "excerpt posts"; |
| 147 | + } |
| 148 | + .date, |
| 149 | + .posts { |
| 150 | + justify-self: self-end; |
| 151 | + } |
| 152 | +} |
| 153 | +</style> |
0 commit comments