@myst-theme/site 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@headlessui/react": "^1.7.15",
|
|
27
27
|
"@heroicons/react": "^2.0.18",
|
|
28
|
-
"@myst-theme/common": "^1.1.
|
|
29
|
-
"@myst-theme/diagrams": "^1.1.
|
|
30
|
-
"@myst-theme/frontmatter": "^1.1.
|
|
31
|
-
"@myst-theme/providers": "^1.1.
|
|
32
|
-
"@myst-theme/search": "^1.1.
|
|
28
|
+
"@myst-theme/common": "^1.1.3",
|
|
29
|
+
"@myst-theme/diagrams": "^1.1.3",
|
|
30
|
+
"@myst-theme/frontmatter": "^1.1.3",
|
|
31
|
+
"@myst-theme/providers": "^1.1.3",
|
|
32
|
+
"@myst-theme/search": "^1.1.3",
|
|
33
33
|
"@radix-ui/react-collapsible": "^1.0.3",
|
|
34
34
|
"@radix-ui/react-dialog": "^1.0.3",
|
|
35
35
|
"@radix-ui/react-visually-hidden": "^1.1.0",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"lodash.throttle": "^4.1.1",
|
|
38
38
|
"myst-common": "^1.8.1",
|
|
39
39
|
"myst-config": "^1.7.9",
|
|
40
|
-
"myst-demo": "^1.1.
|
|
40
|
+
"myst-demo": "^1.1.3",
|
|
41
41
|
"myst-spec-ext": "^1.8.1",
|
|
42
|
-
"myst-to-react": "^1.1.
|
|
42
|
+
"myst-to-react": "^1.1.3",
|
|
43
43
|
"nbtx": "^0.2.3",
|
|
44
44
|
"node-cache": "^5.1.2",
|
|
45
45
|
"node-fetch": "^2.6.11",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isExternalUrl,
|
|
4
|
+
useLinkProvider,
|
|
5
|
+
useNavLinkProvider,
|
|
6
|
+
useSiteManifest,
|
|
7
|
+
} from '@myst-theme/providers';
|
|
3
8
|
|
|
4
9
|
export function ExternalOrInternalLink({
|
|
5
10
|
to,
|
|
@@ -18,8 +23,9 @@ export function ExternalOrInternalLink({
|
|
|
18
23
|
}) {
|
|
19
24
|
const Link = useLinkProvider();
|
|
20
25
|
const NavLink = useNavLinkProvider();
|
|
26
|
+
const config = useSiteManifest();
|
|
21
27
|
const staticClass = typeof className === 'function' ? className({ isActive: false }) : className;
|
|
22
|
-
if (isExternalUrl(to)) {
|
|
28
|
+
if (isExternalUrl(to, config?.options?.internal_domains)) {
|
|
23
29
|
return (
|
|
24
30
|
<a
|
|
25
31
|
href={to}
|
|
@@ -3,10 +3,12 @@ import classNames from 'classnames';
|
|
|
3
3
|
import * as Collapsible from '@radix-ui/react-collapsible';
|
|
4
4
|
import type { Heading } from '@myst-theme/common';
|
|
5
5
|
import {
|
|
6
|
+
isExternalUrl,
|
|
6
7
|
useBaseurl,
|
|
7
8
|
useLinkProvider,
|
|
8
9
|
useNavLinkProvider,
|
|
9
10
|
useNavOpen,
|
|
11
|
+
useSiteManifest,
|
|
10
12
|
withBaseurl,
|
|
11
13
|
} from '@myst-theme/providers';
|
|
12
14
|
import { useLocation, useNavigation } from '@remix-run/react';
|
|
@@ -87,8 +89,11 @@ function LinkItem({
|
|
|
87
89
|
const baseurl = useBaseurl();
|
|
88
90
|
const [, setOpen] = useNavOpen();
|
|
89
91
|
// Render external URL
|
|
92
|
+
const config = useSiteManifest();
|
|
93
|
+
// In case the URL part of our "treat as internal" domain list
|
|
94
|
+
const treatAsInternal = !isExternalUrl(heading.url, config?.options?.internal_domains);
|
|
90
95
|
if (heading.url) {
|
|
91
|
-
const target = heading.open_in_same_tab ? '_self' : '_blank';
|
|
96
|
+
const target = heading.open_in_same_tab || treatAsInternal ? '_self' : '_blank';
|
|
92
97
|
return (
|
|
93
98
|
<Link
|
|
94
99
|
title={`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
|
|
@@ -106,7 +111,9 @@ function LinkItem({
|
|
|
106
111
|
<span className="inline align-middle">
|
|
107
112
|
{`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
|
|
108
113
|
</span>
|
|
109
|
-
|
|
114
|
+
{!treatAsInternal && (
|
|
115
|
+
<ArrowTopRightOnSquareIcon className="inline h-4 w-4 align-middle ml-[0.2rem]" />
|
|
116
|
+
)}
|
|
110
117
|
</Link>
|
|
111
118
|
);
|
|
112
119
|
}
|