(resource: Resource)
| 38 | * ``` |
| 39 | */ |
| 40 | export 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 | |
| 66 | async function propertyLine( |
| 67 | propertySubject: string, |
nothing calls this directly
no test coverage detected