2
2
<ClientOnly >
3
3
<PostBadgeTimeView
4
4
v-if =" previousTime !== undefined && previousTime < currentTime"
5
- @mouseenter =" previousPost !== undefined
5
+ @mouseenter =" () => previousPost !== undefined
6
6
&& highlightPostStore.set(previousPost, currentPostIDKey)"
7
- @mouseleave =" highlightPostStore.unset()"
7
+ @mouseleave =" () => highlightPostStore.unset()"
8
8
:current =" currentDateTime" :relativeTo =" previousDateTime"
9
9
:relativeToText =" `相对于上一${postType}${timestampType}`"
10
- :postType =" props. postType" :timestampType =" timestampType" v-bind =" $attrs" >
10
+ :postType =" postType" :timestampType =" timestampType" v-bind =" $attrs" >
11
11
<!-- https://github.com/vuejs/language-tools/issues/4798 -->
12
12
<FontAwesome :icon =" faChevronUp" class =" me-1 align-bottom" />
13
13
</PostBadgeTimeView >
14
14
<PostBadgeTimeView
15
15
v-else-if =" nextTime !== undefined && nextTime < currentTime"
16
- @mouseenter =" nextPost !== undefined
16
+ @mouseenter =" () => nextPost !== undefined
17
17
&& highlightPostStore.set(nextPost, currentPostIDKey)"
18
- @mouseleave =" highlightPostStore.unset()"
18
+ @mouseleave =" () => highlightPostStore.unset()"
19
19
:current =" currentDateTime" :relativeTo =" nextDateTime"
20
20
:relativeToText =" `相对于下一${postType}${timestampType}`"
21
- :postType =" props. postType" :timestampType =" timestampType" v-bind =" $attrs" >
21
+ :postType =" postType" :timestampType =" timestampType" v-bind =" $attrs" >
22
22
<FontAwesome :icon =" faChevronDown" class =" me-1 align-bottom" />
23
23
</PostBadgeTimeView >
24
24
<PostBadgeTimeView
25
25
v-else-if =" parentTime !== undefined && parentTime !== currentTime"
26
- @mouseenter =" parentPost !== undefined
26
+ @mouseenter =" () => parentPost !== undefined
27
27
&& parentPostIDKey !== undefined
28
28
&& highlightPostStore.set(parentPost, parentPostIDKey)"
29
- @mouseleave =" highlightPostStore.unset()"
29
+ @mouseleave =" () => highlightPostStore.unset()"
30
30
:current =" currentDateTime" :relativeTo =" parentDateTime"
31
31
:relativeToText =" `相对于所属${postTypeText[postTypeText.indexOf(postType) - 1]}${timestampType}`"
32
- :postType =" props. postType" :timestampType =" timestampType" v-bind =" $attrs" >
32
+ :postType =" postType" :timestampType =" timestampType" v-bind =" $attrs" >
33
33
<FontAwesome :icon =" faAnglesUp" class =" me-1 align-bottom" />
34
34
</PostBadgeTimeView >
35
35
</ClientOnly >
36
36
<PostBadgeTimeView
37
- :current =" currentDateTime" :postType =" props. postType"
37
+ :current =" currentDateTime" :postType =" postType"
38
38
:timestampType =" timestampType" class =" text-end"
39
39
:class =" { 'post-badge-time-current-full': hydrationStore.isHydratingOrSSR }" v-bind =" $attrs" />
40
40
</template >
@@ -54,7 +54,7 @@ import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid-
54
54
import { DateTime } from ' luxon' ;
55
55
56
56
defineOptions ({ inheritAttrs: false });
57
- const props = defineProps <{
57
+ const { previousPost, nextPost, currentPost, parentPost, postTimeKey } = defineProps <{
58
58
previousPost? : TPost ,
59
59
nextPost? : TPost ,
60
60
currentPost: TPost ,
@@ -69,21 +69,22 @@ const props = defineProps<{
69
69
const highlightPostStore = useHighlightPostStore ();
70
70
const hydrationStore = useHydrationStore ();
71
71
72
- useNoScript ( ` <style>
72
+ const noScriptStyle = ` <style>
73
73
.post-badge-time-current-full {
74
74
width: auto !important;
75
75
}
76
- </style> ` );
76
+ </style> ` ; // https://github.com/nuxt/nuxt/issues/13848
77
+ useHead ({ noscript: [{ innerHTML: noScriptStyle }] });
77
78
78
79
// https://github.com/typescript-eslint/typescript-eslint/issues/9723
79
80
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-unnecessary-type-parameters
80
81
const getPostTime = <T extends TPost | TParentPost >(post ? : T ) =>
81
- post ?.[props . postTimeKey as keyof T ] as TPostTimeValue | undefined ;
82
- const previousTime = computed (() => getPostTime (props . previousPost ));
83
- const nextTime = computed (() => getPostTime (props . nextPost ));
84
- const parentTime = computed (() => getPostTime (props . parentPost ));
82
+ post ?.[postTimeKey as keyof T ] as TPostTimeValue | undefined ;
83
+ const previousTime = computed (() => getPostTime (previousPost ));
84
+ const nextTime = computed (() => getPostTime (nextPost ));
85
+ const parentTime = computed (() => getPostTime (parentPost ));
85
86
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86
- const currentTime = computed (() => getPostTime (props . currentPost )! );
87
+ const currentTime = computed (() => getPostTime (currentPost )! );
87
88
88
89
const previousDateTime = computed (() =>
89
90
undefinedOr (previousTime .value , i => DateTime .fromSeconds (i )));
0 commit comments