myst-to-react 0.9.1 → 0.9.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.
@@ -1,15 +1,17 @@
1
1
  /// <reference types="react" />
2
2
  import type { CrossReference } from 'myst-spec';
3
3
  import { type NodeRenderer } from '@myst-theme/providers';
4
- export declare function useFetchMdast({ remote, url, dataUrl, }: {
4
+ export declare function useFetchMdast({ remote, url, remoteBaseUrl, dataUrl, }: {
5
5
  remote?: boolean;
6
6
  url?: string;
7
+ remoteBaseUrl?: string;
7
8
  dataUrl?: string;
8
9
  }): import("swr/_internal").SWRResponse<any, any, any>;
9
- export declare function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: remoteIn, children, identifier, htmlId, }: {
10
+ export declare function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: remoteIn, remoteBaseUrl: remoteBaseUrlIn, children, identifier, htmlId, }: {
10
11
  remote?: boolean;
11
12
  url?: string;
12
13
  dataUrl?: string;
14
+ remoteBaseUrl?: string;
13
15
  identifier: string;
14
16
  htmlId?: string;
15
17
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"crossReference.d.ts","sourceRoot":"","sources":["../src/crossReference.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AA0H/B,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,sDAWA;AAuBD,wBAAgB,mBAAmB,CAAC,EAClC,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,QAAQ,EAChB,QAAQ,EACR,UAAU,EACV,MAAW,GACZ,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAuDA;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAuB3D,CAAC;AAEF,QAAA,MAAM,yBAAyB;;CAE9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"crossReference.d.ts","sourceRoot":"","sources":["../src/crossReference.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAkF/B,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,aAAa,EACb,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,sDAIA;AAYD,wBAAgB,mBAAmB,CAAC,EAClC,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,QAAQ,EAChB,aAAa,EAAE,eAAe,EAC9B,QAAQ,EACR,UAAU,EACV,MAAW,GACZ,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAyEA;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAwB3D,CAAC;AAEF,QAAA,MAAM,yBAAyB;;CAE9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1,81 +1,18 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { selectAll } from 'unist-util-select';
3
- import { EXIT, SKIP, visit } from 'unist-util-visit';
4
2
  import { useLinkProvider, useReferences, useBaseurl, withBaseurl, XRefProvider, useXRefState, } from '@myst-theme/providers';
5
3
  import { InlineError } from './inlineError.js';
6
4
  import { default as useSWR } from 'swr';
7
5
  import { HoverPopover } from './components/index.js';
8
6
  import { MyST } from './MyST.js';
9
- const hiddenNodes = new Set(['comment', 'mystComment']);
10
- function selectHeadingNodes(mdast, identifier, maxNodes = 3) {
11
- let begin = false;
12
- let htmlId = undefined;
13
- const nodes = [];
14
- visit(mdast, (node) => {
15
- if ((begin && node.type === 'heading') || nodes.length >= maxNodes) {
16
- return EXIT;
17
- }
18
- if (node.identifier === identifier && node.type === 'heading') {
19
- begin = true;
20
- htmlId = node.html_id || node.identifier;
21
- }
22
- if (begin) {
23
- if (!hiddenNodes.has(node.type))
24
- nodes.push(node);
25
- return SKIP; // Don't traverse the children
26
- }
27
- });
28
- return { htmlId, nodes };
29
- }
30
- function selectDefinitionTerm(mdast, identifier) {
31
- var _a, _b;
32
- let begin = false;
33
- const nodes = [];
34
- visit(mdast, (node) => {
35
- if (begin && node.type === 'definitionTerm') {
36
- if (nodes.length > 1)
37
- return EXIT;
38
- }
39
- else if (begin && node.type !== 'definitionDescription') {
40
- return EXIT;
41
- }
42
- if (node.identifier === identifier && node.type === 'definitionTerm') {
43
- nodes.push(node);
44
- begin = true;
45
- }
46
- if (begin) {
47
- if (node.type === 'definitionDescription')
48
- nodes.push(node);
49
- return SKIP; // Don't traverse the children
50
- }
51
- });
52
- return {
53
- htmlId: ((_a = nodes === null || nodes === void 0 ? void 0 : nodes[0]) === null || _a === void 0 ? void 0 : _a.html_id) || ((_b = nodes === null || nodes === void 0 ? void 0 : nodes[0]) === null || _b === void 0 ? void 0 : _b.identifier),
54
- nodes: [{ type: 'definitionList', key: 'dl', children: nodes }],
55
- };
56
- }
57
- function selectMdastNodes(mdast, identifier) {
58
- // Select the first identifier that is not a crossReference or citation
59
- const node = selectAll(`[identifier=${identifier}],[key=${identifier}]`, mdast).filter(({ type }) => type !== 'crossReference' && type !== 'cite')[0];
60
- if (!node)
61
- return { nodes: [] };
62
- switch (node.type) {
63
- case 'heading':
64
- return selectHeadingNodes(mdast, identifier);
65
- case 'definitionTerm':
66
- return selectDefinitionTerm(mdast, identifier);
67
- default:
68
- return { htmlId: node.html_id || node.identifier, nodes: [node] };
69
- }
70
- }
7
+ import { selectMdastNodes } from 'myst-common';
71
8
  const fetcher = (...args) => fetch(...args).then((res) => {
72
9
  if (res.status === 200)
73
10
  return res.json();
74
11
  throw new Error(`Content returned with status ${res.status}.`);
75
12
  });
76
13
  // This is a small component that must be distinct based on the nodes
77
- function XrefChildren({ load, remote, url, dataUrl, identifier, }) {
78
- const data = useSelectNodes({ load, remote, url, dataUrl, identifier });
14
+ function XrefChildren({ load, identifier }) {
15
+ const data = useSelectNodes({ load, identifier });
79
16
  if (!data)
80
17
  return null;
81
18
  if (data.loading) {
@@ -97,38 +34,60 @@ function openDetails(el) {
97
34
  }
98
35
  openDetails(el.parentElement);
99
36
  }
100
- export function useFetchMdast({ remote, url, dataUrl, }) {
101
- var _a;
37
+ function createRemoteBaseUrl(url, remoteBaseUrl) {
38
+ if (remoteBaseUrl && (url === null || url === void 0 ? void 0 : url.startsWith(remoteBaseUrl))) {
39
+ // The remoteBaseUrl is included in the url
40
+ // This is the case for entry point references
41
+ return url;
42
+ }
43
+ return `${remoteBaseUrl || ''}${url || ''}`;
44
+ }
45
+ function createExternalUrl({ url, remoteBaseUrl, dataUrl, baseurl, }) {
46
+ // Handle external links first
47
+ if (!!remoteBaseUrl || // The parent reference is external
48
+ (dataUrl === null || dataUrl === void 0 ? void 0 : dataUrl.startsWith('http')) // Or the url is actually external
49
+ ) {
50
+ if (!dataUrl) {
51
+ console.error('Expected external URL to provide a dataUrl');
52
+ return null; // Means the fetch won't happen
53
+ }
54
+ return createRemoteBaseUrl(dataUrl, remoteBaseUrl);
55
+ }
102
56
  // dataUrl should point directly to the cross reference mdast data.
57
+ if (dataUrl) {
58
+ // All modern myst should have a dataUrl
59
+ return withBaseurl(dataUrl, baseurl);
60
+ }
103
61
  // If dataUrl is not provided, it will be computed by appending .json to the url.
62
+ // This is legacy
63
+ return `${withBaseurl(url, baseurl)}.json`;
64
+ }
65
+ export function useFetchMdast({ remote, url, remoteBaseUrl, dataUrl, }) {
104
66
  const baseurl = useBaseurl();
105
- const external = (_a = url === null || url === void 0 ? void 0 : url.startsWith('http')) !== null && _a !== void 0 ? _a : false;
106
- const lookupUrl = external
107
- ? dataUrl !== null && dataUrl !== void 0 ? dataUrl : `${url}.json`
108
- : dataUrl
109
- ? `${withBaseurl(dataUrl, baseurl)}`
110
- : `${withBaseurl(url, baseurl)}.json`;
67
+ const lookupUrl = createExternalUrl({ url, remoteBaseUrl, dataUrl, baseurl });
111
68
  return useSWR(remote ? lookupUrl : null, fetcher);
112
69
  }
113
- function useSelectNodes({ load, remote, url, dataUrl, identifier, }) {
70
+ function useSelectNodes({ load, identifier }) {
114
71
  var _a;
115
72
  const references = useReferences();
73
+ const { remote, url, remoteBaseUrl, dataUrl } = useXRefState();
116
74
  if (!load)
117
75
  return;
118
- const { data, error } = useFetchMdast({ remote, url, dataUrl });
76
+ const { data, error } = useFetchMdast({ remote, url, remoteBaseUrl, dataUrl });
119
77
  const mdast = (_a = data === null || data === void 0 ? void 0 : data.mdast) !== null && _a !== void 0 ? _a : references === null || references === void 0 ? void 0 : references.article;
120
78
  const { nodes, htmlId } = selectMdastNodes(mdast, identifier);
121
79
  return { htmlId, nodes, loading: remote && !data, error: remote && error };
122
80
  }
123
- export function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: remoteIn, children, identifier, htmlId = '', }) {
81
+ export function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: remoteIn, remoteBaseUrl: remoteBaseUrlIn, children, identifier, htmlId = '', }) {
124
82
  var _a;
125
83
  const Link = useLinkProvider();
126
84
  const baseurl = useBaseurl();
127
85
  const parent = useXRefState();
128
86
  const remote = parent.remote || remoteIn;
87
+ const remoteBaseUrl = parent.remoteBaseUrl || remoteBaseUrlIn;
129
88
  const url = parent.remote ? urlIn !== null && urlIn !== void 0 ? urlIn : parent.url : urlIn;
130
89
  const dataUrl = parent.remote ? dataUrlIn !== null && dataUrlIn !== void 0 ? dataUrlIn : parent.dataUrl : dataUrlIn;
131
- const external = (_a = url === null || url === void 0 ? void 0 : url.startsWith('http')) !== null && _a !== void 0 ? _a : false;
90
+ const external = !!remoteBaseUrl || ((_a = url === null || url === void 0 ? void 0 : url.startsWith('http')) !== null && _a !== void 0 ? _a : false);
132
91
  const scroll = (e) => {
133
92
  e.preventDefault();
134
93
  if (!htmlId)
@@ -137,15 +96,21 @@ export function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: re
137
96
  openDetails(el);
138
97
  el === null || el === void 0 ? void 0 : el.scrollIntoView({ behavior: 'smooth' });
139
98
  history.replaceState(undefined, '', `#${htmlId}`);
99
+ if (el) {
100
+ // Changes keyboard tab-index location
101
+ if (el.tabIndex === -1)
102
+ el.tabIndex = -1;
103
+ el.focus({ preventScroll: true });
104
+ }
140
105
  };
141
- return (_jsx(HoverPopover, { card: ({ load }) => (_jsx(XRefProvider, { remote: remote, url: url, dataUrl: dataUrl, children: _jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] px-3", children: _jsx(XrefChildren, { load: load, remote: remote, url: url, dataUrl: dataUrl, identifier: identifier }) }) })), children: _jsxs("span", { children: [remote && external && (_jsx("a", { href: `${url}${htmlId ? `#${htmlId}` : ''}`, target: "_blank", className: "hover-link", children: children })), remote && !external && (_jsx(Link, { to: `${withBaseurl(url, baseurl)}${htmlId ? `#${htmlId}` : ''}`, prefetch: "intent", className: "hover-link", children: children })), !remote && (_jsx("a", { href: `#${htmlId}`, onClick: scroll, className: "hover-link", children: children }))] }) }));
106
+ return (_jsx(HoverPopover, { card: ({ load }) => (_jsx(XRefProvider, { remote: remote, remoteBaseUrl: remoteBaseUrl, url: url, dataUrl: dataUrl, children: _jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] overflow-auto", children: [remoteBaseUrl && (_jsxs("div", { className: "w-full px-3 py-1 text-xs border-b bg-gray-50", children: [_jsx("strong", { className: "text-gray-700", children: "Source: " }), _jsx("a", { className: "text-gray-700", href: `${createRemoteBaseUrl(url, remoteBaseUrl)}${htmlId ? `#${htmlId}` : ''}`, target: "_blank", children: remoteBaseUrl })] })), _jsx("div", { className: "px-3", children: _jsx(XrefChildren, { load: load, identifier: identifier }) })] }) })), children: _jsxs("span", { children: [remote && external && (_jsx("a", { href: `${createRemoteBaseUrl(url, remoteBaseUrl)}${htmlId ? `#${htmlId}` : ''}`, target: "_blank", className: "hover-link", children: children })), remote && !external && (_jsx(Link, { to: `${withBaseurl(url, baseurl)}${htmlId ? `#${htmlId}` : ''}`, prefetch: "intent", className: "hover-link", children: children })), !remote && (_jsx("a", { href: `#${htmlId}`, onClick: scroll, className: "hover-link", children: children }))] }) }));
142
107
  }
143
108
  export const CrossReferenceNode = ({ node }) => {
144
109
  if (!node.children) {
145
110
  return (_jsx(InlineError, { value: node.label || node.identifier || 'No Label', message: "Cross Reference Not Found" }));
146
111
  }
147
- const { remote, url, dataUrl, identifier, html_id } = node;
148
- return (_jsxs(CrossReferenceHover, { identifier: identifier, htmlId: html_id, remote: remote, url: url, dataUrl: dataUrl, children: [node.prefix && _jsxs(_Fragment, { children: [node.prefix, " "] }), _jsx(MyST, { ast: node.children }), node.suffix || null] }));
112
+ const { remote, url, dataUrl, remoteBaseUrl, identifier, html_id } = node;
113
+ return (_jsxs(CrossReferenceHover, { identifier: identifier, htmlId: html_id, remote: remote, url: url, dataUrl: dataUrl, remoteBaseUrl: remoteBaseUrl, children: [node.prefix && _jsxs(_Fragment, { children: [node.prefix, " "] }), _jsx(MyST, { ast: node.children }), node.suffix || null] }));
149
114
  };
150
115
  const CROSS_REFERENCE_RENDERERS = {
151
116
  crossReference: CrossReferenceNode,
@@ -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;AAOtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAO1D,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA0CxE,eAAO,MAAM,IAAI,EAAE,YAAY,CAAC,eAAe,CA2C9C,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,eAAe,CA8BnD,CAAC;AAEF,QAAA,MAAM,cAAc;;;CAGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQ1D,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA0CxE,eAAO,MAAM,IAAI,EAAE,YAAY,CAAC,eAAe,CA6C9C,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,eAAe,CA8BnD,CAAC;AAEF,QAAA,MAAM,cAAc;;;CAGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -4,6 +4,7 @@ import { useLinkProvider, useSiteManifest, useBaseurl, withBaseurl } from '@myst
4
4
  import { HoverPopover, LinkCard } from '../components/index.js';
5
5
  import { WikiLink } from './wiki.js';
6
6
  import { RRIDLink } from './rrid.js';
7
+ import { RORLink } from './ror.js';
7
8
  import { GithubLink } from './github.js';
8
9
  import { MyST } from '../MyST.js';
9
10
  function getPageInfo(site, path) {
@@ -28,7 +29,7 @@ function InternalLink({ url, children }) {
28
29
  return (_jsx(HoverPopover, { card: _jsx(LinkCard, { internal: true, url: url, title: page.title, description: page.description, thumbnail: page.thumbnailOptimized || page.thumbnail }), children: _jsx(Link, { to: withBaseurl(url, baseurl), prefetch: "intent", children: children }) }));
29
30
  }
30
31
  export const link = ({ node }) => {
31
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
32
33
  const internal = (_a = node.internal) !== null && _a !== void 0 ? _a : false;
33
34
  const protocol = node.protocol;
34
35
  switch (protocol) {
@@ -38,6 +39,8 @@ export const link = ({ node }) => {
38
39
  return (_jsx(GithubLink, { kind: (_d = node.data) === null || _d === void 0 ? void 0 : _d.kind, url: node.url, org: (_e = node.data) === null || _e === void 0 ? void 0 : _e.org, repo: (_f = node.data) === null || _f === void 0 ? void 0 : _f.repo, raw: (_g = node.data) === null || _g === void 0 ? void 0 : _g.raw, file: (_h = node.data) === null || _h === void 0 ? void 0 : _h.file, from: (_j = node.data) === null || _j === void 0 ? void 0 : _j.from, to: (_k = node.data) === null || _k === void 0 ? void 0 : _k.to, issue_number: (_l = node.data) === null || _l === void 0 ? void 0 : _l.issue_number, children: _jsx(MyST, { ast: node.children }) }));
39
40
  case 'rrid':
40
41
  return _jsx(RRIDLink, { rrid: (_m = node.data) === null || _m === void 0 ? void 0 : _m.rrid });
42
+ case 'ror':
43
+ return _jsx(RORLink, { node: node, ror: (_o = node.data) === null || _o === void 0 ? void 0 : _o.ror });
41
44
  default:
42
45
  if (internal) {
43
46
  return (_jsx(InternalLink, { url: node.url, children: _jsx(MyST, { ast: node.children }) }));
@@ -0,0 +1,6 @@
1
+ import type { GenericNode } from 'myst-common';
2
+ export declare function RORLink({ node, ror }: {
3
+ node: GenericNode;
4
+ ror: string;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=ror.d.ts.map
@@ -0,0 +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;AAiF/C,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,2CAQxE"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { default as useSWR } from 'swr';
3
+ import { HoverPopover } from '../components/index.js';
4
+ import { MyST } from '../MyST.js';
5
+ import { RorIcon } from '@scienceicons/react/24/solid';
6
+ const fetcher = (...args) => fetch(...args).then((res) => {
7
+ if (res.status === 200)
8
+ return res.json();
9
+ throw new Error(`Content returned with status ${res.status}.`);
10
+ });
11
+ function RORChild({ ror }) {
12
+ var _a, _b, _c, _d;
13
+ const { data, error } = useSWR(`https://api.ror.org/organizations/${ror}`, fetcher);
14
+ if (!data && !error) {
15
+ return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
16
+ }
17
+ if (error) {
18
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", ror, "."] }));
19
+ }
20
+ const country_name = (_a = data === null || data === void 0 ? void 0 : data.country) === null || _a === void 0 ? void 0 : _a.country_name;
21
+ const basicLinks = (_b = data === null || data === void 0 ? void 0 : data.links.map((url) => ({ url }))) !== null && _b !== void 0 ? _b : [];
22
+ const wikiLink = data.wikipedia_url
23
+ ? [{ text: 'Wikipedia', url: data.wikipedia_url }]
24
+ : [];
25
+ const links = [...basicLinks, ...wikiLink];
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: 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] })))] }))] })] }));
27
+ }
28
+ export function RORLink({ node, ror }) {
29
+ return (_jsx(HoverPopover, { card: _jsx(RORChild, { ror: ror }), children: _jsx("a", { href: `https://ror.org/${ror}`, target: "_blank", rel: "noopener noreferrer", children: _jsx(MyST, { ast: node.children }) }) }));
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-to-react",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,12 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@heroicons/react": "^2.0.18",
24
- "@myst-theme/providers": "^0.9.1",
24
+ "@myst-theme/providers": "^0.9.3",
25
+ "@scienceicons/react": "^0.0.6",
25
26
  "@radix-ui/react-hover-card": "^1.0.6",
26
27
  "buffer": "^6.0.3",
27
28
  "classnames": "^2.3.2",
28
- "myst-common": "^1.4.0",
29
- "myst-config": "^1.4.0",
29
+ "myst-common": "^1.4.1",
30
+ "myst-config": "^1.4.1",
30
31
  "myst-spec": "^0.0.5",
31
32
  "nanoid": "^4.0.2",
32
33
  "react-syntax-highlighter": "^15.5.0",