use markdown
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { memo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
|
||||
import { createBlock } from '@libs/storage';
|
||||
|
||||
@@ -8,6 +10,8 @@ import { User } from '@shared/user';
|
||||
|
||||
import { useEvent } from '@utils/hooks/useEvent';
|
||||
|
||||
import { MentionUser } from './user';
|
||||
|
||||
export const MentionNote = memo(function MentionNote({ id }: { id: string }) {
|
||||
const { status, data } = useEvent(id);
|
||||
|
||||
@@ -43,7 +47,22 @@ export const MentionNote = memo(function MentionNote({ id }: { id: string }) {
|
||||
) : status === 'success' ? (
|
||||
<>
|
||||
<User pubkey={data.pubkey} time={data.created_at} size="small" />
|
||||
<div className="mt-2 flex items-start gap-3">{data.content.parsed}</div>
|
||||
<div className="mt-2">
|
||||
<ReactMarkdown
|
||||
className="markdown"
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
del: ({ children }) => {
|
||||
const pubkey = children[0] as string;
|
||||
return <MentionUser pubkey={pubkey.slice(3)} />;
|
||||
},
|
||||
}}
|
||||
>
|
||||
{data.content.parsed.length > 200
|
||||
? data.content.parsed.substring(0, 200) + '...'
|
||||
: data.content.parsed}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<p>Failed to fetch event</p>
|
||||
|
||||
@@ -9,7 +9,7 @@ export function MentionUser({ pubkey }: { pubkey: string }) {
|
||||
return (
|
||||
<Link
|
||||
to={`/app/user/${pubkey}`}
|
||||
className="font-normal text-fuchsia-500 no-underline hover:text-fuchsia-600"
|
||||
className="break-words font-normal !text-green-400 no-underline hover:!text-green-500"
|
||||
>
|
||||
@{user?.name || user?.displayName || shortenKey(pubkey)}
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user