Files
boris/node_modules/applesauce-react/dist/hooks/use-rendered-content.js
Gigi 5d53a827e0 feat: initialize markr nostr bookmark client
- 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.
2025-10-02 07:17:07 +02:00

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);
}