@myst-theme/site 0.9.3 → 0.9.5

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.9.3",
3
+ "version": "0.9.5",
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.9.3",
21
- "@myst-theme/diagrams": "^0.9.3",
22
- "@myst-theme/frontmatter": "^0.9.3",
23
- "@myst-theme/jupyter": "^0.9.3",
24
- "@myst-theme/providers": "^0.9.3",
20
+ "@myst-theme/common": "^0.9.5",
21
+ "@myst-theme/diagrams": "^0.9.5",
22
+ "@myst-theme/frontmatter": "^0.9.5",
23
+ "@myst-theme/jupyter": "^0.9.5",
24
+ "@myst-theme/providers": "^0.9.5",
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.4.1",
29
- "myst-config": "^1.4.1",
30
- "myst-demo": "^0.9.3",
31
- "myst-spec-ext": "^1.4.1",
32
- "myst-to-react": "^0.9.3",
28
+ "myst-common": "^1.4.4",
29
+ "myst-config": "^1.4.4",
30
+ "myst-demo": "^0.9.5",
31
+ "myst-spec-ext": "^1.4.4",
32
+ "myst-to-react": "^0.9.5",
33
33
  "nbtx": "^0.2.3",
34
34
  "node-cache": "^5.1.2",
35
35
  "node-fetch": "^2.6.11",
@@ -1,6 +1,5 @@
1
- import type { GenericParent } from 'myst-common';
2
- import { ContentBlocks } from './ContentBlocks.js';
3
- import { HashLink } from 'myst-to-react';
1
+ import type { GenericNode, GenericParent } from 'myst-common';
2
+ import { HashLink, MyST } from 'myst-to-react';
4
3
  import type { KnownParts } from '../utils.js';
5
4
 
6
5
  export function BackmatterParts({ parts }: { parts: KnownParts }) {
@@ -16,6 +15,21 @@ export function BackmatterParts({ parts }: { parts: KnownParts }) {
16
15
  );
17
16
  }
18
17
 
18
+ /**
19
+ * This returns the contents of a part that we want to render (not the root or block, which are already wrapped)
20
+ * This also fixes a bug that the key is not defined on a block.
21
+ */
22
+ function getChildren(content?: GenericParent): GenericNode | GenericNode[] {
23
+ if (
24
+ content?.type === 'root' &&
25
+ content.children?.length === 1 &&
26
+ content.children[0].type === 'block'
27
+ ) {
28
+ return content.children[0].children as GenericNode[];
29
+ }
30
+ return content as GenericNode;
31
+ }
32
+
19
33
  export function Backmatter({
20
34
  title,
21
35
  id,
@@ -35,11 +49,8 @@ export function Backmatter({
35
49
  {title}
36
50
  <HashLink id={id} title={`Link to ${title}`} hover className="ml-2" />
37
51
  </h2>
38
- <div className="grow">
39
- <ContentBlocks
40
- mdast={content}
41
- className="opacity-90 group-hover/backmatter:opacity-100 col-screen"
42
- />
52
+ <div className="grow opacity-90 group-hover/backmatter:opacity-100 col-screen">
53
+ <MyST ast={getChildren(content)} />
43
54
  </div>
44
55
  </div>
45
56
  );
@@ -0,0 +1,54 @@
1
+ import { useGridSystemProvider, useReferences } from '@myst-theme/providers';
2
+ import classNames from 'classnames';
3
+ import type { GenericNode } from 'myst-common';
4
+ import type { FootnoteDefinition, FootnoteReference } from 'myst-spec-ext';
5
+ import { HashLink, MyST } from 'myst-to-react';
6
+ import { selectAll } from 'unist-util-select';
7
+
8
+ export function Footnotes() {
9
+ const references = useReferences();
10
+ const grid = useGridSystemProvider();
11
+ const defs = selectAll('footnoteDefinition', references?.article) as FootnoteDefinition[];
12
+ const refs = selectAll('footnoteReference', references?.article) as FootnoteReference[];
13
+ if (defs.length === 0) return null;
14
+ return (
15
+ <section id="footnotes" className={classNames(grid, 'subgrid-gap col-screen')}>
16
+ <div>
17
+ <header className="text-lg font-semibold text-stone-900 dark:text-white group">
18
+ Footnotes
19
+ <HashLink id="footnotes" title="Link to Footnotes" hover className="ml-2" />
20
+ </header>
21
+ </div>
22
+ <div className="pl-3 mb-8 text-xs text-stone-500 dark:text-stone-300">
23
+ <ol>
24
+ {defs.map((fn) => {
25
+ return (
26
+ <li key={(fn as GenericNode).key} id={`fn-${fn.identifier}`} className="group">
27
+ <div className="flex flex-row">
28
+ <div className="break-words grow">
29
+ <MyST ast={fn.children} />
30
+ </div>
31
+ <div className="flex flex-col grow-0">
32
+ {refs
33
+ .filter((ref) => ref.identifier === fn.identifier)
34
+ .map((ref) => (
35
+ <HashLink
36
+ key={(ref as GenericNode).key}
37
+ id={`fnref-${(ref as GenericNode).key}`}
38
+ title="Link to Content"
39
+ hover
40
+ className="p-1"
41
+ children="↩"
42
+ scrollBehavior="instant"
43
+ />
44
+ ))}
45
+ </div>
46
+ </div>
47
+ </li>
48
+ );
49
+ })}
50
+ </ol>
51
+ </div>
52
+ </section>
53
+ );
54
+ }
@@ -3,6 +3,7 @@ export { DocumentOutline, useOutlineHeight, SupportingDocuments } from './Docume
3
3
  export { FooterLinksBlock } from './FooterLinksBlock.js';
4
4
  export { ContentReload } from './ContentReload.js';
5
5
  export { Bibliography } from './Bibliography.js';
6
+ export { Footnotes } from './Footnotes.js';
6
7
  export { ArticleHeader } from './Headers.js';
7
8
  export { FrontmatterParts, Abstract, Keywords } from './Abstract.js';
8
9
  export { BackmatterParts, Backmatter } from './Backmatter.js';
@@ -41,6 +41,11 @@ function combineDownloads(
41
41
  return pageFrontmatter.exports;
42
42
  }
43
43
 
44
+ /**
45
+ * @deprecated This component is not maintained, in favor of theme-specific ArticlePages
46
+ *
47
+ * As examples, MyST book and article themes define their own ArticlePage components.
48
+ */
44
49
  export const ArticlePage = React.memo(function ({
45
50
  article,
46
51
  hide_all_footer_links,