@myst-theme/site 0.5.13 → 0.5.15
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": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@headlessui/react": "^1.7.15",
|
|
19
19
|
"@heroicons/react": "^2.0.18",
|
|
20
|
-
"@myst-theme/common": "^0.5.
|
|
21
|
-
"@myst-theme/diagrams": "^0.5.
|
|
22
|
-
"@myst-theme/frontmatter": "^0.5.
|
|
23
|
-
"@myst-theme/jupyter": "^0.5.
|
|
24
|
-
"@myst-theme/providers": "^0.5.
|
|
20
|
+
"@myst-theme/common": "^0.5.15",
|
|
21
|
+
"@myst-theme/diagrams": "^0.5.15",
|
|
22
|
+
"@myst-theme/frontmatter": "^0.5.15",
|
|
23
|
+
"@myst-theme/jupyter": "^0.5.15",
|
|
24
|
+
"@myst-theme/providers": "^0.5.15",
|
|
25
25
|
"@radix-ui/react-collapsible": "^1.0.3",
|
|
26
26
|
"classnames": "^2.3.2",
|
|
27
27
|
"lodash.throttle": "^4.1.1",
|
|
28
|
-
"myst-common": "^1.1.
|
|
29
|
-
"myst-config": "^1.1.
|
|
30
|
-
"myst-demo": "^0.5.
|
|
31
|
-
"myst-spec-ext": "^1.1.
|
|
32
|
-
"myst-to-react": "^0.5.
|
|
28
|
+
"myst-common": "^1.1.15",
|
|
29
|
+
"myst-config": "^1.1.15",
|
|
30
|
+
"myst-demo": "^0.5.15",
|
|
31
|
+
"myst-spec-ext": "^1.1.15",
|
|
32
|
+
"myst-to-react": "^0.5.15",
|
|
33
33
|
"nbtx": "^0.2.3",
|
|
34
34
|
"node-cache": "^5.1.2",
|
|
35
35
|
"node-fetch": "^2.6.11",
|
|
@@ -6,12 +6,12 @@ import type { KnownParts } from '../utils.js';
|
|
|
6
6
|
export function BackmatterParts({ parts }: { parts: KnownParts }) {
|
|
7
7
|
return (
|
|
8
8
|
<>
|
|
9
|
+
<Backmatter title="Acknowledgments" id="acknowledgments" content={parts.acknowledgments} />
|
|
9
10
|
<Backmatter
|
|
10
11
|
title="Data Availability"
|
|
11
12
|
id="data-availability"
|
|
12
13
|
content={parts.data_availability}
|
|
13
14
|
/>
|
|
14
|
-
<Backmatter title="Acknowledgments" id="acknowledgments" content={parts.acknowledgments} />
|
|
15
15
|
</>
|
|
16
16
|
);
|
|
17
17
|
}
|
|
@@ -27,16 +27,19 @@ export function Backmatter({
|
|
|
27
27
|
}) {
|
|
28
28
|
if (!content) return null;
|
|
29
29
|
return (
|
|
30
|
-
<div className="flex flex-col w-full md:flex-row">
|
|
30
|
+
<div className="flex flex-col w-full md:flex-row group/backmatter">
|
|
31
31
|
<h2
|
|
32
32
|
id={id}
|
|
33
|
-
className="mt-5 text-base font-semibold group md:w-[200px] self-start md:flex-none opacity-90"
|
|
33
|
+
className="mt-5 text-base font-semibold group md:w-[200px] self-start md:flex-none opacity-90 group-hover/backmatter:opacity-100"
|
|
34
34
|
>
|
|
35
35
|
{title}
|
|
36
36
|
<HashLink id={id} title={`Link to ${title}`} hover className="ml-2" />
|
|
37
37
|
</h2>
|
|
38
38
|
<div className="grow">
|
|
39
|
-
<ContentBlocks
|
|
39
|
+
<ContentBlocks
|
|
40
|
+
mdast={content}
|
|
41
|
+
className="opacity-90 group-hover/backmatter:opacity-100 col-screen"
|
|
42
|
+
/>
|
|
40
43
|
</div>
|
|
41
44
|
</div>
|
|
42
45
|
);
|
|
@@ -3,6 +3,7 @@ import { SourceFileKind } from 'myst-spec-ext';
|
|
|
3
3
|
import type { GenericParent } from 'myst-common';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import {
|
|
6
|
+
executableNodesFromBlock,
|
|
6
7
|
NotebookClearCell,
|
|
7
8
|
NotebookRunCell,
|
|
8
9
|
NotebookRunCellSpinnerOnly,
|
|
@@ -10,14 +11,7 @@ import {
|
|
|
10
11
|
import { useGridSystemProvider } from '@myst-theme/providers';
|
|
11
12
|
|
|
12
13
|
function isACodeCell(node: GenericParent) {
|
|
13
|
-
return (
|
|
14
|
-
node &&
|
|
15
|
-
node.type === 'block' &&
|
|
16
|
-
node.children &&
|
|
17
|
-
node.children?.length === 2 &&
|
|
18
|
-
node.children[0].type === 'code' &&
|
|
19
|
-
node.children[1].type === 'output'
|
|
20
|
-
);
|
|
14
|
+
return !!executableNodesFromBlock(node);
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
function Block({
|
|
@@ -16,6 +16,7 @@ const HIGHLIGHT_CLASS = 'highlight';
|
|
|
16
16
|
const onClient = typeof document !== 'undefined';
|
|
17
17
|
|
|
18
18
|
type Heading = {
|
|
19
|
+
element: HTMLHeadingElement;
|
|
19
20
|
id: string;
|
|
20
21
|
title: string;
|
|
21
22
|
titleHTML: string;
|
|
@@ -46,15 +47,15 @@ const Headings = ({ headings, activeId, highlight, selector }: Props) => (
|
|
|
46
47
|
>
|
|
47
48
|
<a
|
|
48
49
|
className={classNames('block p-1', {
|
|
49
|
-
'text-slate-900 dark:text-slate-50': heading.level <
|
|
50
|
-
'text-slate-500 dark:text-slate-300': heading.level >=
|
|
50
|
+
'text-slate-900 dark:text-slate-50': heading.level < 2 && heading.id !== activeId,
|
|
51
|
+
'text-slate-500 dark:text-slate-300': heading.level >= 2 && heading.id !== activeId,
|
|
51
52
|
'text-blue-600 dark:text-white font-bold': heading.id === activeId,
|
|
52
53
|
'pr-2': heading.id !== activeId, // Allows for bold to change length
|
|
53
|
-
'pl-2': heading.level === 1
|
|
54
|
-
'pl-4': heading.level ===
|
|
55
|
-
'pl-8 text-xs': heading.level ===
|
|
56
|
-
'pl-10 text-xs font-light': heading.level ===
|
|
57
|
-
'pl-12 text-xs font-extralight': heading.level ===
|
|
54
|
+
'pl-2': heading.level === 1,
|
|
55
|
+
'pl-4': heading.level === 2,
|
|
56
|
+
'pl-8 text-xs': heading.level === 3,
|
|
57
|
+
'pl-10 text-xs font-light': heading.level === 4,
|
|
58
|
+
'pl-12 text-xs font-extralight': heading.level === 5,
|
|
58
59
|
})}
|
|
59
60
|
href={`#${heading.id}`}
|
|
60
61
|
onClick={(e) => {
|
|
@@ -104,7 +105,7 @@ function getHeaders(selector: string): HTMLHeadingElement[] {
|
|
|
104
105
|
return headers as HTMLHeadingElement[];
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
function useHeaders(selector: string) {
|
|
108
|
+
function useHeaders(selector: string, maxdepth: number) {
|
|
108
109
|
if (!onClient) return { activeId: '', headings: [] };
|
|
109
110
|
const onScreen = useRef<Set<HTMLHeadingElement>>(new Set());
|
|
110
111
|
const [activeId, setActiveId] = useState<string>();
|
|
@@ -145,28 +146,35 @@ function useHeaders(selector: string) {
|
|
|
145
146
|
Array.from(elements).map((e) => observer.current?.observe(e));
|
|
146
147
|
}, [observer]);
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
if (headingsSet.current.has(e)) return;
|
|
150
|
-
observer.current?.observe(e);
|
|
151
|
-
headingsSet.current.add(e);
|
|
152
|
-
});
|
|
153
|
-
|
|
149
|
+
let minLevel = 10;
|
|
154
150
|
const headings: Heading[] = elements
|
|
155
|
-
.map((
|
|
151
|
+
.map((element) => {
|
|
156
152
|
return {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
element,
|
|
154
|
+
level: Number(element.tagName.slice(1)),
|
|
155
|
+
id: element.id,
|
|
156
|
+
text: element.querySelector('.heading-text'),
|
|
160
157
|
};
|
|
161
158
|
})
|
|
162
159
|
.filter((h) => !!h.text)
|
|
163
|
-
.map(({ level, text, id }) => {
|
|
160
|
+
.map(({ element, level, text, id }) => {
|
|
164
161
|
const { innerText: title, innerHTML: titleHTML } = cloneHeadingElement(
|
|
165
162
|
text as HTMLSpanElement,
|
|
166
163
|
);
|
|
167
|
-
|
|
164
|
+
minLevel = Math.min(minLevel, level);
|
|
165
|
+
return { element, title, titleHTML, id, level };
|
|
166
|
+
})
|
|
167
|
+
.filter((heading) => {
|
|
168
|
+
heading.level = heading.level - minLevel + 1;
|
|
169
|
+
return heading.level < maxdepth + 1;
|
|
168
170
|
});
|
|
169
171
|
|
|
172
|
+
headings.forEach(({ element: e }) => {
|
|
173
|
+
if (headingsSet.current.has(e)) return;
|
|
174
|
+
observer.current?.observe(e);
|
|
175
|
+
headingsSet.current.add(e);
|
|
176
|
+
});
|
|
177
|
+
|
|
170
178
|
return { activeId, highlight, headings };
|
|
171
179
|
}
|
|
172
180
|
|
|
@@ -224,6 +232,7 @@ export const DocumentOutline = ({
|
|
|
224
232
|
className,
|
|
225
233
|
selector = SELECTOR,
|
|
226
234
|
children,
|
|
235
|
+
maxdepth = 4,
|
|
227
236
|
}: {
|
|
228
237
|
outlineRef?: React.RefObject<HTMLElement>;
|
|
229
238
|
top?: number;
|
|
@@ -231,8 +240,9 @@ export const DocumentOutline = ({
|
|
|
231
240
|
className?: string;
|
|
232
241
|
selector?: string;
|
|
233
242
|
children?: React.ReactNode;
|
|
243
|
+
maxdepth?: number;
|
|
234
244
|
}) => {
|
|
235
|
-
const { activeId, headings, highlight } = useHeaders(selector);
|
|
245
|
+
const { activeId, headings, highlight } = useHeaders(selector, maxdepth);
|
|
236
246
|
if (headings.length <= 1 || !onClient) {
|
|
237
247
|
return <nav suppressHydrationWarning>{children}</nav>;
|
|
238
248
|
}
|