summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-12-04 13:44:47 +0100
committerGitHub <[email protected]>2021-12-04 13:44:47 +0100
commit0062fc08917e9ee70148105fe5134e9f4dcf9aba (patch)
tree43cae6d205afd8fdf4f9e70e93eeecf50b2bc109 /util
parent4edbd2abae11def87284d6f7a4a2e1fd4e122cd6 (diff)
fix: add org-attach-id-dir support (#153)
Diffstat (limited to 'util')
-rw-r--r--util/processOrg.tsx10
-rw-r--r--util/uniorg.tsx5
2 files changed, 12 insertions, 3 deletions
diff --git a/util/processOrg.tsx b/util/processOrg.tsx
index 189e980..e139c41 100644
--- a/util/processOrg.tsx
+++ b/util/processOrg.tsx
@@ -44,7 +44,8 @@ export interface ProcessedOrgProps {
outline: boolean
collapse: boolean
linksByNodeId: LinksByNodeId
- macros?: { [key: string]: string }
+ macros: { [key: string]: string } | {}
+ attachDir: string
}
export const ProcessedOrg = (props: ProcessedOrgProps) => {
@@ -60,6 +61,7 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
collapse,
linksByNodeId,
macros,
+ attachDir,
} = props
if (!previewNode || !linksByNodeId) {
return null
@@ -68,7 +70,9 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
const orgProcessor = unified()
.use(uniorgParse)
.use(extractKeywords)
- .use(attachments)
+ .use(attachments, {
+ idDir: attachDir || undefined,
+ })
.use(uniorgSlug)
.use(uniorg2rehype, { useSections: true })
@@ -146,6 +150,8 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => {
outline={outline}
previewNode={previewNode}
isWiki={isMarkdown}
+ macros={macros}
+ attachDir={attachDir}
>
{children}
</PreviewLink>
diff --git a/util/uniorg.tsx b/util/uniorg.tsx
index 68f0330..c4407f2 100644
--- a/util/uniorg.tsx
+++ b/util/uniorg.tsx
@@ -14,6 +14,7 @@ export interface UniOrgProps {
collapse: boolean
linksByNodeId: LinksByNodeId
macros?: { [key: string]: string }
+ attachDir: string
}
export const UniOrg = (props: UniOrgProps) => {
@@ -28,6 +29,7 @@ export const UniOrg = (props: UniOrgProps) => {
collapse,
linksByNodeId,
macros,
+ attachDir,
} = props
const [previewText, setPreviewText] = useState('')
@@ -69,8 +71,9 @@ export const UniOrg = (props: UniOrgProps) => {
outline,
collapse,
linksByNodeId,
- macros,
+ attachDir,
}}
+ macros={macros || {}}
/>
)}
</>