2024-08-10 07:00:17 +00:00
|
|
|
<template>
|
|
|
|
<v-container class="content-container mx-auto">
|
|
|
|
<div class="my-3 flex flex-row gap-4">
|
|
|
|
<v-avatar :image="post.author?.avatar" />
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<span>{{ post.author?.nick }} <span class="text-xs">@{{ post.author?.name }}</span></span>
|
|
|
|
<span v-if="post.body?.title" class="text-md">{{ post.body?.title }}</span>
|
|
|
|
<span v-if="post.body?.description" class="text-sm">{{ post.body?.description }}</span>
|
|
|
|
<span v-if="!post.body?.title && !post.body?.description" class="text-sm">{{ post.author?.description }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-08-10 18:17:20 +00:00
|
|
|
<v-card v-if="post.body?.thumbnail" class="mb-5">
|
|
|
|
<v-img
|
|
|
|
:src="`${config.public.solarNetworkApi}/cgi/files/attachments/${post.body?.thumbnail}`"
|
|
|
|
:aspect-ratio="16 / 9"
|
|
|
|
cover
|
|
|
|
/>
|
|
|
|
</v-card>
|
|
|
|
|
2024-08-10 13:16:36 +00:00
|
|
|
<article class="text-base prose xl:text-lg mx-auto">
|
2024-08-10 07:00:17 +00:00
|
|
|
<m-d-c :value="post.body?.content"></m-d-c>
|
|
|
|
</article>
|
|
|
|
|
|
|
|
<v-card v-if="post.body?.attachments?.length > 0" class="mb-5">
|
2024-08-11 06:53:58 +00:00
|
|
|
<attachment-carousel :attachments="post.body?.attachments" @update:metadata="args => attachments = args" />
|
2024-08-10 07:00:17 +00:00
|
|
|
</v-card>
|
|
|
|
|
|
|
|
<div class="mb-3 text-sm flex flex-col">
|
|
|
|
<span class="flex flex-row gap-1">
|
|
|
|
<span>
|
|
|
|
{{ post.metric.reply_count }} {{ post.metric.reply_count > 1 ? "replies" : "reply" }},
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{ post.metric.reaction_count }} {{ post.metric.reaction_count > 1 ? "reactions" : "reaction" }}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{ post.type.startsWith("a") ? "An" : "A" }} {{ post.type }} posted on
|
|
|
|
{{ new Date(post.published_at).toLocaleString() }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
2024-08-10 08:09:17 +00:00
|
|
|
<div v-if="post.tags?.length > 0" class="text-xs text-grey flex flex-row gap-1 mb-3">
|
|
|
|
<span v-for="tag in post.tags">#{{ tag.alias }}</span>
|
|
|
|
</div>
|
|
|
|
|
2024-08-10 07:00:17 +00:00
|
|
|
<div class="text-xs text-grey flex flex-col">
|
|
|
|
<span>Solar Network Post Web Preview</span>
|
|
|
|
<span>To get full view of this post, open it on <a class="underline" :href="externalOpenLink">Solian</a></span>
|
|
|
|
</div>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
2024-08-10 05:26:58 +00:00
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-08-10 07:00:17 +00:00
|
|
|
const route = useRoute()
|
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
2024-08-11 06:53:58 +00:00
|
|
|
const attachments = ref<any[]>([])
|
2024-08-11 15:49:15 +00:00
|
|
|
const firstImage = ref<string | null>()
|
|
|
|
const firstVideo = ref<string | null>()
|
2024-08-11 06:53:58 +00:00
|
|
|
|
2024-08-10 07:00:17 +00:00
|
|
|
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${route.params.id}`)
|
|
|
|
|
2024-08-11 04:40:20 +00:00
|
|
|
if (!post.value) {
|
|
|
|
throw createError({
|
|
|
|
statusCode: 404,
|
2024-08-11 06:53:58 +00:00
|
|
|
statusMessage: "Post Not Found",
|
2024-08-11 04:40:20 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-08-10 19:01:23 +00:00
|
|
|
const title = computed(() => post.value.body?.title ? `${post.value.body?.title} from ${post.value.author.nick}` : `Post from ${post.value.author.nick}`)
|
2024-08-11 06:53:58 +00:00
|
|
|
const description = computed(() => post.value.body?.description ?? post.value.body?.content.substring(0, 160).trim())
|
|
|
|
|
|
|
|
watch(attachments, (value) => {
|
|
|
|
if (post.value.body?.thumbnail) {
|
|
|
|
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${post.value.body?.thumbnail}`
|
|
|
|
}
|
|
|
|
if (value.length > 0 && value[0].mimetype.split("/")[0] == "image") {
|
|
|
|
firstImage.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value.length > 0 && value[0].mimetype.split("/")[0] == "video") {
|
|
|
|
firstVideo.value = `${config.public.solarNetworkApi}/cgi/files/attachments/${attachments.value[0].id}`
|
|
|
|
}
|
|
|
|
}, { immediate: true, deep: true })
|
2024-08-10 19:01:23 +00:00
|
|
|
|
2024-08-10 05:26:58 +00:00
|
|
|
useHead({
|
2024-08-10 19:01:23 +00:00
|
|
|
title: title.value,
|
2024-08-10 07:00:17 +00:00
|
|
|
titleTemplate: "%s on Solar Network",
|
2024-08-10 14:34:29 +00:00
|
|
|
link: [
|
|
|
|
{ rel: "icon", type: "image/png", href: "/favicon-solian.png" },
|
|
|
|
{ rel: "apple-touch-icon", type: "image/png", href: "/favicon-solian.png" },
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
useSeoMeta({
|
2024-08-10 18:17:20 +00:00
|
|
|
author: post.value.author.nick,
|
2024-08-11 06:53:58 +00:00
|
|
|
title: title,
|
2024-08-10 18:17:20 +00:00
|
|
|
articlePublishedTime: post.value.publishedAt,
|
2024-08-11 06:53:58 +00:00
|
|
|
description: description,
|
|
|
|
ogTitle: title,
|
|
|
|
ogDescription: description,
|
|
|
|
ogUrl: `${useRuntimeConfig().public.siteUrl}${route.fullPath}`,
|
|
|
|
ogImage: firstImage,
|
|
|
|
ogVideo: firstVideo,
|
2024-08-11 07:36:56 +00:00
|
|
|
ogType: "article",
|
|
|
|
publisher: "Solar Network",
|
|
|
|
ogSiteName: "Solsynth Capital",
|
2024-08-10 05:26:58 +00:00
|
|
|
})
|
2024-08-10 07:00:17 +00:00
|
|
|
|
|
|
|
const externalOpenLink = computed(() => `${config.public.solianUrl}/posts/view/${route.params.id}`)
|
2024-08-10 05:26:58 +00:00
|
|
|
</script>
|
2024-08-10 07:00:17 +00:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.content-container {
|
|
|
|
max-width: 65ch !important;
|
|
|
|
}
|
|
|
|
</style>
|