@myst-theme/site 0.8.1 → 0.8.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 +11 -11
- package/src/pages/Article.tsx +22 -3
- package/src/utils.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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.8.
|
|
21
|
-
"@myst-theme/diagrams": "^0.8.
|
|
22
|
-
"@myst-theme/frontmatter": "^0.8.
|
|
23
|
-
"@myst-theme/jupyter": "^0.8.
|
|
24
|
-
"@myst-theme/providers": "^0.8.
|
|
20
|
+
"@myst-theme/common": "^0.8.2",
|
|
21
|
+
"@myst-theme/diagrams": "^0.8.2",
|
|
22
|
+
"@myst-theme/frontmatter": "^0.8.2",
|
|
23
|
+
"@myst-theme/jupyter": "^0.8.2",
|
|
24
|
+
"@myst-theme/providers": "^0.8.2",
|
|
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.8.
|
|
31
|
-
"myst-spec-ext": "^1.1.
|
|
32
|
-
"myst-to-react": "^0.8.
|
|
28
|
+
"myst-common": "^1.1.35",
|
|
29
|
+
"myst-config": "^1.1.35",
|
|
30
|
+
"myst-demo": "^0.8.2",
|
|
31
|
+
"myst-spec-ext": "^1.1.35",
|
|
32
|
+
"myst-to-react": "^0.8.2",
|
|
33
33
|
"nbtx": "^0.2.3",
|
|
34
34
|
"node-cache": "^5.1.2",
|
|
35
35
|
"node-fetch": "^2.6.11",
|
package/src/pages/Article.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ReferencesProvider } from '@myst-theme/providers';
|
|
2
|
+
import { ReferencesProvider, useProjectManifest } from '@myst-theme/providers';
|
|
3
3
|
import {
|
|
4
4
|
Bibliography,
|
|
5
5
|
ContentBlocks,
|
|
@@ -22,6 +22,24 @@ import {
|
|
|
22
22
|
} from '@myst-theme/jupyter';
|
|
23
23
|
import { FrontmatterBlock } from '@myst-theme/frontmatter';
|
|
24
24
|
import { extractKnownParts } from '../utils.js';
|
|
25
|
+
import type { SiteAction } from 'myst-config';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Combines the project downloads and the export options
|
|
29
|
+
*/
|
|
30
|
+
function combineDownloads(
|
|
31
|
+
siteDownloads: SiteAction[] | undefined,
|
|
32
|
+
pageFrontmatter: PageLoader['frontmatter'],
|
|
33
|
+
) {
|
|
34
|
+
if (pageFrontmatter.downloads) {
|
|
35
|
+
return pageFrontmatter.downloads;
|
|
36
|
+
}
|
|
37
|
+
// No downloads on the page, combine the exports if they exist
|
|
38
|
+
if (siteDownloads) {
|
|
39
|
+
return [...(pageFrontmatter.exports ?? []), ...siteDownloads];
|
|
40
|
+
}
|
|
41
|
+
return pageFrontmatter.exports;
|
|
42
|
+
}
|
|
25
43
|
|
|
26
44
|
export const ArticlePage = React.memo(function ({
|
|
27
45
|
article,
|
|
@@ -32,10 +50,11 @@ export const ArticlePage = React.memo(function ({
|
|
|
32
50
|
hide_all_footer_links?: boolean;
|
|
33
51
|
hideKeywords?: boolean;
|
|
34
52
|
}) {
|
|
53
|
+
const manifest = useProjectManifest();
|
|
35
54
|
const compute = useComputeOptions();
|
|
36
55
|
|
|
37
56
|
const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.options ?? {};
|
|
38
|
-
|
|
57
|
+
const downloads = combineDownloads(manifest?.downloads, article.frontmatter);
|
|
39
58
|
const tree = copyNode(article.mdast);
|
|
40
59
|
const keywords = article.frontmatter?.keywords ?? [];
|
|
41
60
|
const parts = extractKnownParts(tree);
|
|
@@ -50,7 +69,7 @@ export const ArticlePage = React.memo(function ({
|
|
|
50
69
|
{!hide_title_block && (
|
|
51
70
|
<FrontmatterBlock
|
|
52
71
|
kind={article.kind}
|
|
53
|
-
frontmatter={article.frontmatter}
|
|
72
|
+
frontmatter={{ ...article.frontmatter, downloads }}
|
|
54
73
|
className="pt-5 mb-8"
|
|
55
74
|
/>
|
|
56
75
|
)}
|
package/src/utils.ts
CHANGED
|
@@ -17,9 +17,9 @@ export type KnownParts = {
|
|
|
17
17
|
|
|
18
18
|
export function extractKnownParts(tree: GenericParent): KnownParts {
|
|
19
19
|
const abstract = extractPart(tree, 'abstract');
|
|
20
|
-
const summary = extractPart(tree, 'summary');
|
|
21
|
-
const keypoints = extractPart(tree, 'keypoints');
|
|
22
|
-
const data_availability = extractPart(tree, 'data_availability');
|
|
23
|
-
const acknowledgments = extractPart(tree, 'acknowledgments');
|
|
20
|
+
const summary = extractPart(tree, 'summary', { requireExplicitPart: true });
|
|
21
|
+
const keypoints = extractPart(tree, ['keypoints'], { requireExplicitPart: true });
|
|
22
|
+
const data_availability = extractPart(tree, ['data_availability', 'data availability']);
|
|
23
|
+
const acknowledgments = extractPart(tree, ['acknowledgments', 'acknowledgements']);
|
|
24
24
|
return { abstract, summary, keypoints, data_availability, acknowledgments };
|
|
25
25
|
}
|