1
1
<template >
2
2
<div >
3
- <h1 >
4
- {{ post.title || post.name }}
5
- </h1 >
3
+ <component :is =" isDetail ? 'h1' : 'h2'" >
4
+ <NuxtLink v-if =" !isDetail" :to =" postLink" >{{ displayTitle }}</NuxtLink >
5
+ <template v-else >{{ displayTitle }}</template >
6
+ </component >
6
7
<NSFWShield v-if =" post.nsfw" :width =" post.width" :height =" post.height" >
7
- <PostMedia :post =" post" />
8
+ <PostMedia :post =" post" :post-link = " postLink " />
8
9
</NSFWShield >
9
- <PostMedia v-else :post =" post" />
10
+ <PostMedia v-else :post =" post" :post-link = " postLink " />
10
11
<!-- eslint-disable-next-line vue/no-v-html -->
11
12
<div v-html =" formattedDescription" />
12
13
<ul >
13
14
<li >Comment Count: {{ post.comments }}</li >
14
15
<li >Views: {{ post.views }}</li >
15
16
<li >Likes: {{ post.likes }}</li >
16
17
<li >Saves: {{ post.saves }}</li >
17
- <li >NSFW: {{ post.nsfw }}</li >
18
18
<li >
19
19
Posted at:
20
- <NuxtLink :to =" `/post/${post.sharekey} `" >
20
+ <NuxtLink :to =" `postLink `" >
21
21
{{ post.posted_at }}
22
22
</NuxtLink >
23
23
</li >
24
24
<li v-if =" post.user" >
25
25
Posted by:
26
- <nuxt-link :to =" `/user/${post.user.name}`" >
26
+ <NuxtLink :to =" `/user/${post.user.name}`" >
27
27
{{ post.user.name }}
28
- </nuxt-link >
28
+ </NuxtLink >
29
29
<img
30
30
v-if =" post.user.profile_image_url"
31
31
:src =" post.user.profile_image_url"
32
32
alt =" "
33
- width =" 50 "
33
+ width =" 20 "
34
34
/>
35
35
</li >
36
36
</ul >
@@ -42,11 +42,25 @@ import { MltshpFile } from '~/types/MltshpFile';
42
42
43
43
const props = defineProps <{
44
44
post: MltshpFile ;
45
- isOwnPost : boolean ;
45
+ isDetail : boolean ;
46
46
}>();
47
47
48
48
// Apply formatting to the post description
49
49
const formattedDescription = computed (() =>
50
50
simpleFormatter (props .post .description ?? ' ' )
51
51
);
52
+
53
+ // Link to the original URL on detail, the detail page otherwise
54
+ const postLink = computed (() =>
55
+ props .isDetail
56
+ ? props .post .original_image_url
57
+ : ` /post/${props .post .sharekey } `
58
+ );
59
+
60
+ // If no title, display filename. If no filename, display sharekey.
61
+ const displayTitle = computed (() => {
62
+ if (props .post .title ) return props .post .title ;
63
+ if (props .post .name ) return props .post .name ;
64
+ return props .post .sharekey ;
65
+ });
52
66
</script >
0 commit comments