myst-to-react 1.0.1 → 1.1.0

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 +1 @@
1
- {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../src/basic.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,SAAS,GAAG;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,uBAAuB,CAAC;CAC/B,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MA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AAC;IAEpD,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAExC,aAAa,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IACjC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAEnC,cAAc,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC7C,cAAc,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC7C,qBAAqB,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAC;IAC3D,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,kBAwUtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/basic.js CHANGED
@@ -40,7 +40,17 @@ const BASIC_RENDERERS = {
40
40
  return (_jsx("a", { target: "_blank", href: node.url, className: classNames(node.class, className), rel: "noreferrer", children: _jsx(MyST, { ast: node.children }) }));
41
41
  },
42
42
  paragraph({ node, className }) {
43
- return (_jsx("p", { id: node.html_id, className: className, children: _jsx(MyST, { ast: node.children }) }));
43
+ var _a, _b, _c, _d;
44
+ const isSingleImage = ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) === 1 && node.children[0].type === 'image';
45
+ const isSingleLinkedImage = ((_b = node.children) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
46
+ node.children[0].type === 'link' &&
47
+ ((_c = node.children[0].children) === null || _c === void 0 ? void 0 : _c.length) === 1 &&
48
+ ((_d = node.children[0].children[0]) === null || _d === void 0 ? void 0 : _d.type) === 'image';
49
+ // Only wrap in <p> if it's not a single image or linked image
50
+ if (!isSingleImage && !isSingleLinkedImage) {
51
+ return (_jsx("p", { id: node.html_id, className: className, children: _jsx(MyST, { ast: node.children }) }));
52
+ }
53
+ return _jsx(MyST, { ast: node.children });
44
54
  },
45
55
  algorithmLine({ node, className }) {
46
56
  var _a;
@@ -120,7 +130,7 @@ const BASIC_RENDERERS = {
120
130
  return (_jsx("sup", { className: className, children: _jsx(MyST, { ast: node.children }) }));
121
131
  },
122
132
  abbreviation({ node, className }) {
123
- return (_jsx(Tooltip, { title: node.title, className: classNames(className), children: _jsx("abbr", { "aria-label": node.title, className: "border-b border-dotted cursor-help", children: _jsx(MyST, { ast: node.children }) }) }));
133
+ return (_jsx(Tooltip, { title: node.title, className: classNames(className), children: _jsx("abbr", { "aria-label": node.title, className: "hover-text", children: _jsx(MyST, { ast: node.children }) }) }));
124
134
  },
125
135
  mystComment() {
126
136
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/links/github.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkOnD,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,YAAY,EACZ,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAsCA"}
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/links/github.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmQnD,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,YAAY,EACZ,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CA2CA"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { default as useSWR } from 'swr';
3
- import { ArrowTopRightOnSquareIcon as ExternalLinkIcon, PlusCircleIcon, CheckCircleIcon, } from '@heroicons/react/24/outline';
3
+ import { ArrowTopRightOnSquareIcon as ExternalLinkIcon, CheckCircleIcon, DocumentCheckIcon, DocumentPlusIcon, NoSymbolIcon, PlusCircleIcon, XCircleIcon, } from '@heroicons/react/24/outline';
4
4
  import { HoverPopover, LinkCard } from '../components/index.js';
5
5
  import { useEffect, useState } from 'react';
6
6
  import { CodeBlock } from '../code.js';
@@ -67,21 +67,58 @@ function useWhiteTextColor(bgColor) {
67
67
  return r * 0.299 + g * 0.587 + b * 0.114 <= 186;
68
68
  }
69
69
  function GithubIssuePreview({ url, org, repo, issue_number, open, className, }) {
70
- var _a, _b;
70
+ var _a, _b, _c;
71
71
  const { data, error } = useLoadWhenOpen(open, `https://api.github.com/repos/${org}/${repo}/issues/${issue_number}`, jsonFetcher);
72
72
  if (!data && !error) {
73
73
  return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
74
74
  }
75
- const resp = data;
76
75
  if (error) {
77
76
  return (_jsxs("div", { className: "hover-document article", children: [_jsx("a", { href: url, className: classNames('block text-inherit hover:text-inherit', className), target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { className: "float-right w-4 h-4" }) }), _jsx("div", { className: "mt-2", children: "Error loading from GitHub." })] }));
78
77
  }
79
- const dateString = new Date(resp.created_at).toLocaleDateString('en-US', {
78
+ const issueData = data;
79
+ const isPullRequest = Boolean(issueData.pull_request);
80
+ const issueState = issueData.state;
81
+ const isOpen = issueState === 'open';
82
+ const isMerged = Boolean((_a = issueData.pull_request) === null || _a === void 0 ? void 0 : _a.merged_at);
83
+ const isCompletedIssue = issueData.state_reason === 'completed';
84
+ const isNotPlannedIssue = !isPullRequest && issueState === 'closed' && !isCompletedIssue;
85
+ const dateString = new Date(issueData.created_at).toLocaleDateString('en-US', {
80
86
  year: 'numeric',
81
87
  month: 'long',
82
88
  day: 'numeric',
83
89
  });
84
- return (_jsxs("div", { className: "hover-document article w-[400px] sm:max-w-[400px] p-3", children: [_jsxs("div", { className: "text-xs font-light", children: [org, "/", repo] }), _jsxs("div", { className: "my-2 text-lg font-bold dark:text-white", children: [resp.state === 'open' && (_jsx(PlusCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-green-700 -translate-y-px dark:text-green-500" })), resp.state === 'closed' && (_jsx(CheckCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-purple-700 -translate-y-px dark:text-purple-500" })), resp.title] }), _jsxs("div", { className: "text-xs font-light", children: ["#", issue_number, " opened on ", dateString, " by", ' ', _jsxs("span", { className: "font-normal", children: ["@", resp.user.login] })] }), _jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: resp.body }), ((_a = resp.labels) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx("div", { className: "flex flex-wrap", children: (_b = resp.labels) === null || _b === void 0 ? void 0 : _b.map((label) => (_jsx("span", { className: classNames('mr-1 text-xs inline-flex items-center px-2 py-0.5 rounded-full', {
90
+ const iconClassName = 'inline-block mr-2 -translate-y-px h-6 w-6';
91
+ // Define the icon element we'll render based on the issue's state
92
+ let stateIcon = null;
93
+ if (isPullRequest) {
94
+ // If it's a PR we choose between open, merged, not merged
95
+ if (isOpen) {
96
+ stateIcon = (
97
+ // PR still open
98
+ _jsx(DocumentPlusIcon, { className: classNames(iconClassName, 'text-green-700 dark:text-green-500') }));
99
+ }
100
+ else {
101
+ stateIcon = isMerged ? (
102
+ // PR Merged
103
+ _jsx(DocumentCheckIcon, { className: classNames(iconClassName, 'text-purple-700 dark:text-purple-500') })) : (
104
+ // PR closed as not merged
105
+ _jsx(XCircleIcon, { className: classNames(iconClassName, 'text-red-700 dark:text-red-500') }));
106
+ }
107
+ }
108
+ else if (isOpen) {
109
+ // If it's an issue, we choose between open, completed, and "closed not completed"
110
+ stateIcon = (
111
+ // Issue still open
112
+ _jsx(PlusCircleIcon, { className: classNames(iconClassName, 'text-green-700 dark:text-green-500') }));
113
+ }
114
+ else {
115
+ stateIcon = isNotPlannedIssue ? (
116
+ // Issue closed as not planned
117
+ _jsx(NoSymbolIcon, { className: classNames(iconClassName, 'text-slate-500 dark:text-slate-400') })) : (
118
+ // Issue completed
119
+ _jsx(CheckCircleIcon, { className: classNames(iconClassName, 'text-purple-700 dark:text-purple-500') }));
120
+ }
121
+ return (_jsxs("div", { className: "hover-document article w-[400px] sm:max-w-[400px] p-3", children: [_jsxs("div", { className: "text-xs font-light", children: [org, "/", repo] }), _jsxs("div", { className: "my-2 text-lg font-bold dark:text-white", children: [stateIcon, issueData.title] }), _jsxs("div", { className: "text-xs font-light", children: ["#", issue_number, " opened on ", dateString, " by", ' ', _jsxs("span", { className: "font-normal", children: ["@", issueData.user.login] })] }), _jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: issueData.body }), ((_b = issueData.labels) === null || _b === void 0 ? void 0 : _b.length) > 0 && (_jsx("div", { className: "flex flex-wrap", children: (_c = issueData.labels) === null || _c === void 0 ? void 0 : _c.map((label) => (_jsx("span", { className: classNames('mr-1 text-xs inline-flex items-center px-2 py-0.5 rounded-full', {
85
122
  'text-white': useWhiteTextColor(label.color),
86
123
  }), style: { backgroundColor: `#${label.color}` }, children: label.name }, label.id))) }))] }));
87
124
  }
@@ -93,5 +130,5 @@ export function GithubLink({ kind, children, url, org, repo, raw, file, from, to
93
130
  if (kind === 'issue') {
94
131
  return (_jsx(GithubIssuePreview, { url: url, open: load, org: org, issue_number: issue_number, repo: repo, className: className }));
95
132
  }
96
- }, children: _jsx("a", { href: url, className: classNames('italic', className), target: "_blank", rel: "noreferrer", children: children }) }));
133
+ }, children: _jsx("a", { href: url, className: classNames('hover-link', className), target: "_blank", rel: "noreferrer", children: children }) }));
97
134
  }
@@ -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,aAAa,EAAE,MAAM,uBAAuB,CAAC;AASzE,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAkDxE,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,CAmBpD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,eAAe,CAmCnD,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,aAerB,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;AAatC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AASzE,KAAK,eAAe,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA0DxE,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,CAoBpD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,eAAe,CAmCnD,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,aAerB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ArrowTopRightOnSquareIcon as ExternalLinkIcon, LinkIcon, } from '@heroicons/react/24/outline';
3
- import { useLinkProvider, useSiteManifest, useBaseurl, withBaseurl } from '@myst-theme/providers';
3
+ import { isExternalUrl, useLinkProvider, useSiteManifest, useBaseurl, withBaseurl, } from '@myst-theme/providers';
4
4
  import { HoverPopover, LinkCard } from '../components/index.js';
5
5
  import { WikiLink } from './wiki.js';
6
6
  import { RRIDLink } from './rrid.js';
@@ -25,9 +25,9 @@ function InternalLink({ url, children, className, }) {
25
25
  const baseurl = useBaseurl();
26
26
  const skipPreview = !page || (!page.description && !page.thumbnail);
27
27
  if (!page || skipPreview) {
28
- return (_jsx(Link, { to: withBaseurl(url, baseurl), prefetch: "intent", className: className, children: children }));
28
+ return (_jsx(Link, { to: withBaseurl(url, baseurl), prefetch: "intent", className: classNames('link', className), children: children }));
29
29
  }
30
- 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", className: className, children: children }) }));
30
+ 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", className: classNames('hover-link', className), children: children }) }));
31
31
  }
32
32
  export const WikiLinkRenderer = ({ node, className }) => {
33
33
  var _a, _b;
@@ -47,11 +47,11 @@ export const RORLinkRenderer = ({ node, className }) => {
47
47
  };
48
48
  export const SimpleLink = ({ node, className }) => {
49
49
  var _a;
50
- const internal = (_a = node.internal) !== null && _a !== void 0 ? _a : false;
50
+ const internal = (_a = node.internal) !== null && _a !== void 0 ? _a : !isExternalUrl(node.url);
51
51
  if (internal) {
52
52
  return (_jsx(InternalLink, { url: node.url, className: classNames(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
53
53
  }
54
- return (_jsx("a", { target: "_blank", rel: "noreferrer", href: node.url, className: classNames(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
54
+ return (_jsxs("a", { target: "_blank", rel: "noreferrer", href: node.url, className: classNames('link', node.class, className), children: [_jsx(MyST, { ast: node.children }), _jsx(ExternalLinkIcon, { className: "external-link-icon" })] }));
55
55
  };
56
56
  export const linkBlock = ({ node, className }) => {
57
57
  var _a;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/links/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { isExternalUrl } from '@myst-theme/providers';
3
+ describe('isExternalUrl', () => {
4
+ it('treats internal reference and static asset paths as internal', () => {
5
+ expect(isExternalUrl('intro.md')).toBe(false);
6
+ expect(isExternalUrl('./intro.md')).toBe(false);
7
+ expect(isExternalUrl('/intro.md')).toBe(false);
8
+ expect(isExternalUrl('./assets/logo.svg')).toBe(false);
9
+ expect(isExternalUrl('/docs/page/')).toBe(false);
10
+ });
11
+ it('treats external urls as external', () => {
12
+ expect(isExternalUrl('https://example.com')).toBe(true);
13
+ expect(isExternalUrl('http://example.com')).toBe(true);
14
+ expect(isExternalUrl('ftp://example.com/file.txt')).toBe(true);
15
+ expect(isExternalUrl('mailto:foo@example.com')).toBe(true);
16
+ });
17
+ });
@@ -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;AAiF/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"}
1
+ {"version":3,"file":"ror.d.ts","sourceRoot":"","sources":["../../src/links/ror.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkF/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
@@ -3,6 +3,7 @@ import { default as useSWR } from 'swr';
3
3
  import { HoverPopover } from '../components/index.js';
4
4
  import { MyST } from '../MyST.js';
5
5
  import { RorIcon } from '@scienceicons/react/24/solid';
6
+ import classNames from 'classnames';
6
7
  const fetcher = (...args) => fetch(...args).then((res) => {
7
8
  if (res.status === 200)
8
9
  return res.json();
@@ -26,5 +27,5 @@ function RORChild({ ror }) {
26
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] })))] }))] })] }));
27
28
  }
28
29
  export function RORLink({ node, ror, className, }) {
29
- return (_jsx(HoverPopover, { card: _jsx(RORChild, { ror: ror }), children: _jsx("a", { href: `https://ror.org/${ror}`, target: "_blank", rel: "noopener noreferrer", className: className, children: _jsx(MyST, { ast: node.children }) }) }));
30
+ 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 }) }) }));
30
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rrid.d.ts","sourceRoot":"","sources":["../../src/links/rrid.tsx"],"names":[],"mappings":"AAsEA,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAajF"}
1
+ {"version":3,"file":"rrid.d.ts","sourceRoot":"","sources":["../../src/links/rrid.tsx"],"names":[],"mappings":"AAuEA,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAajF"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { default as useSWR } from 'swr';
3
3
  import { HoverPopover } from '../components/index.js';
4
+ import classNames from 'classnames';
4
5
  const fetcher = (...args) => fetch(...args).then((res) => {
5
6
  if (res.status === 200)
6
7
  return res.json();
@@ -23,5 +24,5 @@ function RRIDChild({ rrid }) {
23
24
  return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "text-sm font-light", children: ["RRID: ", category] }), _jsxs("div", { className: "mb-4 text-xl font-bold", children: [title, " ", _jsx("code", { children: curie })] }), _jsx("p", { className: "text-md", children: description }), types.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Categories" }), _jsx("div", { className: "flex flex-wrap ml-1", children: types === null || types === void 0 ? void 0 : types.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] })), tags.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Tags" }), _jsx("div", { className: "flex flex-wrap ml-1", children: tags === null || tags === void 0 ? void 0 : tags.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] }))] }));
24
25
  }
25
26
  export function RRIDLink({ rrid, className }) {
26
- return (_jsx(HoverPopover, { card: _jsx(RRIDChild, { rrid: rrid }), children: _jsxs("a", { href: `https://scicrunch.org/resolver/${rrid}`, target: "_blank", rel: "noopener noreferrer", className: className, children: ["RRID: ", _jsx("cite", { className: "italic", children: rrid })] }) }));
27
+ return (_jsx(HoverPopover, { card: _jsx(RRIDChild, { rrid: rrid }), children: _jsxs("a", { href: `https://scicrunch.org/resolver/${rrid}`, target: "_blank", rel: "noopener noreferrer", className: classNames('hover-link', className), children: ["RRID: ", _jsx("cite", { className: "italic", children: rrid })] }) }));
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/links/wiki.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAsG1B,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAQA"}
1
+ {"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/links/wiki.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAsG1B,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAaA"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { default as useSWR } from 'swr';
3
- import { ArrowTopRightOnSquareIcon as ExternalLinkIcon } from '@heroicons/react/24/outline';
3
+ import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline';
4
4
  import { HoverPopover, LinkCard } from '../components/index.js';
5
5
  import classNames from 'classnames';
6
6
  const WikiTextMark = () => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", version: "1.1", id: "svg3400", viewBox: "0 0 500 85", className: "h-4", children: _jsxs("g", { transform: "translate(-357.71336,-784.65111)", children: [_jsx("path", { fill: "currentColor", d: "m 412.98736,806.72288 c 0,0 -1.468,-2.984 -1.968,-3.976 -3.336,-6.612 -3.264,-6.964 -6.636,-7.408 -0.944,-0.124 -1.432,-0.244 -1.432,-0.712 v -2.092 l 0.284,-0.204 c 6.092,-0.008 19.648,-0.008 19.648,-0.008 l 0.52,0.172 v 2.084 c 0,0.476 -0.34,0.72 -1.032,0.72 l -1.424,0.204 c -3.6,0.28 -3.012,1.752 -0.62,6.516 l 22.708,46.46 0.776,0.212 20.16,-47.844 c 0.7,-1.928 0.592,-3.296 -0.308,-4.1 -0.904,-0.784 -1.54,-1.248 -3.876,-1.344 l -1.892,-0.096 c -0.232,0 -0.452,-0.084 -0.664,-0.24 -0.208,-0.148 -0.316,-0.344 -0.316,-0.58 v -1.992 l 0.288,-0.204 c 5.68,0 22.776,0 22.776,0 l 0.232,0.204 v 1.992 c 0,0.54 -0.308,0.812 -0.916,0.812 -2.984,0.132 -5.196,0.78 -6.628,1.936 -1.436,1.164 -2.556,2.768 -3.36,4.852 0,0 -18.54,42.436 -24.884,56.54 -2.428,4.624 -4.816,4.2 -6.916,-0.132 -4.436,-9.136 -16.928,-36.852 -16.928,-36.852 l -7.592,-14.92 z" }), _jsx("path", { fill: "currentColor", d: "m 449.37136,792.29888 c 0,0 -12.812,-0.04 -18.516,0 l -0.284,0.204 v 1.984 c 0,0.244 0.104,0.436 0.312,0.584 0.212,0.156 0.428,0.236 0.66,0.236 l 0.916,0.1 c 2.332,0.096 3.404,0.708 3.724,1.092 0.556,0.68 0.832,1.416 -0.516,4.356 l -23.92,47.708 -0.628,-0.164 c 0,0 -17.132,-36.124 -22.092,-48.208 -0.516,-1.252 -0.748,-2.18 -0.748,-2.752 0,-1.228 1.108,-1.892 3.324,-1.984 l 2.584,-0.108 c 0.684,0 1.032,-0.264 1.032,-0.812 v -1.984 l -0.232,-0.204 c 0,0 -20.52,-0.024 -24.76,0 l -0.232,0.204 v 2.084 c 0,0.376 0.476,0.608 1.432,0.712 2.604,0.14 4.316,0.556 5.14,1.248 0.82,0.7 1.688,2.468 2.84,5.224 6.228,14.96 19.46,41.656 25.904,56.86 1.856,4.152 4.188,4.796 7.02,-0.128 4.904,-9.096 18.2,-36.872 18.2,-36.872 l 10.472,-19.584 c 1.22,-2.068 2.396,-3.912 2.992,-4.772 1.092,-1.572 1.704,-1.868 4.688,-2.008 0.608,0 0.916,-0.272 0.916,-0.82 v -1.984 l -0.228,-0.212 z" }), _jsx("path", { fill: "currentColor", d: "m 488.32736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.128,-0.212 -2.912,0 -11.024,0.212 -11.024,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.432,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.252,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.44,0.208 2.808,0 10.816,-0.208 10.816,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 v 34.632 z" }), _jsx("path", { fill: "currentColor", d: "m 519.01936,854.23088 c 0,2.288 1.352,3.432 4.368,3.952 l 1.144,0.212 c 0.312,0.1 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -6.552,-0.212 -9.672,-0.212 -2.912,0 -11.44,0.212 -11.44,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.12,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.144,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.528,0.208 11.752,0.208 2.916,0 9.464,-0.208 9.464,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.416 -0.624,0.52 l -1.144,0.212 c -3.224,0.62 -4.368,1.144 -4.368,3.228 v 15.704 c 3.432,0 5.408,-1.764 9.984,-6.656 4.16,-4.58 7.384,-8.42 7.384,-10.4 0,-0.836 -0.936,-1.768 -3.016,-2.084 -0.416,-0.1 -0.624,-0.208 -0.624,-0.52 v -2.396 l 0.104,-0.1 c 0,0 8.424,0.208 11.44,0.208 2.704,0 7.28,-0.208 7.28,-0.208 l 0.312,0.1 v 2.396 c 0,0.312 -0.312,0.52 -0.832,0.52 -4.056,0.312 -6.864,0.52 -10.608,4.784 l -8.944,10.292 c -1.768,1.876 -2.392,3.016 -2.392,3.852 0,0.624 0.416,1.14 0.936,1.764 l 15.704,18.928 c 1.248,1.452 3.744,2.08 5.824,2.492 l 0.52,0.1 c 0.312,0.104 0.728,0.312 0.728,0.624 v 2.184 l -0.312,0.104 c 0,0 -5.512,-0.104 -8.424,-0.104 -2.6,0 -6.344,0.104 -6.344,0.104 l -0.104,-0.104 v -1.248 c 0,-1.356 -0.104,-2.492 -1.56,-4.156 l -11.544,-14.356 c -1.56,-2.084 -3.224,-2.596 -5.512,-2.596 v 15.404 l 0,0 z" }), _jsx("path", { fill: "currentColor", d: "m 575.08736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.128,-0.212 -2.912,0 -11.024,0.212 -11.024,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.432,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.248,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.44,0.208 2.808,0 10.816,-0.208 10.816,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 v 34.632 z" }), _jsx("path", { fill: "currentColor", d: "m 597.55936,819.80288 c 0,-3.224 -1.352,-3.328 -6.24,-3.64 -0.624,0 -0.728,-0.308 -0.728,-0.52 v -2.392 l 0.208,-0.104 c 1.56,0 7.696,0.208 10.712,0.208 2.912,0 7.072,-0.208 10.92,-0.208 14.76,0 17.464,7.276 17.464,12.692 0,6.244 -3.016,16.016 -17.776,16.016 -2.6,0 -4.68,-0.212 -6.556,-1.04 v 13.928 c 0,2.288 1.248,2.812 4.58,3.328 l 2.084,0.312 c 0.416,0.104 0.728,0.212 0.728,0.624 v 2.184 l -0.1,0.208 c 0,0 -8.32,-0.208 -11.544,-0.208 -2.912,0 -10.712,0.208 -10.712,0.208 l -0.104,-0.208 v -2.184 c 0,-0.416 0.208,-0.52 0.624,-0.624 l 2.184,-0.312 c 3.224,-0.416 4.264,-1.352 4.264,-3.328 l -0.008,-34.94 0,0 z m 8.008,18.1 c 2.08,0.836 4.68,0.936 6.76,0.936 6.244,0 9.248,-3.752 9.248,-11.752 0,-8.944 -4.056,-10.92 -9.768,-10.92 -4.996,0 -6.244,0.936 -6.244,3.64 l 0.004,18.096 0,0 z" }), _jsx("path", { fill: "currentColor", d: "m 647.80736,861.19888 c -3.12,0 -10.292,0.212 -10.292,0.212 l -0.108,-0.212 v -2.288 c 0,-0.204 0.108,-0.516 0.624,-0.516 l 2.396,-0.212 c 3.228,-0.312 4.164,-2.392 4.164,-4.468 v -34.32 c 0,-2.4 -1.252,-2.812 -4.164,-3.016 l -2.396,-0.216 c -0.624,-0.096 -0.624,-0.308 -0.624,-0.416 v -2.396 l 0.108,-0.208 c 0,0 8.108,0.208 11.228,0.208 h 15.288 c 3.12,0 10.508,-0.208 10.508,-0.208 l 0.212,0.208 c 0.1,4.472 0.828,8.536 1.56,12.484 l -2.596,0.416 c -1.14,-3.852 -3.116,-9.36 -9.772,-9.36 h -8.32 c -1.976,0 -3.016,0.728 -3.016,2.492 v 15.084 h 7.796 c 2.916,0 3.64,-1.248 4.06,-3.328 l 0.62,-2.184 c 0,-0.312 0.212,-0.524 0.624,-0.524 h 1.764 c 0.212,0 0.212,0.108 0.212,0.312 -0.212,2.288 -0.624,5.204 -0.624,7.7 0,2.596 0.416,4.784 0.624,7.176 l -0.212,0.212 h -1.764 c -0.516,0 -0.732,-0.212 -0.732,-0.524 l -0.52,-2.284 c -0.416,-2.084 -1.352,-3.228 -4.064,-3.228 h -7.792 v 15.916 c 0,1.972 1.136,3.948 3.016,3.948 h 9.88 c 5.304,0 8.22,-3.328 9.464,-8.74 l 2.596,0.312 -2.084,11.956 -0.208,0.208 c 0,0 -6.136,-0.208 -9.256,-0.208 l -18.2,0.012 0,0 z" }), _jsx("path", { fill: "currentColor", d: "m 686.91936,858.39488 2.392,-0.212 c 3.124,-0.312 4.164,-1.248 4.164,-4.468 v -34.32 c 0,-2.712 -0.736,-2.712 -4.164,-3.016 l -2.28,-0.216 c -0.416,0 -0.736,-0.208 -0.736,-0.52 v -2.288 l 0.1,-0.208 c 0,0 9.156,0.208 11.032,0.208 1.968,0 11.024,-0.208 13.728,-0.208 17.368,0 25.9,10.816 25.9,24.648 0,18.204 -12.9,23.604 -24.44,23.604 -8.32,0 -11.956,-0.208 -15.18,-0.208 -3.124,0 -11.028,0.208 -11.028,0.208 l -0.104,-0.208 v -2.184 c -0.008,-0.3 0.204,-0.612 0.616,-0.612 z m 23.196,0 c 11.436,0 17.892,-4.26 17.892,-18.828 0,-10.812 -2.396,-23.404 -19.868,-23.404 -4.056,0 -6.656,0.624 -6.656,3.232 v 34.32 c 0,2.904 0.724,4.68 8.632,4.68 z" }), _jsx("path", { fill: "currentColor", d: "m 761.60736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.124,-0.212 -2.916,0 -11.024,0.212 -11.024,0.212 l -0.212,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.084,-0.212 c 3.428,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.252,-2.916 -4.472,-3.22 l -2.084,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.432,0.208 2.808,0 10.82,-0.208 10.82,-0.208 l 0.1,0.208 v 2.288 c 0,0.312 -0.212,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 l 0.008,34.632 0,0 z" }), _jsx("path", { fill: "currentColor", d: "m 793.64736,858.18288 3.016,0.212 c 0.416,0 0.832,0.312 0.832,0.828 v 1.976 l -0.208,0.212 c 0,0 -11.336,-0.212 -13.832,-0.212 -2.708,0 -9.364,0.212 -9.364,0.212 l -0.212,-0.212 v -1.976 c 0,-0.516 0.312,-0.828 0.836,-0.828 4.58,-0.312 7.172,-1.148 10.084,-7.804 l 23.084,-54.084 c 1.14,-2.704 1.976,-3.748 3.54,-3.748 1.452,0 1.976,1.044 2.804,3.124 l 21.32,56.368 c 1.46,4.06 3.54,5.616 7.7,6.032 l 1.144,0.1 c 0.52,0 1.04,0.312 1.04,0.836 v 1.972 l -0.312,0.208 c 0,0 -8.008,-0.208 -12.064,-0.208 -3.64,0 -13.836,0.208 -13.836,0.208 l -0.1,-0.208 v -1.972 c 0,-0.524 0.208,-0.836 0.736,-0.836 l 2.912,-0.208 c 3.948,-0.308 5.412,-1.564 4.368,-4.472 l -6.344,-17.58 h -21.632 c -2.496,0 -3.12,0.416 -3.636,1.764 l -6.036,15.084 c -1.04,2.608 0.312,4.9 4.16,5.212 z m 25.48,-26.424 -10.088,-27.764 h -0.208 l -10.4,26.416 c -0.416,1.044 0.308,1.352 2.596,1.352 h 18.1 z" })] }) }));
@@ -23,10 +23,10 @@ function WikiChild({ page, wiki, load }) {
23
23
  const url = (_b = (_a = content_urls === null || content_urls === void 0 ? void 0 : content_urls.desktop) === null || _a === void 0 ? void 0 : _a.page) !== null && _b !== void 0 ? _b : createWikiUrl(page);
24
24
  const image = thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.source;
25
25
  if (error) {
26
- return (_jsxs("span", { children: [_jsxs("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: [_jsx(ExternalLinkIcon, { width: "1rem", height: "1rem", className: "float-right" }), _jsx(WikiTextMark, {})] }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", page, "\" from wikipedia."] })] }));
26
+ return (_jsxs("span", { children: [_jsxs("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: [_jsx(ArrowTopRightOnSquareIcon, { width: "1rem", height: "1rem", className: "float-right" }), _jsx(WikiTextMark, {})] }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", page, "\" from wikipedia."] })] }));
27
27
  }
28
28
  return (_jsx(LinkCard, { loading: !data, url: url, title: _jsx(WikiTextMark, {}), thumbnail: image, description: extract }));
29
29
  }
30
30
  export function WikiLink({ children, page, url, wiki, className, }) {
31
- return (_jsx(HoverPopover, { card: ({ load }) => _jsx(WikiChild, { wiki: wiki, page: page, load: load }), children: _jsx("a", { href: url, className: classNames('italic', className), target: "_blank", rel: "noreferrer", children: children }) }));
31
+ return (_jsx(HoverPopover, { card: ({ load }) => _jsx(WikiChild, { wiki: wiki, page: page, load: load }), children: _jsx("a", { href: url, className: classNames('hover-link', className), target: "_blank", rel: "noreferrer", children: children }) }));
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-to-react",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,6 +17,8 @@
17
17
  },
18
18
  "scripts": {
19
19
  "clean": "rimraf dist",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest watch",
20
22
  "lint": "eslint \"src/**/*.ts*\" \"src/**/*.tsx\" -c ./.eslintrc.cjs",
21
23
  "lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\"",
22
24
  "dev": "npm-run-all --parallel \"build:* -- --watch\"",
@@ -25,7 +27,7 @@
25
27
  },
26
28
  "dependencies": {
27
29
  "@heroicons/react": "^2.0.18",
28
- "@myst-theme/providers": "^1.0.1",
30
+ "@myst-theme/providers": "^1.1.0",
29
31
  "@radix-ui/react-hover-card": "^1.0.6",
30
32
  "@scienceicons/react": "^0.0.13",
31
33
  "buffer": "^6.0.3",