mirror of
https://github.com/dergigi/boris.git
synced 2025-12-25 10:34:28 +01:00
- Add project structure with TypeScript, React, and Vite - Implement nostr authentication using browser extension (NIP-07) - Add NIP-51 compliant bookmark fetching and display - Create minimal UI with login and bookmark components - Integrate applesauce-core and applesauce-react libraries - Add responsive styling with dark/light mode support - Include comprehensive README with setup instructions This is a minimal MVP for a nostr bookmark client that allows users to view their bookmarks according to NIP-51 specification.
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import { unified } from "unified";
|
|
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
import { nostrMentions } from "./mentions.js";
|
|
import { cashuTokens } from "./cashu.js";
|
|
import { emojis } from "./emoji.js";
|
|
import { createEventContentTree } from "./parser.js";
|
|
import { hashtags } from "./hashtag.js";
|
|
import { galleries } from "./gallery.js";
|
|
import { lightningInvoices } from "./lightning.js";
|
|
import { eolMetadata } from "../nast/eol-metadata.js";
|
|
import { links } from "./links.js";
|
|
export const TextNoteContentSymbol = Symbol.for("text-note-content");
|
|
// default kind 1 transformers
|
|
export const textNoteTransformers = [
|
|
links,
|
|
nostrMentions,
|
|
galleries,
|
|
emojis,
|
|
hashtags,
|
|
lightningInvoices,
|
|
cashuTokens,
|
|
eolMetadata,
|
|
];
|
|
/** Parsed and process a note with custom transformers */
|
|
export function getParsedContent(event, content, transformers = textNoteTransformers, cacheKey = TextNoteContentSymbol) {
|
|
// process strings
|
|
if (typeof event === "string") {
|
|
const processor = unified();
|
|
for (const transformer of transformers) {
|
|
processor.use(transformer);
|
|
}
|
|
return processor.runSync(createEventContentTree(event, content));
|
|
}
|
|
// no caching
|
|
if (!cacheKey) {
|
|
const processor = unified();
|
|
for (const transformer of transformers) {
|
|
processor.use(transformer);
|
|
}
|
|
return processor.runSync(createEventContentTree(event, content));
|
|
}
|
|
return getOrComputeCachedValue(event, cacheKey, () => {
|
|
const processor = unified();
|
|
for (const transformer of transformers) {
|
|
processor.use(transformer);
|
|
}
|
|
return processor.runSync(createEventContentTree(event, content));
|
|
});
|
|
}
|
|
export function removeParsedTextContent(event) {
|
|
// @ts-expect-error
|
|
delete event[TextNoteContentSymbol];
|
|
}
|