-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 Upgrade v0.9.5, Footnotes, Localize ArticlePage
- Loading branch information
1 parent
f8603a9
commit 9c7745f
Showing
6 changed files
with
2,261 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<ReferencesProvider | ||
references={{ ...article.references, article: article.mdast }} | ||
frontmatter={article.frontmatter} | ||
> | ||
<BusyScopeProvider> | ||
<ExecuteScopeProvider enable={compute?.enabled ?? false} contents={article}> | ||
{!hide_title_block && ( | ||
<FrontmatterBlock | ||
kind={article.kind} | ||
frontmatter={{ ...article.frontmatter, downloads }} | ||
className="pt-5 mb-8" | ||
/> | ||
)} | ||
{compute?.enabled && | ||
compute.features.notebookCompute && | ||
article.kind === SourceFileKind.Notebook && <NotebookToolbar showLaunch />} | ||
{compute?.enabled && article.kind === SourceFileKind.Article && ( | ||
<ErrorTray pageSlug={article.slug} /> | ||
)} | ||
<div id="skip-to-article" /> | ||
<FrontmatterParts parts={parts} keywords={keywords} hideKeywords={hideKeywords} /> | ||
<ContentBlocks pageKind={article.kind} mdast={tree as GenericParent} /> | ||
<BackmatterParts parts={parts} /> | ||
<Footnotes /> | ||
<Bibliography /> | ||
<ConnectionStatusTray /> | ||
{!hide_footer_links && !hide_all_footer_links && ( | ||
<FooterLinksBlock links={article.footer} /> | ||
)} | ||
</ExecuteScopeProvider> | ||
</BusyScopeProvider> | ||
</ReferencesProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.