From d2709ed7cfe4abe7444bbe8e0049cccbcbe22dde Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 27 Nov 2023 14:16:29 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=BDaccept=20project=20not=20site?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/jupyter/src/providers.tsx | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/jupyter/src/providers.tsx b/packages/jupyter/src/providers.tsx index 883adc616..8e7a0e00c 100644 --- a/packages/jupyter/src/providers.tsx +++ b/packages/jupyter/src/providers.tsx @@ -7,20 +7,17 @@ import type { SiteManifest } from 'myst-config'; import type { RepoProviderSpec } from 'thebe-core'; function makeThebeOptions( - siteManifest: SiteManifest | undefined, + project: Required['projects'][0], optionsOverrideFn = (opts?: ExtendedCoreOptions) => opts, ): { options?: ExtendedCoreOptions; githubBadgeUrl?: string; binderBadgeUrl?: string; } { - if (!siteManifest) return {}; - // TODO there may be multiple projects? - // useProjectManifest? - const mainProject = siteManifest?.projects?.[0]; - const thebeFrontmatter = mainProject?.thebe; - const githubBadgeUrl = mainProject?.github; - const binderBadgeUrl = mainProject?.binder; + if (!project) return {}; + const thebeFrontmatter = project?.thebe; + const githubBadgeUrl = project?.github; + const binderBadgeUrl = project?.binder; const optionsFromFrontmatter = thebeFrontmatterToOptions( thebeFrontmatter, githubBadgeUrl, @@ -45,21 +42,21 @@ type ThebeOptionsContextType = { const ThebeOptionsContext = React.createContext(undefined); export function ConfiguredThebeServerProvider({ - siteManifest, + project, optionOverrideFn, customRepoProviders, children, }: React.PropsWithChildren<{ - siteManifest?: SiteManifest; + project?: Required['project'][0]; optionOverrideFn?: (opts?: ExtendedCoreOptions) => ExtendedCoreOptions | undefined; customRepoProviders?: RepoProviderSpec[]; }>) { const thebe = React.useMemo( - () => makeThebeOptions(siteManifest, optionOverrideFn), - [siteManifest, optionOverrideFn], + () => makeThebeOptions(project, optionOverrideFn), + [project, optionOverrideFn], ); - if (!siteManifest) return <>{children}; + if (!project) return <>{children}; return (