Skip to content

Commit

Permalink
fix: preparser
Browse files Browse the repository at this point in the history
  • Loading branch information
oripka committed Nov 18, 2024
1 parent 434df02 commit 5b931c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/slidev/node/setups/preparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { loadSetups } from './load'

export default function setupPreparser() {
injectPreparserExtensionLoader(async (headmatter: Record<string, unknown>, filepath: string, mode?: string) => {
const addons = headmatter?.addons as string[]
// if (!addons?.length)
// return []
// Ensure addons is an array or an empty array if undefined
const addons = Array.isArray(headmatter?.addons) ? headmatter.addons as string[] : []

const { userRoot } = await getRoots()
const roots = uniq([
...await resolveAddons(addons),
userRoot,
])

const returns = await loadSetups<PreparserSetup>(roots, 'preparser.ts', [{ filepath, headmatter, mode }])
return returns.flat()
})
Expand Down

0 comments on commit 5b931c7

Please sign in to comment.