update note parser

This commit is contained in:
Ren Amamiya
2023-05-07 12:42:40 +07:00
parent 730f3be016
commit c39987ff1c
4 changed files with 27 additions and 27 deletions

View File

@@ -1,6 +1,5 @@
import ImagePreview from '@lume/app/note/components/preview/image';
import VideoPreview from '@lume/app/note/components/preview/video';
import { NoteQuote } from '@lume/app/note/components/quote';
import { NoteMentionUser } from '@lume/app/note/components/user/mention';
import ReactMarkdown from 'react-markdown';
@@ -14,9 +13,7 @@ export const NoteContent = ({ content }: { content: any }) => {
linkTarget="_blank"
className="prose prose-zinc max-w-none select-text break-words dark:prose-invert prose-p:text-[15px] prose-p:leading-tight prose-a:text-[15px] prose-a:leading-tight prose-a:text-fuchsia-500 prose-a:no-underline hover:prose-a:text-fuchsia-600 hover:prose-a:underline prose-ol:mb-1 prose-ul:mb-1 prose-li:text-[15px] prose-li:leading-tight"
components={{
h5: ({ ...props }) => <NoteMentionUser pubkey={props.content} />,
h6: ({ ...props }) => <NoteQuote id={props.content} />,
em: ({ ...props }) => <span className="text-fuchsia-500 hover:text-fuchsia-600" {...props} />,
em: ({ ...props }) => <NoteMentionUser {...props} />,
}}
>
{content.parsed}

View File

@@ -1,7 +1,8 @@
import { useProfile } from '@lume/utils/hooks/useProfile';
import { shortenKey } from '@lume/utils/shortenKey';
export const NoteMentionUser = ({ pubkey }: { pubkey: string }) => {
export const NoteMentionUser = (props: { children: any[] }) => {
const pubkey = props.children[0];
const { user } = useProfile(pubkey);
return <span className="cursor-pointer text-fuchsia-500">@{user?.username || user?.name || shortenKey(pubkey)}</span>;