myst-to-react 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/links/index.d.ts.map +1 -1
- package/dist/links/index.js +7 -5
- package/dist/links/ror.d.ts.map +1 -1
- package/dist/links/ror.js +8 -9
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AActC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAUzE,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA+D1F,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,eAAe,CAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,eAAe,CAiB5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,eAAe,CAI1D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,eAAe,CAQzD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AActC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAUzE,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA+D1F,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,eAAe,CAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,eAAe,CAiB5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,eAAe,CAI1D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,eAAe,CAQzD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,eAAe,CA8BpD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,eAAe,CAoCnD,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,aAerB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/links/index.js
CHANGED
|
@@ -54,11 +54,12 @@ export const RORLinkRenderer = ({ node, className }) => {
|
|
|
54
54
|
return (_jsx(RORLink, { node: node, ror: (_a = node.data) === null || _a === void 0 ? void 0 : _a.ror, className: classNames(node.class, className) }));
|
|
55
55
|
};
|
|
56
56
|
export const SimpleLink = ({ node, className }) => {
|
|
57
|
-
var _a, _b;
|
|
57
|
+
var _a, _b, _c;
|
|
58
58
|
// Internal links will need to be modified by a baseURL (e.g. in static sites).
|
|
59
|
-
const
|
|
59
|
+
const config = useSiteManifest();
|
|
60
|
+
const internal = (_a = node.internal) !== null && _a !== void 0 ? _a : !isExternalUrl(node.url, (_b = config === null || config === void 0 ? void 0 : config.options) === null || _b === void 0 ? void 0 : _b.internal_domains);
|
|
60
61
|
// If the link is static (a link to a document/asset), we can just use the regular link.
|
|
61
|
-
const isStatic = (
|
|
62
|
+
const isStatic = (_c = node.static) !== null && _c !== void 0 ? _c : false;
|
|
62
63
|
if (internal && !isStatic) {
|
|
63
64
|
return (_jsx(InternalLink, { url: node.url, className: classNames(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
|
|
64
65
|
}
|
|
@@ -69,10 +70,11 @@ export const SimpleLink = ({ node, className }) => {
|
|
|
69
70
|
_jsxs("a", { target: "_blank", rel: "noreferrer", href: node.url, className: classNames('link whitespace-nowrap', node.class, className), children: [_jsx("span", { className: "link-text whitespace-normal", children: _jsx(MyST, { ast: node.children }) }), isStatic && _jsx(ArrowDownTrayIcon, { className: "link-icon" }), !isStatic && _jsx(ExternalLinkIcon, { className: "link-icon" })] }));
|
|
70
71
|
};
|
|
71
72
|
export const linkBlock = ({ node, className }) => {
|
|
72
|
-
var _a;
|
|
73
|
+
var _a, _b;
|
|
73
74
|
const iconClass = 'self-center transition-transform flex-none ml-3';
|
|
74
75
|
const containerClass = 'flex-1 p-4 my-5 block border font-normal hover:border-blue-500 dark:hover:border-blue-400 no-underline hover:text-blue-600 dark:hover:text-blue-400 text-gray-600 dark:text-gray-100 border-gray-200 dark:border-gray-500 rounded shadow-sm hover:shadow-lg dark:shadow-neutral-700';
|
|
75
|
-
const
|
|
76
|
+
const config = useSiteManifest();
|
|
77
|
+
const internal = (_a = node.internal) !== null && _a !== void 0 ? _a : !isExternalUrl(node.url, (_b = config === null || config === void 0 ? void 0 : config.options) === null || _b === void 0 ? void 0 : _b.internal_domains);
|
|
76
78
|
const nested = (_jsxs("div", { className: "flex h-full align-middle", children: [_jsxs("div", { className: "flex-grow", children: [node.title, _jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: _jsx(MyST, { ast: node.children }) })] }), internal && _jsx(LinkIcon, { width: "1.5rem", height: "1.5rem", className: iconClass }), !internal && _jsx(ExternalLinkIcon, { width: "1.5rem", height: "1.5rem", className: iconClass })] }));
|
|
77
79
|
if (internal) {
|
|
78
80
|
return (_jsx("a", { href: node.url, className: classNames(containerClass, className), children: nested }));
|
package/dist/links/ror.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ror.d.ts","sourceRoot":"","sources":["../../src/links/ror.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ror.d.ts","sourceRoot":"","sources":["../../src/links/ror.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAwG/C,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,GAAG,EACH,SAAS,GACV,EAAE;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAaA"}
|
package/dist/links/ror.js
CHANGED
|
@@ -4,27 +4,26 @@ import { HoverPopover } from '../components/index.js';
|
|
|
4
4
|
import { MyST } from '../MyST.js';
|
|
5
5
|
import { RorIcon } from '@scienceicons/react/24/solid';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
+
import { useMemo } from 'react';
|
|
7
8
|
const fetcher = (...args) => fetch(...args).then((res) => {
|
|
8
9
|
if (res.status === 200)
|
|
9
10
|
return res.json();
|
|
10
11
|
throw new Error(`Content returned with status ${res.status}.`);
|
|
11
12
|
});
|
|
12
13
|
function RORChild({ ror }) {
|
|
13
|
-
|
|
14
|
-
const {
|
|
14
|
+
const { data, error } = useSWR(`https://api.ror.org/v2/organizations/${ror}`, fetcher);
|
|
15
|
+
const name = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.names.find((n) => n.types.includes('ror_display'))) === null || _a === void 0 ? void 0 : _a.value; }, [data]);
|
|
16
|
+
const countryName = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.locations[0]) === null || _a === void 0 ? void 0 : _a.geonames_details.country_name; }, [data]);
|
|
17
|
+
const links = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.links) !== null && _a !== void 0 ? _a : []; }, [data]);
|
|
18
|
+
const labels = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.names.filter((n) => n.types.includes('label'))) !== null && _a !== void 0 ? _a : []; }, [data]);
|
|
19
|
+
const acronyms = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.names.filter((n) => n.types.includes('acronym'))) !== null && _a !== void 0 ? _a : []; }, [data]);
|
|
15
20
|
if (!data && !error) {
|
|
16
21
|
return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
|
|
17
22
|
}
|
|
18
23
|
if (error) {
|
|
19
24
|
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", ror, "."] }));
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
const basicLinks = (_b = data === null || data === void 0 ? void 0 : data.links.map((url) => ({ url }))) !== null && _b !== void 0 ? _b : [];
|
|
23
|
-
const wikiLink = data.wikipedia_url
|
|
24
|
-
? [{ text: 'Wikipedia', url: data.wikipedia_url }]
|
|
25
|
-
: [];
|
|
26
|
-
const links = [...basicLinks, ...wikiLink];
|
|
27
|
-
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "flex items-stretch gap-2 text-sm font-light", children: [_jsx(RorIcon, { width: "1.25rem", height: "1.25rem", className: "self-center inline-block" }), _jsx("a", { href: `https://ror.org/${ror}`, className: "self-center", target: "_blank", rel: "noopener noreferrer", children: _jsx("code", { children: ror }) })] }), _jsx("div", { className: "mb-4 text-xl font-bold", children: data.name }), _jsxs("dl", { className: "mb-4 text-sm", children: [_jsx("dt", { children: "Country" }), _jsx("dd", { children: country_name }), links.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Links" }), links.map(({ url, text }) => (_jsx("dd", { children: _jsx("a", { href: url, children: text || url }) })))] })), ((_c = data.acronyms) === null || _c === void 0 ? void 0 : _c.length) > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Acronyms" }), data.acronyms.map((text) => (_jsx("dd", { children: text })))] })), ((_d = data.labels) === null || _d === void 0 ? void 0 : _d.length) > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Labels" }), data.labels.map(({ label, iso639 }) => (_jsxs("dd", { children: [label, iso639 ? ` (${iso639})` : null] })))] }))] })] }));
|
|
26
|
+
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "flex items-stretch gap-2 text-sm font-light", children: [_jsx(RorIcon, { width: "1.25rem", height: "1.25rem", className: "self-center inline-block" }), _jsx("a", { href: `https://ror.org/${ror}`, className: "self-center", target: "_blank", rel: "noopener noreferrer", children: _jsx("code", { children: ror }) })] }), _jsx("div", { className: "mb-4 text-xl font-bold", children: name }), _jsxs("dl", { className: "mb-4 text-sm", children: [countryName && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Country" }), _jsx("dd", { children: countryName })] })), links.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Links" }), links.map(({ type, value }) => (_jsx("dd", { children: _jsx("a", { href: value, children: type === 'wikipedia' ? 'Wikipedia' : value }) })))] })), (acronyms === null || acronyms === void 0 ? void 0 : acronyms.length) > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Acronyms" }), acronyms.map(({ value }) => (_jsx("dd", { children: value })))] })), (labels === null || labels === void 0 ? void 0 : labels.length) > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Labels" }), labels.map(({ value, lang }) => (_jsxs("dd", { children: [value, lang ? ` (${lang})` : null] })))] }))] })] }));
|
|
28
27
|
}
|
|
29
28
|
export function RORLink({ node, ror, className, }) {
|
|
30
29
|
return (_jsx(HoverPopover, { card: _jsx(RORChild, { ror: ror }), children: _jsx("a", { href: `https://ror.org/${ror}`, target: "_blank", rel: "noopener noreferrer", className: classNames('hover-link', className), children: _jsx(MyST, { ast: node.children }) }) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myst-to-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=20"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@heroicons/react": "^2.0.18",
|
|
30
|
-
"@myst-theme/providers": "^1.1.
|
|
30
|
+
"@myst-theme/providers": "^1.1.3",
|
|
31
31
|
"@radix-ui/react-hover-card": "^1.0.6",
|
|
32
32
|
"@scienceicons/react": "^0.0.13",
|
|
33
33
|
"buffer": "^6.0.3",
|