mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.9 KiB
97 lines
2.9 KiB
<script setup lang="ts"> |
|
import { unified } from 'unified' |
|
import remarkParse from 'remark-parse' |
|
import remarkRehype from 'remark-rehype' |
|
import rehypeSanitize from 'rehype-sanitize' |
|
import rehypeStringify from 'rehype-stringify' |
|
import { YoutubeVue3 } from 'youtube-vue3' |
|
import type { ProductFeedItem } from '../../../lib/types' |
|
import { extractYoutubeVideoId } from '../../../utils/urlUtils' |
|
import { timeAgo } from '~/utils/datetimeUtils' |
|
const props = defineProps<{ |
|
item: ProductFeedItem |
|
}>() |
|
|
|
const { getPossibleAttachmentSrc } = useAttachment() |
|
|
|
const { |
|
item: { 'Published Time': CreatedAt, Description, Url, Title, 'Feed Source': source, Images }, |
|
} = props |
|
|
|
const feedIcon = { |
|
Twitter: iconMap.twitter, |
|
Youtube: iconMap.youtube, |
|
Github: iconMap.githubSolid, |
|
} |
|
|
|
const renderedText = computedAsync(async () => { |
|
return await unified() |
|
.use(remarkParse) |
|
.use(remarkRehype) |
|
.use(rehypeSanitize) |
|
.use(rehypeStringify) |
|
.process( |
|
Description.replace(/!\[.*?\]\(.*?\)/g, '') |
|
.substring(0, 250) |
|
.concat('...') |
|
.concat(` [Read more](${Url})`), |
|
) |
|
}) |
|
</script> |
|
|
|
<template> |
|
<div class="bg-white recent-card border-gray-200 border-1 rounded-2xl" style="width: 540px"> |
|
<div class="flex items-center justify-between px-5 py-4"> |
|
<div class="flex items-center gap-3"> |
|
<component :is="feedIcon[source as any]" class="w-4 h-4 stroke-transparent" /> |
|
<span class="font-weight-medium text-nc-content-gray leading-5 cursor-pointer" @click="openLink(Url)"> |
|
{{ source }} |
|
</span> |
|
</div> |
|
<div class="text-sm text-nc-content-gray-muted leading-5"> |
|
{{ timeAgo(CreatedAt) }} |
|
</div> |
|
</div> |
|
<template v-if="source === 'Github'"> |
|
<LazyCellAttachmentPreviewImage |
|
v-if="Images?.length" |
|
class="cursor-pointer" |
|
:srcs="getPossibleAttachmentSrc(Images[0], 'card_cover')" |
|
@click="openLink(Url)" |
|
/> |
|
<div class="prose px-5 pb-5 mt-5" v-html="renderedText"></div> |
|
</template> |
|
<template v-else-if="source === 'Youtube'"> |
|
<YoutubeVue3 :videoid="extractYoutubeVideoId(Url)" :controls="1" :height="330" :width="538" :autoplay="0" /> |
|
<div class="p-5 flex flex-col text-nc-content-gray-emphasis gap-4"> |
|
<div class="text-2xl font-semibold truncate"> |
|
{{ Title }} |
|
</div> |
|
|
|
<div class="font-weight-base text-md"> |
|
{{ Description.substring(0, 200).concat('...') }} |
|
</div> |
|
</div> |
|
</template> |
|
</div> |
|
</template> |
|
|
|
<style scoped lang="scss"> |
|
.recent-card { |
|
box-shadow: 0px 4px 8px -2px rgba(0, 0, 0, 0.08), 0px 2px 4px -2px rgba(0, 0, 0, 0.04); |
|
:deep(.prose) { |
|
a { |
|
@apply text-gray-900; |
|
} |
|
|
|
h1 { |
|
@apply text-2xl text-nc-content-gray-emphasis truncate leading-9 mb-0; |
|
font-weight: 700; |
|
} |
|
p { |
|
@apply text-nc-content-gray-emphasis leading-5; |
|
font-size: 14px !important; |
|
} |
|
} |
|
} |
|
</style>
|
|
|