Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pngwn committed Aug 17, 2024
1 parent 09e4e30 commit 83da63f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/mdsvex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import extract_frontmatter from 'remark-frontmatter';
import remark2rehype from 'remark-rehype';
//@ts-ignore
import hast_to_html from '@starptech/prettyhtml-hast-to-html';
import { createRequire } from 'module';

import { mdsvex_parser } from './parsers';
import {
Expand Down Expand Up @@ -126,13 +127,15 @@ function to_posix(_path: string): string {
return _path.replace(/\\/g, '/');
}

const _require = import.meta.url ? createRequire(import.meta.url) : require;

function resolve_layout(layout_path: string): string {
try {
return to_posix(require.resolve(layout_path));
return to_posix(_require.resolve(layout_path));
} catch (e) {
try {
const _path = join(process.cwd(), layout_path);
return to_posix(require.resolve(_path));
return to_posix(_require.resolve(_path));
} catch (e) {
throw new Error(
`The layout path you provided couldn't be found at either ${layout_path} or ${join(
Expand Down

0 comments on commit 83da63f

Please sign in to comment.