@myst-theme/site 0.5.6 → 0.5.8

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,7 @@
1
1
  {
2
2
  "name": "@myst-theme/site",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
+ "type": "module",
4
5
  "main": "./src/index.ts",
5
6
  "types": "./src/index.ts",
6
7
  "files": [
@@ -16,22 +17,22 @@
16
17
  "dependencies": {
17
18
  "@headlessui/react": "^1.7.15",
18
19
  "@heroicons/react": "^2.0.18",
19
- "@myst-theme/diagrams": "^0.5.6",
20
- "@myst-theme/frontmatter": "^0.5.6",
21
- "@myst-theme/jupyter": "^0.5.6",
22
- "@myst-theme/common": "^0.5.6",
23
- "@myst-theme/providers": "^0.5.6",
20
+ "@myst-theme/diagrams": "^0.5.8",
21
+ "@myst-theme/frontmatter": "^0.5.8",
22
+ "@myst-theme/jupyter": "^0.5.8",
23
+ "@myst-theme/common": "^0.5.8",
24
+ "@myst-theme/providers": "^0.5.8",
24
25
  "classnames": "^2.3.2",
25
26
  "lodash.throttle": "^4.1.1",
26
- "myst-common": "^1.1.4",
27
- "myst-spec-ext": "^1.1.4",
28
- "myst-config": "^1.1.4",
29
- "myst-demo": "^0.5.6",
30
- "myst-to-react": "^0.5.6",
27
+ "myst-common": "^1.1.8",
28
+ "myst-spec-ext": "^1.1.8",
29
+ "myst-config": "^1.1.8",
30
+ "myst-demo": "^0.5.8",
31
+ "myst-to-react": "^0.5.8",
31
32
  "nbtx": "^0.2.3",
32
33
  "node-cache": "^5.1.2",
33
34
  "node-fetch": "^2.6.11",
34
- "thebe-react": "^0.3.2",
35
+ "thebe-react": "^0.3.5",
35
36
  "unist-util-select": "^4.0.1"
36
37
  },
37
38
  "peerDependencies": {
@@ -1,12 +1,16 @@
1
1
  import type { GenericParent } from 'myst-common';
2
- import { ContentBlocks } from './ContentBlocks';
2
+ import { ContentBlocks } from './ContentBlocks.js';
3
3
  import classNames from 'classnames';
4
+ import { HashLink } from 'myst-to-react';
4
5
 
5
6
  export function Abstract({ content }: { content: GenericParent }) {
6
- if (!content) return null;
7
+ if (!content) return <div className="hidden" aria-label="this article has no abstract" />;
7
8
  return (
8
9
  <>
9
- <span className="mb-3 font-semibold">Abstract</span>
10
+ <h2 id="abstract" className="mb-3 text-base font-semibold group">
11
+ Abstract
12
+ <HashLink id="abstract" title="Link to Abstract" hover className="ml-2" />
13
+ </h2>
10
14
  <div className="px-6 py-1 mb-3 rounded-sm bg-slate-50 dark:bg-slate-800">
11
15
  <ContentBlocks mdast={content} className="col-body" />
12
16
  </div>
@@ -21,9 +25,10 @@ export function Keywords({
21
25
  keywords?: string[];
22
26
  hideKeywords?: boolean;
23
27
  }) {
24
- if (hideKeywords || !keywords || keywords.length === 0) return null;
28
+ if (hideKeywords || !keywords || keywords.length === 0)
29
+ return <div className="hidden" aria-label="this article has no keywords" />;
25
30
  return (
26
- <div className="mb-10">
31
+ <div className="mb-10 group">
27
32
  <span className="mr-2 font-semibold">Keywords:</span>
28
33
  {keywords.map((k, i) => (
29
34
  <span
@@ -35,6 +40,7 @@ export function Keywords({
35
40
  {k}
36
41
  </span>
37
42
  ))}
43
+ <HashLink id="keywords" title="Link to Keywords" hover className="ml-2" />
38
44
  </div>
39
45
  );
40
46
  }
@@ -8,7 +8,7 @@ import { useNavigation } from '@remix-run/react';
8
8
  import classNames from 'classnames';
9
9
  import throttle from 'lodash.throttle';
10
10
  import React, { useCallback, useEffect, useRef, useState } from 'react';
11
- import DocumentChartBarIcon from '@heroicons/react/24/outline/DocumentChartBarIcon';
11
+ import { DocumentChartBarIcon } from '@heroicons/react/24/outline';
12
12
 
13
13
  const SELECTOR = [1, 2, 3, 4].map((n) => `main h${n}`).join(', ');
14
14
  const HIGHLIGHT_CLASS = 'highlight';
@@ -1,6 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import ArrowLeftIcon from '@heroicons/react/24/outline/ArrowLeftIcon';
3
- import ArrowRightIcon from '@heroicons/react/24/outline/ArrowRightIcon';
2
+ import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/24/outline';
4
3
  import type { FooterLinks, NavigationLink } from '@myst-theme/common';
5
4
  import { useLinkProvider, useBaseurl, withBaseurl } from '@myst-theme/providers';
6
5
 
@@ -8,7 +8,7 @@ import {
8
8
  import { useGridSystemProvider } from '@myst-theme/providers';
9
9
  import classNames from 'classnames';
10
10
  import type { PageFrontmatter } from 'myst-frontmatter';
11
- import { ThemeButton } from './Navigation';
11
+ import { ThemeButton } from './Navigation/index.js';
12
12
 
13
13
  export function ArticleHeader({
14
14
  frontmatter,
@@ -1,5 +1,5 @@
1
1
  import { useNavOpen, useThemeTop } from '@myst-theme/providers';
2
- import { TableOfContents } from './TableOfContents';
2
+ import { TableOfContents } from './TableOfContents.js';
3
3
 
4
4
  export function Navigation({
5
5
  children,
@@ -16,10 +16,13 @@ export function Navigation({
16
16
  }) {
17
17
  const [open, setOpen] = useNavOpen();
18
18
  const top = useThemeTop();
19
- if (hide_toc) return <>{children}</>;
19
+ if (children)
20
+ console.warn(
21
+ `Including children in Navigation can break keyboard accessbility and is deprecated. Please move children to the page component.`,
22
+ );
23
+ if (hide_toc) return children ? null : <>{children}</>;
20
24
  return (
21
25
  <>
22
- {children}
23
26
  {open && (
24
27
  <div
25
28
  className="fixed inset-0 z-30 bg-black opacity-50"
@@ -28,6 +31,7 @@ export function Navigation({
28
31
  ></div>
29
32
  )}
30
33
  <TableOfContents tocRef={tocRef} projectSlug={projectSlug} footer={footer} />
34
+ {children}
31
35
  </>
32
36
  );
33
37
  }
@@ -168,8 +168,7 @@ export const TableOfContents = ({
168
168
  'fixed',
169
169
  `xl:${grid}`, // for example, xl:article-grid
170
170
  'grid-gap xl:w-screen xl:pointer-events-none overflow-auto max-xl:min-w-[300px]',
171
- { hidden: !open },
172
- { 'z-30': open },
171
+ { hidden: !open, 'z-30': open, 'z-10': !open },
173
172
  )}
174
173
  style={{ top }}
175
174
  >
@@ -1,6 +1,6 @@
1
1
  import { useTheme } from '@myst-theme/providers';
2
- import MoonIcon from '@heroicons/react/24/solid/MoonIcon';
3
- import SunIcon from '@heroicons/react/24/outline/SunIcon';
2
+ import { MoonIcon } from '@heroicons/react/24/solid';
3
+ import { SunIcon } from '@heroicons/react/24/outline';
4
4
  import classNames from 'classnames';
5
5
 
6
6
  export function ThemeButton({ className = 'w-8 h-8 mx-3' }: { className?: string }) {
@@ -2,11 +2,13 @@ import { NavLink } from '@remix-run/react';
2
2
  import { Fragment } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { Menu, Transition } from '@headlessui/react';
5
- import EllipsisVerticalIcon from '@heroicons/react/24/solid/EllipsisVerticalIcon';
6
- import MenuIcon from '@heroicons/react/24/solid/Bars3Icon';
7
- import ChevronDownIcon from '@heroicons/react/24/solid/ChevronDownIcon';
5
+ import {
6
+ EllipsisVerticalIcon,
7
+ ChevronDownIcon,
8
+ Bars3Icon as MenuIcon,
9
+ } from '@heroicons/react/24/solid';
8
10
  import type { SiteManifest, SiteNavItem } from 'myst-config';
9
- import { ThemeButton } from './ThemeButton';
11
+ import { ThemeButton } from './ThemeButton.js';
10
12
  import {
11
13
  useBaseurl,
12
14
  useLinkProvider,
@@ -14,7 +16,7 @@ import {
14
16
  useSiteManifest,
15
17
  withBaseurl,
16
18
  } from '@myst-theme/providers';
17
- import { LoadingBar } from './Loading';
19
+ import { LoadingBar } from './Loading.js';
18
20
 
19
21
  export const DEFAULT_NAV_HEIGHT = 60;
20
22
 
@@ -1,5 +1,5 @@
1
- export { ThemeButton } from './ThemeButton';
2
- export { TopNav, DEFAULT_NAV_HEIGHT } from './TopNav';
3
- export { Navigation } from './Navigation';
4
- export { TableOfContents, InlineTableOfContents, useTocHeight } from './TableOfContents';
5
- export { LoadingBar } from './Loading';
1
+ export { ThemeButton } from './ThemeButton.js';
2
+ export { TopNav, DEFAULT_NAV_HEIGHT } from './TopNav.js';
3
+ export { Navigation } from './Navigation.js';
4
+ export { TableOfContents, InlineTableOfContents, useTocHeight } from './TableOfContents.js';
5
+ export { LoadingBar } from './Loading.js';
@@ -0,0 +1,50 @@
1
+ import { useCallback } from 'react';
2
+
3
+ function makeSkipClickHandler(hash: string) {
4
+ return (e: React.UIEvent<HTMLElement, Event>) => {
5
+ e.preventDefault();
6
+ const el = document.querySelector(`#${hash}`);
7
+ if (!el) return;
8
+ (el.nextSibling as HTMLElement).focus();
9
+ history.replaceState(undefined, '', `#${hash}`);
10
+ };
11
+ }
12
+
13
+ export function SkipToArticle({
14
+ frontmatter = true,
15
+ article = true,
16
+ }: {
17
+ frontmatter?: boolean;
18
+ article?: boolean;
19
+ }) {
20
+ const fm = 'skip-to-frontmatter';
21
+ const art = 'skip-to-article';
22
+
23
+ const frontmatterHandler = useCallback(() => makeSkipClickHandler(fm), [frontmatter]);
24
+ const articleHandler = useCallback(() => makeSkipClickHandler(art), [article]);
25
+ return (
26
+ <div
27
+ className="fixed top-1 left-1 h-[0px] w-[0px] focus-within:z-40 focus-within:h-auto focus-within:w-auto bg-white overflow-hidden focus-within:p-2 focus-within:ring-1"
28
+ aria-label="skip to content options"
29
+ >
30
+ {frontmatter && (
31
+ <a
32
+ href={`#${fm}`}
33
+ className="block px-2 py-1 text-black underline"
34
+ onClick={frontmatterHandler}
35
+ >
36
+ Skip to article frontmatter
37
+ </a>
38
+ )}
39
+ {article && (
40
+ <a
41
+ href={`#${art}`}
42
+ className="block px-2 py-1 text-black underline"
43
+ onClick={articleHandler}
44
+ >
45
+ Skip to article content
46
+ </a>
47
+ )}
48
+ </div>
49
+ );
50
+ }
@@ -1,10 +1,11 @@
1
- export { ContentBlocks } from './ContentBlocks';
2
- export { DocumentOutline, useOutlineHeight, SupportingDocuments } from './DocumentOutline';
3
- export { FooterLinksBlock } from './FooterLinksBlock';
4
- export { ContentReload } from './ContentReload';
5
- export { Bibliography } from './Bibliography';
6
- export { ArticleHeader } from './Headers';
7
- export { Abstract, Keywords } from './Abstract';
8
- export { ExternalOrInternalLink } from './ExternalOrInternalLink';
9
- export * from './Navigation';
10
- export { renderers } from './renderers';
1
+ export { ContentBlocks } from './ContentBlocks.js';
2
+ export { DocumentOutline, useOutlineHeight, SupportingDocuments } from './DocumentOutline.js';
3
+ export { FooterLinksBlock } from './FooterLinksBlock.js';
4
+ export { ContentReload } from './ContentReload.js';
5
+ export { Bibliography } from './Bibliography.js';
6
+ export { ArticleHeader } from './Headers.js';
7
+ export { Abstract, Keywords } from './Abstract.js';
8
+ export { ExternalOrInternalLink } from './ExternalOrInternalLink.js';
9
+ export * from './Navigation/index.js';
10
+ export { renderers } from './renderers.js';
11
+ export * from './SkipToArticle.js';
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './utils';
2
- export * from './loaders';
3
- export * from './components';
4
- export * from './pages';
5
- export * from './seo';
1
+ export * from './utils.js';
2
+ export * from './loaders/index.js';
3
+ export * from './components/index.js';
4
+ export * from './pages/index.js';
5
+ export * from './seo/index.js';
@@ -1,3 +1,3 @@
1
- export * from './errors.server';
2
- export * from './links';
3
- export * from './theme.server';
1
+ export * from './errors.server.js';
2
+ export * from './links.js';
3
+ export * from './theme.server.js';
@@ -1,18 +1,22 @@
1
1
  import React from 'react';
2
2
  import { ReferencesProvider } from '@myst-theme/providers';
3
- import { Abstract, Bibliography, ContentBlocks, FooterLinksBlock, Keywords } from '../components';
4
- import { ErrorDocumentNotFound } from './ErrorDocumentNotFound';
5
- import { ErrorProjectNotFound } from './ErrorProjectNotFound';
3
+ import {
4
+ Abstract,
5
+ Bibliography,
6
+ ContentBlocks,
7
+ FooterLinksBlock,
8
+ Keywords,
9
+ } from '../components/index.js';
10
+ import { ErrorDocumentNotFound } from './ErrorDocumentNotFound.js';
11
+ import { ErrorProjectNotFound } from './ErrorProjectNotFound.js';
6
12
  import type { PageLoader } from '@myst-theme/common';
7
13
  import { copyNode, extractPart, type GenericParent } from 'myst-common';
8
14
  import { SourceFileKind } from 'myst-spec-ext';
9
15
  import {
10
- useComputeOptions,
11
16
  ExecuteScopeProvider,
12
17
  BusyScopeProvider,
13
18
  NotebookToolbar,
14
19
  ConnectionStatusTray,
15
- BinderBadge,
16
20
  useCanCompute,
17
21
  ErrorTray,
18
22
  } from '@myst-theme/jupyter';
@@ -30,14 +34,11 @@ export const ArticlePage = React.memo(function ({
30
34
  hideKeywords?: boolean;
31
35
  }) {
32
36
  const canCompute = useCanCompute(article);
33
- const { binderBadgeUrl } = useComputeOptions();
34
37
  const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.design ?? {};
35
38
 
36
39
  const tree = copyNode(article.mdast);
37
40
  const keywords = article.frontmatter?.keywords ?? [];
38
41
  const abstract = showAbstract ? extractPart(tree, 'abstract') : undefined;
39
- // take binder url from article frontmatter or fallback to project
40
- const binderUrl = article.frontmatter.binder ?? binderBadgeUrl;
41
42
 
42
43
  return (
43
44
  <ReferencesProvider
@@ -53,13 +54,9 @@ export const ArticlePage = React.memo(function ({
53
54
  className="pt-5 mb-8"
54
55
  />
55
56
  )}
56
- {binderUrl && !canCompute && (
57
- <div className="flex justify-end">
58
- <BinderBadge binder={binderUrl} />
59
- </div>
60
- )}
61
57
  {canCompute && article.kind === SourceFileKind.Notebook && <NotebookToolbar showLaunch />}
62
58
  <ErrorTray pageSlug={article.slug} />
59
+ <div id="skip-to-article" />
63
60
  <Abstract content={abstract as GenericParent} />
64
61
  {abstract && <Keywords keywords={keywords} hideKeywords={hideKeywords} />}
65
62
  <ContentBlocks pageKind={article.kind} mdast={tree as GenericParent} />
@@ -12,12 +12,13 @@ import {
12
12
  Link,
13
13
  NavLink,
14
14
  } from '@remix-run/react';
15
- import { DEFAULT_NAV_HEIGHT, renderers } from '../components';
16
- import { Analytics } from '../seo';
17
- import { Error404 } from './Error404';
15
+ import { DEFAULT_NAV_HEIGHT, renderers } from '../components/index.js';
16
+ import { Analytics } from '../seo/index.js';
17
+ import { Error404 } from './Error404.js';
18
18
  import classNames from 'classnames';
19
19
  import { ConfiguredThebeServerProvider } from '@myst-theme/jupyter';
20
20
  import { ThebeBundleLoaderProvider } from 'thebe-react';
21
+ import type { BinderOptions, RepoProviderSpec } from 'thebe-core';
21
22
 
22
23
  export function Document({
23
24
  children,
@@ -27,6 +28,7 @@ export function Document({
27
28
  title,
28
29
  staticBuild,
29
30
  baseurl,
31
+ loadThebeLite,
30
32
  top = DEFAULT_NAV_HEIGHT,
31
33
  }: {
32
34
  children: React.ReactNode;
@@ -36,6 +38,7 @@ export function Document({
36
38
  title?: string;
37
39
  staticBuild?: boolean;
38
40
  baseurl?: string;
41
+ loadThebeLite?: boolean;
39
42
  top?: number;
40
43
  }) {
41
44
  const links = staticBuild
@@ -63,9 +66,11 @@ export function Document({
63
66
  <body className="m-0 transition-colors duration-500 bg-white dark:bg-stone-900">
64
67
  <ThemeProvider theme={theme} renderers={renderers} {...links} top={top}>
65
68
  <BaseUrlProvider baseurl={baseurl}>
66
- <ThebeBundleLoaderProvider loadThebeLite publicPath={baseurl}>
69
+ <ThebeBundleLoaderProvider loadThebeLite={loadThebeLite} publicPath={baseurl}>
67
70
  <SiteProvider config={config}>
68
- <ConfiguredThebeServerProvider>{children}</ConfiguredThebeServerProvider>
71
+ <ConfiguredThebeServerProvider siteManifest={config}>
72
+ {children}
73
+ </ConfiguredThebeServerProvider>
69
74
  </SiteProvider>
70
75
  </ThebeBundleLoaderProvider>
71
76
  </BaseUrlProvider>
@@ -1,5 +1,5 @@
1
- export { ErrorProjectNotFound } from './ErrorProjectNotFound';
2
- export { ErrorDocumentNotFound } from './ErrorDocumentNotFound';
3
- export { Error404 } from './Error404';
4
- export { ArticlePage, ArticlePageCatchBoundary, ProjectPageCatchBoundary } from './Article';
5
- export { App, Document, AppCatchBoundary } from './Root';
1
+ export { ErrorProjectNotFound } from './ErrorProjectNotFound.js';
2
+ export { ErrorDocumentNotFound } from './ErrorDocumentNotFound.js';
3
+ export { Error404 } from './Error404.js';
4
+ export { ArticlePage, ArticlePageCatchBoundary, ProjectPageCatchBoundary } from './Article.js';
5
+ export { App, Document, AppCatchBoundary } from './Root.js';
package/src/seo/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './analytics';
2
- export * from './meta';
3
- export * from './sitemap';
4
- export * from './robots';
1
+ export * from './analytics.js';
2
+ export * from './meta.js';
3
+ export * from './sitemap.js';
4
+ export * from './robots.js';