2024-11-30 02:19:32 +01:00
|
|
|
<template>
|
2025-12-09 23:26:59 +01:00
|
|
|
<div class="flex items-start justify-between">
|
|
|
|
|
<div class="flex items-center gap-3">
|
|
|
|
|
<NuxtLink :href="urlAsPath">
|
2026-01-09 21:47:12 +01:00
|
|
|
<Avatar :src="author.avatar" :name="author.display_name" />
|
2025-12-09 23:26:59 +01:00
|
|
|
</NuxtLink>
|
|
|
|
|
<div class="flex flex-col gap-0.5">
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<span
|
|
|
|
|
class="text-sm font-semibold"
|
|
|
|
|
v-render-emojis="author.emojis"
|
|
|
|
|
>{{ author.display_name }}</span
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="flex items-center gap-1 text-muted-foreground text-xs"
|
2025-12-09 22:32:22 +01:00
|
|
|
>
|
2025-12-09 23:26:59 +01:00
|
|
|
<span>
|
|
|
|
|
@{{ `${username}${instance ? `@${instance}` : ""}` }}
|
|
|
|
|
</span>
|
|
|
|
|
<span>·</span>
|
|
|
|
|
<span>{{ timeAgo }}</span>
|
|
|
|
|
</div>
|
2025-07-10 05:13:42 +02:00
|
|
|
</div>
|
2024-11-30 02:19:32 +01:00
|
|
|
</div>
|
2025-12-09 23:26:59 +01:00
|
|
|
<Menu
|
|
|
|
|
:api-note-string="apiNoteString"
|
|
|
|
|
:url="noteUrl"
|
|
|
|
|
:remote-url="remoteUrl"
|
|
|
|
|
:is-remote="isRemote"
|
|
|
|
|
:author-id="author.id"
|
|
|
|
|
@edit="emit('edit')"
|
|
|
|
|
:note-id="noteId"
|
|
|
|
|
@delete="emit('delete')"
|
|
|
|
|
>
|
|
|
|
|
<Button variant="ghost" size="icon">
|
2026-01-09 21:47:12 +01:00
|
|
|
<Ellipsis />
|
2025-12-09 23:26:59 +01:00
|
|
|
</Button>
|
|
|
|
|
</Menu>
|
2024-11-30 18:21:40 +01:00
|
|
|
</div>
|
2024-11-30 02:19:32 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { Account, Status } from "@versia/client/schemas";
|
2024-12-02 11:17:25 +01:00
|
|
|
import type {
|
|
|
|
|
UseTimeAgoMessages,
|
|
|
|
|
UseTimeAgoUnitNamesDefault,
|
|
|
|
|
} from "@vueuse/core";
|
2025-12-09 23:26:59 +01:00
|
|
|
import { AtSign, Ellipsis, Globe, Lock, LockOpen } from "lucide-vue-next";
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { z } from "zod";
|
2025-07-16 07:48:39 +02:00
|
|
|
import { getLocale } from "~~/paraglide/runtime";
|
2024-12-03 14:07:00 +01:00
|
|
|
import Avatar from "../profiles/avatar.vue";
|
2025-12-09 23:26:59 +01:00
|
|
|
import { Button } from "../ui/button";
|
|
|
|
|
import Menu from "./menu.vue";
|
2024-11-30 02:19:32 +01:00
|
|
|
|
2024-12-04 12:47:17 +01:00
|
|
|
const { createdAt, noteUrl, author, authorUrl } = defineProps<{
|
2024-11-30 16:21:16 +01:00
|
|
|
cornerAvatar?: string;
|
2025-05-26 11:19:15 +02:00
|
|
|
visibility: z.infer<typeof Status.shape.visibility>;
|
2024-12-02 22:29:08 +01:00
|
|
|
noteUrl: string;
|
2024-11-30 02:19:32 +01:00
|
|
|
createdAt: Date;
|
2025-05-26 11:19:15 +02:00
|
|
|
author: z.infer<typeof Account>;
|
2024-12-04 12:47:17 +01:00
|
|
|
authorUrl: string;
|
2025-12-09 23:26:59 +01:00
|
|
|
remoteUrl?: string;
|
|
|
|
|
apiNoteString: string;
|
|
|
|
|
isRemote: boolean;
|
|
|
|
|
noteId: string;
|
2024-11-30 02:19:32 +01:00
|
|
|
}>();
|
|
|
|
|
|
2024-12-04 12:47:17 +01:00
|
|
|
const [username, instance] = author.acct.split("@");
|
2024-12-02 11:17:25 +01:00
|
|
|
const digitRegex = /\d/;
|
2024-12-04 12:47:17 +01:00
|
|
|
const urlAsPath = new URL(authorUrl).pathname;
|
2024-12-02 22:29:08 +01:00
|
|
|
const noteUrlAsPath = new URL(noteUrl).pathname;
|
2024-12-02 11:17:25 +01:00
|
|
|
const timeAgo = useTimeAgo(createdAt, {
|
|
|
|
|
messages: {
|
|
|
|
|
justNow: "now",
|
|
|
|
|
past: (n) => (n.match(digitRegex) ? `${n}` : n),
|
|
|
|
|
future: (n) => (n.match(digitRegex) ? `in ${n}` : n),
|
|
|
|
|
month: (n) => `${n}mo`,
|
|
|
|
|
year: (n) => `${n}y`,
|
|
|
|
|
day: (n) => `${n}d`,
|
|
|
|
|
week: (n) => `${n}w`,
|
|
|
|
|
hour: (n) => `${n}h`,
|
|
|
|
|
minute: (n) => `${n}m`,
|
|
|
|
|
second: (n) => `${n}s`,
|
|
|
|
|
invalid: "",
|
|
|
|
|
} as UseTimeAgoMessages<UseTimeAgoUnitNamesDefault>,
|
|
|
|
|
});
|
2025-02-14 14:08:21 +01:00
|
|
|
const fullTime = new Intl.DateTimeFormat(getLocale(), {
|
2024-11-30 02:19:32 +01:00
|
|
|
dateStyle: "medium",
|
|
|
|
|
timeStyle: "short",
|
|
|
|
|
}).format(createdAt);
|
2024-12-04 12:47:17 +01:00
|
|
|
const popupOpen = ref(false);
|
2024-11-30 02:19:32 +01:00
|
|
|
|
2025-12-09 23:26:59 +01:00
|
|
|
const emit = defineEmits<{
|
|
|
|
|
edit: [];
|
|
|
|
|
delete: [];
|
|
|
|
|
}>();
|
|
|
|
|
|
2024-11-30 02:19:32 +01:00
|
|
|
const visibilities = {
|
|
|
|
|
public: {
|
|
|
|
|
icon: Globe,
|
|
|
|
|
text: "This note is public: it can be seen by anyone.",
|
|
|
|
|
},
|
|
|
|
|
unlisted: {
|
|
|
|
|
icon: LockOpen,
|
|
|
|
|
text: "This note is unlisted: it can be seen by anyone with the link.",
|
|
|
|
|
},
|
|
|
|
|
private: {
|
|
|
|
|
icon: Lock,
|
|
|
|
|
text: "This note is private: it can only be seen by followers.",
|
|
|
|
|
},
|
|
|
|
|
direct: {
|
|
|
|
|
icon: AtSign,
|
|
|
|
|
text: "This note is direct: it can only be seen by mentioned users.",
|
|
|
|
|
},
|
|
|
|
|
};
|
2024-12-31 15:55:02 +01:00
|
|
|
</script>
|