@myst-theme/site 0.4.1 → 0.4.2
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.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"main": "./src/index.ts",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@headlessui/react": "^1.7.15",
|
|
18
18
|
"@heroicons/react": "^2.0.18",
|
|
19
|
-
"@myst-theme/diagrams": "^0.4.
|
|
20
|
-
"@myst-theme/frontmatter": "^0.4.
|
|
21
|
-
"@myst-theme/jupyter": "^0.4.
|
|
22
|
-
"@myst-theme/common": "^0.4.
|
|
23
|
-
"@myst-theme/providers": "^0.4.
|
|
19
|
+
"@myst-theme/diagrams": "^0.4.2",
|
|
20
|
+
"@myst-theme/frontmatter": "^0.4.2",
|
|
21
|
+
"@myst-theme/jupyter": "^0.4.2",
|
|
22
|
+
"@myst-theme/common": "^0.4.2",
|
|
23
|
+
"@myst-theme/providers": "^0.4.2",
|
|
24
24
|
"classnames": "^2.3.2",
|
|
25
25
|
"lodash.throttle": "^4.1.1",
|
|
26
|
-
"myst-common": "^1.1.
|
|
27
|
-
"myst-spec-ext": "^1.1.
|
|
28
|
-
"myst-config": "^1.1.
|
|
29
|
-
"myst-demo": "^0.4.
|
|
30
|
-
"myst-to-react": "^0.4.
|
|
26
|
+
"myst-common": "^1.1.1",
|
|
27
|
+
"myst-spec-ext": "^1.1.1",
|
|
28
|
+
"myst-config": "^1.1.1",
|
|
29
|
+
"myst-demo": "^0.4.2",
|
|
30
|
+
"myst-to-react": "^0.4.2",
|
|
31
31
|
"nbtx": "^0.2.3",
|
|
32
32
|
"node-cache": "^5.1.2",
|
|
33
33
|
"node-fetch": "^2.6.11",
|
|
@@ -70,6 +70,25 @@ const Headings = ({ headings, activeId, highlight, selector }: Props) => (
|
|
|
70
70
|
</ul>
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
+
function cloneHeadingElement(originalElement: HTMLSpanElement) {
|
|
74
|
+
// Clone the original element
|
|
75
|
+
const clonedElement = originalElement.cloneNode(true) as HTMLSpanElement;
|
|
76
|
+
|
|
77
|
+
// Get all <abbr> elements in the cloned element
|
|
78
|
+
const abbrElements = clonedElement.getElementsByTagName('abbr');
|
|
79
|
+
|
|
80
|
+
// Move children of <abbr> elements to their parent
|
|
81
|
+
for (let i = 0; i < abbrElements.length; i++) {
|
|
82
|
+
const abbr = abbrElements[i];
|
|
83
|
+
const parent = abbr.parentNode as HTMLSpanElement;
|
|
84
|
+
while (abbr.firstChild) {
|
|
85
|
+
parent.insertBefore(abbr.firstChild, abbr);
|
|
86
|
+
}
|
|
87
|
+
parent.removeChild(abbr);
|
|
88
|
+
}
|
|
89
|
+
return clonedElement;
|
|
90
|
+
}
|
|
91
|
+
|
|
73
92
|
function getHeaders(selector: string): HTMLHeadingElement[] {
|
|
74
93
|
const headers = Array.from(document.querySelectorAll(selector)).filter((e) => {
|
|
75
94
|
const parent = e.closest('.exclude-from-outline');
|
|
@@ -135,7 +154,9 @@ function useHeaders(selector: string) {
|
|
|
135
154
|
})
|
|
136
155
|
.filter((h) => !!h.text)
|
|
137
156
|
.map(({ level, text, id }) => {
|
|
138
|
-
const { innerText: title, innerHTML: titleHTML } =
|
|
157
|
+
const { innerText: title, innerHTML: titleHTML } = cloneHeadingElement(
|
|
158
|
+
text as HTMLSpanElement,
|
|
159
|
+
);
|
|
139
160
|
return { title, titleHTML, id, level };
|
|
140
161
|
});
|
|
141
162
|
|
|
@@ -36,7 +36,7 @@ const FooterLink = ({
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export function FooterLinksBlock({ links }: { links?: FooterLinks }) {
|
|
39
|
-
if (!links) return null;
|
|
39
|
+
if (!links || (!links.navigation?.prev && !links.navigation?.next)) return null;
|
|
40
40
|
return (
|
|
41
41
|
<div className="flex pt-10 mb-10 space-x-4">
|
|
42
42
|
{links.navigation?.prev && <FooterLink {...links.navigation?.prev} right />}
|
package/src/pages/Article.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { Bibliography, ContentBlocks, FooterLinksBlock } from '../components';
|
|
|
4
4
|
import { ErrorDocumentNotFound } from './ErrorDocumentNotFound';
|
|
5
5
|
import { ErrorProjectNotFound } from './ErrorProjectNotFound';
|
|
6
6
|
import type { PageLoader } from '@myst-theme/common';
|
|
7
|
-
import type
|
|
7
|
+
import { copyNode, extractPart, type GenericParent } from 'myst-common';
|
|
8
8
|
import { SourceFileKind } from 'myst-spec-ext';
|
|
9
9
|
import {
|
|
10
10
|
useComputeOptions,
|
|
@@ -17,18 +17,26 @@ import {
|
|
|
17
17
|
ErrorTray,
|
|
18
18
|
} from '@myst-theme/jupyter';
|
|
19
19
|
import { FrontmatterBlock } from '@myst-theme/frontmatter';
|
|
20
|
+
import classNames from 'classnames';
|
|
20
21
|
|
|
21
22
|
export const ArticlePage = React.memo(function ({
|
|
22
23
|
article,
|
|
23
24
|
hide_all_footer_links,
|
|
25
|
+
showAbstract,
|
|
26
|
+
hideKeywords,
|
|
24
27
|
}: {
|
|
25
28
|
article: PageLoader;
|
|
26
29
|
hide_all_footer_links?: boolean;
|
|
30
|
+
showAbstract?: boolean;
|
|
31
|
+
hideKeywords?: boolean;
|
|
27
32
|
}) {
|
|
28
33
|
const canCompute = useCanCompute(article);
|
|
29
34
|
const { binderBadgeUrl } = useComputeOptions();
|
|
30
35
|
const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.design ?? {};
|
|
31
36
|
|
|
37
|
+
const tree = copyNode(article.mdast);
|
|
38
|
+
const keywords = article.frontmatter?.keywords ?? [];
|
|
39
|
+
const abstract = showAbstract ? extractPart(tree, 'abstract') : undefined;
|
|
32
40
|
// take binder url from article frontmatter or fallback to project
|
|
33
41
|
const binderUrl = article.frontmatter.binder ?? binderBadgeUrl;
|
|
34
42
|
|
|
@@ -53,7 +61,30 @@ export const ArticlePage = React.memo(function ({
|
|
|
53
61
|
)}
|
|
54
62
|
{canCompute && article.kind === SourceFileKind.Notebook && <NotebookToolbar showLaunch />}
|
|
55
63
|
<ErrorTray pageSlug={article.slug} />
|
|
56
|
-
|
|
64
|
+
{abstract && (
|
|
65
|
+
<>
|
|
66
|
+
<span className="font-semibold">Abstract</span>
|
|
67
|
+
<div className="px-6 py-1 m-3 rounded-sm bg-slate-50 dark:bg-slate-800">
|
|
68
|
+
<ContentBlocks mdast={abstract as GenericParent} className="col-body" />
|
|
69
|
+
</div>
|
|
70
|
+
{!hideKeywords && keywords.length > 0 && (
|
|
71
|
+
<div className="mb-10">
|
|
72
|
+
<span className="mr-2 font-semibold">Keywords:</span>
|
|
73
|
+
{keywords.map((k, i) => (
|
|
74
|
+
<span
|
|
75
|
+
key={k}
|
|
76
|
+
className={classNames({
|
|
77
|
+
"after:content-[','] after:mr-1": i < keywords.length - 1,
|
|
78
|
+
})}
|
|
79
|
+
>
|
|
80
|
+
{k}
|
|
81
|
+
</span>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
87
|
+
<ContentBlocks pageKind={article.kind} mdast={tree as GenericParent} />
|
|
57
88
|
<Bibliography />
|
|
58
89
|
<ConnectionStatusTray />
|
|
59
90
|
{!hide_footer_links && !hide_all_footer_links && (
|