updated newsfeed note ui

This commit is contained in:
Ren Amamiya
2023-04-17 14:01:09 +07:00
parent 8b67253c0a
commit dfe5e4533e
14 changed files with 75 additions and 92 deletions

View File

@@ -7,7 +7,7 @@ import destr from 'destr';
import reactStringReplace from 'react-string-replace';
export const contentParser = (noteContent, noteTags) => {
let parsedContent = noteContent;
let parsedContent = noteContent.trim();
// get data tags
const tags = destr(noteTags);
@@ -24,7 +24,7 @@ export const contentParser = (noteContent, noteTags) => {
return <VideoPreview key={match + i} url={match} />;
} else {
return (
<a key={match + i} href={match} target="_blank" rel="noreferrer">
<a key={match + i} href={match} className="cursor-pointer text-fuchsia-500" target="_blank" rel="noreferrer">
{match}
</a>
);
@@ -55,7 +55,7 @@ export const contentParser = (noteContent, noteTags) => {
};
export const messageParser = (noteContent) => {
let parsedContent = noteContent;
let parsedContent = noteContent.trim();
// handle urls
parsedContent = reactStringReplace(parsedContent, /(https?:\/\/\S+)/g, (match, i) => {
@@ -70,7 +70,7 @@ export const messageParser = (noteContent) => {
return <VideoPreview key={match + i} url={match} />;
} else {
return (
<a key={match + i} href={match} target="_blank" rel="noreferrer">
<a key={match + i} href={match} className="cursor-pointer text-fuchsia-500" target="_blank" rel="noreferrer">
{match}
</a>
);

6
src/utils/shortenKey.tsx Normal file
View File

@@ -0,0 +1,6 @@
import { nip19 } from 'nostr-tools';
export const shortenKey = (pubkey: string) => {
const npub = nip19.npubEncode(pubkey);
return npub.substring(0, 16).concat('...');
};