Skip to content

Commit 9c3dc47

Browse files
committed
Fix loading JSON files when running with npx globally.
1 parent 552fd17 commit 9c3dc47

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog
55
------------------
66

77
* Add CSS style for experimental feature
8+
* Fix an issue with loading JSON files when running as a dependency via npx.
89

910

1011
1.1.1 (2024-02-01)

Diff for: src/components/links-table.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ import * as React from 'react';
22
import { Link } from 'ketting';
33
import { PageProps } from '../types.js';
44
import { readFileSync } from 'node:fs';
5+
import { fileURLToPath } from 'node:url';
6+
import * as path from 'node:path';
57

68
type LinkDescriptions = Record<string, {href: string; description: string}>;
79

810
function loadLinkData(fileName: string) {
911
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+
)
1120
);
1221
}
1322

0 commit comments

Comments
 (0)