File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Changelog
5
5
------------------
6
6
7
7
* Add CSS style for experimental feature
8
+ * Fix an issue with loading JSON files when running as a dependency via npx.
8
9
9
10
10
11
1.1.1 (2024-02-01)
Original file line number Diff line number Diff line change @@ -2,12 +2,21 @@ import * as React from 'react';
2
2
import { Link } from 'ketting' ;
3
3
import { PageProps } from '../types.js' ;
4
4
import { readFileSync } from 'node:fs' ;
5
+ import { fileURLToPath } from 'node:url' ;
6
+ import * as path from 'node:path' ;
5
7
6
8
type LinkDescriptions = Record < string , { href : string ; description : string } > ;
7
9
8
10
function loadLinkData ( fileName : string ) {
9
11
return JSON . parse (
10
- readFileSync ( new URL ( import . meta. url + '/..' ) . pathname + '../../data/' + fileName + '.json' , 'utf-8' )
12
+ readFileSync (
13
+ path . join (
14
+ fileURLToPath ( new URL ( import . meta. url + '/..' ) ) ,
15
+ '../../data/' ,
16
+ fileName + '.json'
17
+ ) ,
18
+ 'utf-8'
19
+ )
11
20
) ;
12
21
}
13
22
You can’t perform that action at this time.
0 commit comments