MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / useMarkdown

Function useMarkdown

react/src/useMarkdown.ts:40–64  ·  view source on GitHub ↗
(resource: Resource)

Source from the content-addressed store, hash-verified

38 * ```
39 */
40export function useMarkdown(resource: Resource): string {
41 const title = useTitle(resource);
42 const [description] = useString(resource, urls.properties.description);
43 const [md, setMd] = useState(`# ${title}`);
44 const store = useStore();
45
46 useEffect(() => {
47 async function getPropValTexts() {
48 let propValLines = '';
49 for await (const [prop, val] of resource.getPropVals()) {
50 if (!hiddenProps.includes(prop)) {
51 propValLines = propValLines + (await propertyLine(prop, val, store));
52 }
53 }
54 setMd(`# ${title}` + propValLines + '\n\n' + description);
55 }
56 getPropValTexts();
57 }, [resource]);
58
59 if (resource.error) {
60 return resource.error.message;
61 }
62
63 return md;
64}
65
66async function propertyLine(
67 propertySubject: string,

Callers

nothing calls this directly

Calls 4

useTitleFunction · 0.85
useStringFunction · 0.85
useStoreFunction · 0.85
getPropValTextsFunction · 0.85

Tested by

no test coverage detected