Skip to content

Commit 497930e

Browse files
committed
Stop using json imports :'(
1 parent 6a88c25 commit 497930e

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
1.0.1 (????-??-??)
5+
------------------
6+
7+
* Fix weird Typescript / Node disagreement on whether JSON import assertions
8+
are required or forbidden
9+
10+
411
1.0.0 (2024-01-15)
512
------------------
613

src/components/links-table.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import * as React from 'react';
22
import { Link } from 'ketting';
33
import { PageProps } from '../types.js';
4-
5-
// List of links from the IANA website, auto generated
6-
import ianaLinks from '../data/iana-links.json';
7-
// List of links from this project, overrides some IANA links with better
8-
// descriptions
9-
import editorLinks from '../data/editor-links.json';
10-
//List of links from the Level 3 REST (https://level3.rest) specification.
11-
import level3RestLinks from '../data/level3-rest-links.json';
4+
import { readFileSync } from 'node:fs';
125

136
type LinkDescriptions = Record<string, {href: string; description: string}>;
147

8+
function loadLinkData(fileName: string) {
9+
return JSON.parse(
10+
readFileSync(new URL(import.meta.url + '/..').pathname + '/../data/' + fileName + '.json', 'utf-8')
11+
);
12+
}
13+
1514
const linkDescriptions: LinkDescriptions = {
16-
...ianaLinks,
17-
...editorLinks,
18-
...level3RestLinks
15+
...loadLinkData('iana-links'),
16+
...loadLinkData('editor-links'),
17+
...loadLinkData('level3-rest-links')
1918
};
2019

2120
export function LinksTable(props: PageProps) {

0 commit comments

Comments
 (0)