minor fixes

This commit is contained in:
Ren Amamiya
2023-06-01 14:44:33 +07:00
parent 4e132582b0
commit ea3e5a69f6
15 changed files with 326 additions and 248 deletions

View File

@@ -41,10 +41,7 @@ export function noteParser(event: Event) {
// map hashtag to em
content.original.match(/#(\w+)(?!:\/\/)/g)?.forEach((item) => {
content.parsed = content.parsed.replace(
item,
` [${item}](https://primal.net/search/${item})`,
);
content.parsed = content.parsed.replace(item, `[${item}](/search/${item})`);
});
// handle nostr mention
@@ -58,7 +55,10 @@ export function noteParser(event: Event) {
}
if (profile) {
content.parsed = content.parsed.replace(item.text, `*${profile.pubkey}*`);
content.parsed = content.parsed.replace(
item.text,
`[${profile.pubkey}](/user?pubkey=${profile.pubkey})`,
);
}
});

View File

@@ -1,5 +1,9 @@
import destr from "destr";
export function truncateContent(str, n) {
return str.length > n ? `${str.slice(0, n - 1)}…` : str;
}
// convert NIP-02 to array of pubkey
export function nip02ToArray(tags: any) {
const arr = [];