Skip to content

Commit

Permalink
refactor mdx-loader logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 2, 2024
1 parent 2071832 commit ca6f060
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions code/addons/docs/src/mdx-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type MdxCompileOptions = Parameters<typeof mdxCompile>[1];
export type BabelOptions = Parameters<typeof transformAsync>[1];

export interface CompileOptions {
skipCsf?: boolean;
mdxCompileOptions?: MdxCompileOptions;
}

Expand All @@ -30,16 +29,14 @@ async function loader(this: LoaderContext, content: string): Promise<void> {
const callback = this.async();
const options = { ...this.getOptions(), filepath: this.resourcePath };

let result: string;
try {
result = await compile(content, options);
const result = await compile(content, options);
const code = `${DEFAULT_RENDERER}\n${result}`;
return callback(null, code);
} catch (err: any) {
console.error('Error loading:', this.resourcePath);
return callback(err);
}

const code = `${DEFAULT_RENDERER}\n${result}`;
return callback(null, code);
}

export default loader;

0 comments on commit ca6f060

Please sign in to comment.