From 9c7745fe2be38b88cb3c104213030541fa8c373f Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Fri, 14 Jun 2024 12:47:39 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20Upgrade=20v0.9.5,=20Footnotes,?= =?UTF-8?q?=20Localize=20ArticlePage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theme/app/components/ArticlePage.tsx | 94 + theme/app/routes/$project.($slug).tsx | 2 + theme/app/routes/_index.tsx | 3 +- theme/app/routes/overview.($slug).tsx | 3 +- theme/package-lock.json | 3133 +++++++++++++++++-------- theme/package.json | 14 +- 6 files changed, 2261 insertions(+), 988 deletions(-) create mode 100644 theme/app/components/ArticlePage.tsx diff --git a/theme/app/components/ArticlePage.tsx b/theme/app/components/ArticlePage.tsx new file mode 100644 index 0000000..b593ec1 --- /dev/null +++ b/theme/app/components/ArticlePage.tsx @@ -0,0 +1,94 @@ +import { ReferencesProvider, useProjectManifest } from '@myst-theme/providers'; +import { + Bibliography, + ContentBlocks, + FooterLinksBlock, + FrontmatterParts, + BackmatterParts, + Footnotes, + extractKnownParts, +} from '@myst-theme/site'; +import type { PageLoader } from '@myst-theme/common'; +import { copyNode, type GenericParent } from 'myst-common'; +import { SourceFileKind } from 'myst-spec-ext'; +import { + ExecuteScopeProvider, + BusyScopeProvider, + NotebookToolbar, + ConnectionStatusTray, + ErrorTray, + useComputeOptions, +} from '@myst-theme/jupyter'; +import { FrontmatterBlock } from '@myst-theme/frontmatter'; +import type { SiteAction } from 'myst-config'; + +/** + * Combines the project downloads and the export options + */ +function combineDownloads( + siteDownloads: SiteAction[] | undefined, + pageFrontmatter: PageLoader['frontmatter'] +) { + if (pageFrontmatter.downloads) { + return pageFrontmatter.downloads; + } + // No downloads on the page, combine the exports if they exist + if (siteDownloads) { + return [...(pageFrontmatter.exports ?? []), ...siteDownloads]; + } + return pageFrontmatter.exports; +} + +export function ArticlePage({ + article, + hide_all_footer_links, + hideKeywords, +}: { + article: PageLoader; + hide_all_footer_links?: boolean; + hideKeywords?: boolean; +}) { + const manifest = useProjectManifest(); + const compute = useComputeOptions(); + + const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.options ?? {}; + const downloads = combineDownloads(manifest?.downloads, article.frontmatter); + const tree = copyNode(article.mdast); + const keywords = article.frontmatter?.keywords ?? []; + const parts = extractKnownParts(tree); + + return ( + + + + {!hide_title_block && ( + + )} + {compute?.enabled && + compute.features.notebookCompute && + article.kind === SourceFileKind.Notebook && } + {compute?.enabled && article.kind === SourceFileKind.Article && ( + + )} +