summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2022-01-29 15:55:09 +0100
committerGitHub <[email protected]>2022-01-29 15:55:09 +0100
commit5a93993de3163fa88ce2a9d341371d62bc4e13d5 (patch)
tree86730114dde5d3bd872f088ead3d684fb50392cb /util
parentf1e1769d97e4f44d7336839db587b0acbb918d99 (diff)
parent7da981397e9f0700d39d144b2b2591c127f2786a (diff)
Merge pull request #208 from org-roam/fix/106
Diffstat (limited to 'util')
-rw-r--r--util/processOrg.tsx26
-rw-r--r--util/uniorg.tsx4
2 files changed, 19 insertions, 11 deletions
diff --git a/util/processOrg.tsx b/util/processOrg.tsx
index e139c41..aa0118d 100644
--- a/util/processOrg.tsx
+++ b/util/processOrg.tsx
@@ -33,6 +33,10 @@ import { Section } from '../components/Sidebar/Section'
import { NoteContext } from './NoteContext'
import { OrgRoamLink, OrgRoamNode } from '../api'
+// @ts-expect-error non-ESM unified means no types
+import { toString } from 'hast-util-to-string'
+import { Box } from '@chakra-ui/react'
+
export interface ProcessedOrgProps {
nodeById: NodeById
previewNode: OrgRoamNode
@@ -63,6 +67,7 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
macros,
attachDir,
} = props
+
if (!previewNode || !linksByNodeId) {
return null
}
@@ -96,7 +101,6 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
}
const wikiLinkProcessor = (wikiLink: string): string => {
- console.log(wikiLink)
return `id:${wikiLink}`
}
@@ -160,11 +164,18 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
img: ({ src }) => {
return <OrgImage src={src as string} file={previewNode?.file} />
},
- section: ({ children, className }) => (
- <Section {...{ outline, collapse }} className={className as string}>
- {children}
- </Section>
- ),
+ section: ({ children, className }) => {
+ console.log(className)
+ console.log(previewNode.level)
+ if (className && (className as string).slice(-1) === `${previewNode.level}`) {
+ return <Box>{(children as React.ReactElement[]).slice(1)}</Box>
+ }
+ return (
+ <Section {...{ outline, collapse }} className={className as string}>
+ {children}
+ </Section>
+ )
+ },
p: ({ children }) => {
return <p lang="en">{children as ReactNode}</p>
},
@@ -178,6 +189,3 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
<NoteContext.Provider value={{ collapse, outline }}>{text as ReactNode}</NoteContext.Provider>
)
}
-function useCallBack(arg0: () => unified.Processor<unified.Settings>) {
- throw new Error('Function not implemented.')
-}
diff --git a/util/uniorg.tsx b/util/uniorg.tsx
index c4407f2..6580b9c 100644
--- a/util/uniorg.tsx
+++ b/util/uniorg.tsx
@@ -34,9 +34,9 @@ export const UniOrg = (props: UniOrgProps) => {
const [previewText, setPreviewText] = useState('')
- const file = encodeURIComponent(encodeURIComponent(previewNode.file))
+ const id = encodeURIComponent(encodeURIComponent(previewNode.id))
useEffect(() => {
- fetch(`http://localhost:35901/file/${file}`)
+ fetch(`http://localhost:35901/node/${id}`)
.then((res) => {
return res.text()
})