@myst-theme/site 0.13.7 → 0.14.0
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 -12
- package/src/components/Abstract.tsx +2 -3
- package/src/components/ContentBlocks.tsx +9 -78
- package/src/components/renderers.ts +0 -2
- package/src/pages/index.ts +0 -1
- package/src/themeCSS.ts +13 -3
- package/src/utils.ts +0 -5
- package/src/pages/Article.tsx +0 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -21,22 +21,21 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@headlessui/react": "^1.7.15",
|
|
23
23
|
"@heroicons/react": "^2.0.18",
|
|
24
|
-
"@myst-theme/common": "^0.
|
|
25
|
-
"@myst-theme/diagrams": "^0.
|
|
26
|
-
"@myst-theme/frontmatter": "^0.
|
|
27
|
-
"@myst-theme/
|
|
28
|
-
"@myst-theme/
|
|
29
|
-
"@myst-theme/search": "^0.13.7",
|
|
24
|
+
"@myst-theme/common": "^0.14.0",
|
|
25
|
+
"@myst-theme/diagrams": "^0.14.0",
|
|
26
|
+
"@myst-theme/frontmatter": "^0.14.0",
|
|
27
|
+
"@myst-theme/providers": "^0.14.0",
|
|
28
|
+
"@myst-theme/search": "^0.14.0",
|
|
30
29
|
"@radix-ui/react-collapsible": "^1.0.3",
|
|
31
30
|
"@radix-ui/react-dialog": "^1.0.3",
|
|
32
31
|
"@radix-ui/react-visually-hidden": "^1.1.0",
|
|
33
32
|
"classnames": "^2.3.2",
|
|
34
33
|
"lodash.throttle": "^4.1.1",
|
|
35
|
-
"myst-common": "^1.7.
|
|
36
|
-
"myst-config": "^1.7.
|
|
37
|
-
"myst-demo": "^0.
|
|
38
|
-
"myst-spec-ext": "^1.7.
|
|
39
|
-
"myst-to-react": "^0.
|
|
34
|
+
"myst-common": "^1.7.9",
|
|
35
|
+
"myst-config": "^1.7.9",
|
|
36
|
+
"myst-demo": "^0.14.0",
|
|
37
|
+
"myst-spec-ext": "^1.7.9",
|
|
38
|
+
"myst-to-react": "^0.14.0",
|
|
40
39
|
"nbtx": "^0.2.3",
|
|
41
40
|
"node-cache": "^5.1.2",
|
|
42
41
|
"node-fetch": "^2.6.11",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { GenericParent } from 'myst-common';
|
|
2
|
-
import {
|
|
3
|
-
import { HashLink } from 'myst-to-react';
|
|
2
|
+
import { MyST, HashLink } from 'myst-to-react';
|
|
4
3
|
|
|
5
4
|
export function Abstract({
|
|
6
5
|
content,
|
|
@@ -21,7 +20,7 @@ export function Abstract({
|
|
|
21
20
|
<HashLink id={id} title={`Link to ${title}`} hover className="ml-2" />
|
|
22
21
|
</h2>
|
|
23
22
|
<div className="px-6 py-1 mb-3 rounded-sm bg-slate-50 dark:bg-slate-800">
|
|
24
|
-
<
|
|
23
|
+
<MyST ast={content} className="col-body" />
|
|
25
24
|
</div>
|
|
26
25
|
</div>
|
|
27
26
|
);
|
|
@@ -1,89 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SourceFileKind } from 'myst-spec-ext';
|
|
1
|
+
import type { SourceFileKind } from 'myst-spec-ext';
|
|
3
2
|
import type { GenericParent } from 'myst-common';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
NotebookClearCell,
|
|
7
|
-
NotebookRunCell,
|
|
8
|
-
NotebookRunCellSpinnerOnly,
|
|
9
|
-
} from '@myst-theme/jupyter';
|
|
10
|
-
import { useGridSystemProvider } from '@myst-theme/providers';
|
|
11
|
-
import { isACodeCell } from '../utils.js';
|
|
12
|
-
|
|
13
|
-
export function Block({
|
|
14
|
-
id,
|
|
15
|
-
pageKind,
|
|
16
|
-
node,
|
|
17
|
-
className,
|
|
18
|
-
}: {
|
|
19
|
-
id: string;
|
|
20
|
-
pageKind: SourceFileKind;
|
|
21
|
-
node: GenericParent;
|
|
22
|
-
className?: string;
|
|
23
|
-
}) {
|
|
24
|
-
const grid = useGridSystemProvider();
|
|
25
|
-
const subGrid = node.visibility === 'hide' ? '' : `${grid} subgrid-gap col-screen`;
|
|
26
|
-
const dataClassName = typeof node.data?.class === 'string' ? node.data?.class : undefined;
|
|
27
|
-
// Hide the subgrid if either the dataClass or the className exists and includes `col-`
|
|
28
|
-
const noSubGrid =
|
|
29
|
-
(dataClassName && dataClassName.includes('col-')) || (className && className.includes('col-'));
|
|
30
|
-
const block = (
|
|
31
|
-
<div
|
|
32
|
-
key={`block-${id}`}
|
|
33
|
-
id={id}
|
|
34
|
-
className={classNames('relative group/block', className, dataClassName, {
|
|
35
|
-
[subGrid]: !noSubGrid,
|
|
36
|
-
hidden: node.visibility === 'remove',
|
|
37
|
-
})}
|
|
38
|
-
>
|
|
39
|
-
{pageKind === SourceFileKind.Notebook && isACodeCell(node) && (
|
|
40
|
-
<>
|
|
41
|
-
<div className="flex sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:hidden">
|
|
42
|
-
<div className="absolute top-0 -right-[28px] flex md:flex-col">
|
|
43
|
-
<NotebookRunCellSpinnerOnly id={id} />
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
<div className="hidden sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:flex">
|
|
47
|
-
<div className="absolute top-0 -right-[28px] flex md:flex-col">
|
|
48
|
-
<NotebookRunCell id={id} />
|
|
49
|
-
<NotebookClearCell id={id} />
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</>
|
|
53
|
-
)}
|
|
54
|
-
<MyST ast={node.children} />
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
if (node.visibility === 'hide') {
|
|
58
|
-
return <Details title="Notebook Cell">{block}</Details>;
|
|
59
|
-
}
|
|
60
|
-
return block;
|
|
61
|
-
}
|
|
3
|
+
import { MyST, Block as MystBlock } from 'myst-to-react';
|
|
62
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated This component is not maintained, in favor of the generic `MyST` component
|
|
7
|
+
*/
|
|
63
8
|
export function ContentBlocks({
|
|
64
9
|
mdast,
|
|
65
|
-
pageKind = SourceFileKind.Article,
|
|
66
10
|
className,
|
|
67
11
|
}: {
|
|
68
12
|
mdast: GenericParent;
|
|
69
13
|
pageKind?: SourceFileKind;
|
|
70
14
|
className?: string;
|
|
71
15
|
}) {
|
|
72
|
-
|
|
73
|
-
const blocks = mdast.children as GenericParent[];
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
{blocks
|
|
77
|
-
.filter((node) => node.visibility !== 'remove')
|
|
78
|
-
.map((node) => (
|
|
79
|
-
<Block
|
|
80
|
-
key={node.key}
|
|
81
|
-
id={node.key}
|
|
82
|
-
pageKind={pageKind}
|
|
83
|
-
node={node}
|
|
84
|
-
className={className}
|
|
85
|
-
/>
|
|
86
|
-
))}
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
16
|
+
return <MyST ast={mdast} className={className} />;
|
|
89
17
|
}
|
|
18
|
+
|
|
19
|
+
/** @deprecated use `import { Block } from 'myst-to-react';` */
|
|
20
|
+
export const Block = MystBlock;
|
|
@@ -2,11 +2,9 @@ import type { NodeRenderers } from '@myst-theme/providers';
|
|
|
2
2
|
import { DEFAULT_RENDERERS } from 'myst-to-react';
|
|
3
3
|
import { MystDemoRenderer } from 'myst-demo';
|
|
4
4
|
import { MermaidNodeRenderer } from '@myst-theme/diagrams';
|
|
5
|
-
import OUTPUT_RENDERERS from '@myst-theme/jupyter';
|
|
6
5
|
|
|
7
6
|
export const renderers: NodeRenderers = {
|
|
8
7
|
...DEFAULT_RENDERERS,
|
|
9
8
|
myst: MystDemoRenderer,
|
|
10
9
|
mermaid: MermaidNodeRenderer,
|
|
11
|
-
...OUTPUT_RENDERERS,
|
|
12
10
|
};
|
package/src/pages/index.ts
CHANGED
|
@@ -2,5 +2,4 @@ export { ErrorProjectNotFound } from './ErrorProjectNotFound.js';
|
|
|
2
2
|
export { ErrorDocumentNotFound } from './ErrorDocumentNotFound.js';
|
|
3
3
|
export { Error404 } from './Error404.js';
|
|
4
4
|
export { ErrorUnhandled } from './ErrorUnhandled.js';
|
|
5
|
-
export { ArticlePage } from './Article.js';
|
|
6
5
|
export { App, Document, AppErrorBoundary } from './Root.js';
|
package/src/themeCSS.ts
CHANGED
|
@@ -12,15 +12,25 @@ function variables(vars: MystThemeVariables) {
|
|
|
12
12
|
.map(([name, value]) => `--${name}: '${value}';`)
|
|
13
13
|
.join('\n ');
|
|
14
14
|
if (!css) return '';
|
|
15
|
-
return `:root {\n ${css}}`;
|
|
15
|
+
return `:root {\n ${css}\n}`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function themeCSS(options?: ThemeCssOptions) {
|
|
18
|
+
export function themeCSS(options?: ThemeCssOptions, css?: string): string {
|
|
19
19
|
const numbered_references = !!options?.numbered_references;
|
|
20
20
|
const citationCss = numbered_references
|
|
21
21
|
? { 'cite-group-open': '[', 'cite-group-close': ']' }
|
|
22
22
|
: {};
|
|
23
|
-
|
|
23
|
+
const vars = variables({ ...citationCss });
|
|
24
|
+
const themeCss = vars ? `/* MyST Theme Options */\n\n${vars}` : '';
|
|
25
|
+
const userCss = css
|
|
26
|
+
? `/* User Provided Stylesheet */\n\n${css}`
|
|
27
|
+
: '/* No Custom Stylesheet Provided */';
|
|
28
|
+
return (
|
|
29
|
+
[themeCss, userCss]
|
|
30
|
+
.map((s) => s.trim())
|
|
31
|
+
.join('\n\n')
|
|
32
|
+
.trim() + '\n'
|
|
33
|
+
);
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
export function cssResponse(css: string): Response {
|
package/src/utils.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { GenericNode, GenericParent } from 'myst-common';
|
|
|
2
2
|
import { extractPart } from 'myst-common';
|
|
3
3
|
import type { PageLoader } from '@myst-theme/common';
|
|
4
4
|
import type { SiteAction } from 'myst-config';
|
|
5
|
-
import { executableNodesFromBlock } from '@myst-theme/jupyter';
|
|
6
5
|
|
|
7
6
|
export function getDomainFromRequest(request: Request) {
|
|
8
7
|
const url = new URL(request.url);
|
|
@@ -66,7 +65,3 @@ export function getChildren(content?: GenericParent): GenericNode | GenericNode[
|
|
|
66
65
|
}
|
|
67
66
|
return content as GenericNode;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
export function isACodeCell(node: GenericParent) {
|
|
71
|
-
return !!executableNodesFromBlock(node);
|
|
72
|
-
}
|
package/src/pages/Article.tsx
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ReferencesProvider, useProjectManifest } from '@myst-theme/providers';
|
|
3
|
-
import {
|
|
4
|
-
Bibliography,
|
|
5
|
-
ContentBlocks,
|
|
6
|
-
FooterLinksBlock,
|
|
7
|
-
FrontmatterParts,
|
|
8
|
-
BackmatterParts,
|
|
9
|
-
} from '../components/index.js';
|
|
10
|
-
import type { PageLoader } from '@myst-theme/common';
|
|
11
|
-
import { copyNode, type GenericParent } from 'myst-common';
|
|
12
|
-
import { SourceFileKind } from 'myst-spec-ext';
|
|
13
|
-
import {
|
|
14
|
-
ExecuteScopeProvider,
|
|
15
|
-
BusyScopeProvider,
|
|
16
|
-
NotebookToolbar,
|
|
17
|
-
ConnectionStatusTray,
|
|
18
|
-
ErrorTray,
|
|
19
|
-
useComputeOptions,
|
|
20
|
-
} from '@myst-theme/jupyter';
|
|
21
|
-
import { FrontmatterBlock } from '@myst-theme/frontmatter';
|
|
22
|
-
import { combineDownloads, extractKnownParts } from '../utils.js';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated This component is not maintained, in favor of theme-specific ArticlePages
|
|
26
|
-
*
|
|
27
|
-
* As examples, MyST book and article themes define their own ArticlePage components.
|
|
28
|
-
*/
|
|
29
|
-
export const ArticlePage = React.memo(function ({
|
|
30
|
-
article,
|
|
31
|
-
hide_all_footer_links,
|
|
32
|
-
hideKeywords,
|
|
33
|
-
}: {
|
|
34
|
-
article: PageLoader;
|
|
35
|
-
hide_all_footer_links?: boolean;
|
|
36
|
-
hideKeywords?: boolean;
|
|
37
|
-
}) {
|
|
38
|
-
const manifest = useProjectManifest();
|
|
39
|
-
const compute = useComputeOptions();
|
|
40
|
-
|
|
41
|
-
const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.options ?? {};
|
|
42
|
-
const downloads = combineDownloads(manifest?.downloads, article.frontmatter);
|
|
43
|
-
const tree = copyNode(article.mdast);
|
|
44
|
-
const keywords = article.frontmatter?.keywords ?? [];
|
|
45
|
-
const parts = extractKnownParts(tree, article.frontmatter?.parts);
|
|
46
|
-
|
|
47
|
-
const { thebe } = manifest as any;
|
|
48
|
-
const { location } = article;
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ReferencesProvider
|
|
52
|
-
references={{ ...article.references, article: article.mdast }}
|
|
53
|
-
frontmatter={article.frontmatter}
|
|
54
|
-
>
|
|
55
|
-
<BusyScopeProvider>
|
|
56
|
-
<ExecuteScopeProvider enable={compute?.enabled ?? false} contents={article}>
|
|
57
|
-
{!hide_title_block && (
|
|
58
|
-
<FrontmatterBlock
|
|
59
|
-
kind={article.kind}
|
|
60
|
-
frontmatter={{ ...article.frontmatter, downloads }}
|
|
61
|
-
thebe={thebe}
|
|
62
|
-
location={location}
|
|
63
|
-
className="mb-8 pt-9"
|
|
64
|
-
/>
|
|
65
|
-
)}
|
|
66
|
-
{compute?.enabled &&
|
|
67
|
-
compute.features.notebookCompute &&
|
|
68
|
-
article.kind === SourceFileKind.Notebook && <NotebookToolbar showLaunch />}
|
|
69
|
-
{compute?.enabled && article.kind === SourceFileKind.Article && (
|
|
70
|
-
<ErrorTray pageSlug={article.slug} />
|
|
71
|
-
)}
|
|
72
|
-
<div id="skip-to-article" />
|
|
73
|
-
<FrontmatterParts parts={parts} keywords={keywords} hideKeywords={hideKeywords} />
|
|
74
|
-
<ContentBlocks pageKind={article.kind} mdast={tree as GenericParent} />
|
|
75
|
-
<BackmatterParts parts={parts} />
|
|
76
|
-
<Bibliography />
|
|
77
|
-
<ConnectionStatusTray />
|
|
78
|
-
{!hide_footer_links && !hide_all_footer_links && (
|
|
79
|
-
<FooterLinksBlock links={article.footer} />
|
|
80
|
-
)}
|
|
81
|
-
</ExecuteScopeProvider>
|
|
82
|
-
</BusyScopeProvider>
|
|
83
|
-
</ReferencesProvider>
|
|
84
|
-
);
|
|
85
|
-
});
|