Skip to content

Commit

Permalink
refactor: obsidian reference plugin with processor
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Mar 21, 2024
1 parent 7ec5406 commit 50e8657
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { toMarkdown } from 'mdast-util-to-markdown'
import { remark } from 'remark'
import remarkFrontmatter from 'remark-frontmatter'
import remarkHtml from 'remark-html'
import type { Plugin } from 'unified'
import type { Literal, Parent } from 'unist'
Expand Down Expand Up @@ -95,10 +94,10 @@ const RemarkObsidianReferencePlugin: Plugin<

export const ObsidianReference =
(): BuilderPlugin['build:contents'] =>
async ({ io }) => {
async ({ io, processor }) => {
return {
name: 'ObsidianReference',
modifier: async (buildStore) => {
modifier: async ({ buildStore }) => {
const assetReferencesUUIDList = buildStore
.filter(
({ file_type }) =>
Expand Down Expand Up @@ -128,12 +127,12 @@ export const ObsidianReference =
textFile.build_path.build
)
if (textFileContent.success) {
const updatedVFile = await remark()
const updatedVFile = await processor
.remark()
.use(RemarkObsidianReferencePlugin, {
imageReference: assetReferencesUUIDList,
io,
})
.use(remarkFrontmatter)
.process(textFileContent.data)

awaitedAcc.push({
Expand All @@ -143,6 +142,7 @@ export const ObsidianReference =
}
return acc
}, Promise.resolve([]))

return referenceUpdatedList
},
}
Expand Down

0 comments on commit 50e8657

Please sign in to comment.