Skip to content

Commit

Permalink
fix: allow non-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Jun 11, 2024
1 parent d523557 commit 70b2a90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const makeUseMDXComponents = (more: ReturnType<UseMdxComponents> = {}): UseMdxCo
const run = async (string: string, _opts: RunOpts = {}) => {
const { Fragment } = runtime as any;
const { components = {}, terms, variables, baseUrl, ...opts } = _opts;
const defaults = Object.fromEntries(Object.entries(components).map(([tag, module]) => [tag, module.default]));
const defaults = Object.fromEntries(
Object.entries(components).map(([tag, module]) => [tag, 'default' in module ? module.default : module]),
);

const exec = (text: string, { useMDXComponents = makeUseMDXComponents(defaults) }: RunOpts = {}) => {
return mdxRun(text, {
Expand Down

0 comments on commit 70b2a90

Please sign in to comment.