mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +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.
17 lines
1.0 KiB
JavaScript
17 lines
1.0 KiB
JavaScript
import { useMemo } from "react";
|
|
import { truncateContent } from "applesauce-content/nast";
|
|
import { getParsedContent } from "applesauce-content/text";
|
|
import { useRenderNast } from "./use-render-nast.js";
|
|
import { buildLinkRenderer } from "../helpers/build-link-renderer.js";
|
|
/** Returns the parsed and render text content for an event */
|
|
export function useRenderedContent(event, components, opts) {
|
|
// if link renderers are set, override the link components
|
|
const _components = useMemo(() => (opts?.linkRenderers ? { ...components, link: buildLinkRenderer(opts.linkRenderers) } : components), [opts?.linkRenderers, components]);
|
|
// add additional transformers
|
|
const nast = useMemo(() => (event ? getParsedContent(event, opts?.content, opts?.transformers, opts?.cacheKey) : undefined), [event, opts?.content, opts?.transformers, opts?.cacheKey]);
|
|
let truncated = nast;
|
|
if (opts?.maxLength && nast)
|
|
truncated = truncateContent(nast, opts.maxLength);
|
|
return useRenderNast(truncated, _components);
|
|
}
|