@myst-theme/site 0.8.1 → 0.8.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 +11 -11
- package/src/pages/Article.tsx +22 -3
- package/src/pages/Root.tsx +4 -1
- 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.3",
|
|
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.3",
|
|
21
|
+
"@myst-theme/diagrams": "^0.8.3",
|
|
22
|
+
"@myst-theme/frontmatter": "^0.8.3",
|
|
23
|
+
"@myst-theme/jupyter": "^0.8.3",
|
|
24
|
+
"@myst-theme/providers": "^0.8.3",
|
|
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.3",
|
|
31
|
+
"myst-spec-ext": "^1.1.35",
|
|
32
|
+
"myst-to-react": "^0.8.3",
|
|
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/pages/Root.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SiteManifest } from 'myst-config';
|
|
2
2
|
import type { SiteLoader } from '@myst-theme/common';
|
|
3
|
+
import type { NodeRenderer } from '@myst-theme/providers';
|
|
3
4
|
import { BaseUrlProvider, SiteProvider, Theme, ThemeProvider } from '@myst-theme/providers';
|
|
4
5
|
import {
|
|
5
6
|
Links,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
Link,
|
|
13
14
|
NavLink,
|
|
14
15
|
} from '@remix-run/react';
|
|
15
|
-
import { DEFAULT_NAV_HEIGHT, renderers } from '../components/index.js';
|
|
16
|
+
import { DEFAULT_NAV_HEIGHT, renderers as defaultRenderers } from '../components/index.js';
|
|
16
17
|
import { Analytics } from '../seo/index.js';
|
|
17
18
|
import { Error404 } from './Error404.js';
|
|
18
19
|
import classNames from 'classnames';
|
|
@@ -26,6 +27,7 @@ export function Document({
|
|
|
26
27
|
staticBuild,
|
|
27
28
|
baseurl,
|
|
28
29
|
top = DEFAULT_NAV_HEIGHT,
|
|
30
|
+
renderers = defaultRenderers,
|
|
29
31
|
}: {
|
|
30
32
|
children: React.ReactNode;
|
|
31
33
|
scripts?: React.ReactNode;
|
|
@@ -35,6 +37,7 @@ export function Document({
|
|
|
35
37
|
staticBuild?: boolean;
|
|
36
38
|
baseurl?: string;
|
|
37
39
|
top?: number;
|
|
40
|
+
renderers?: Record<string, NodeRenderer>;
|
|
38
41
|
}) {
|
|
39
42
|
const links = staticBuild
|
|
40
43
|
? {
|
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
|
}
|