Skip to content

Commit

Permalink
fix: restore config, move types
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed May 10, 2024
1 parent a521d0e commit d2bb502
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 33 deletions.
4 changes: 3 additions & 1 deletion themes/article/app/components/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export function Article({
hideKeywords,
hideOutline,
hideTitle,
outlineMaxDepth,
}: {
article: PageLoader;
hideKeywords?: boolean;
hideOutline?: boolean;
hideTitle?: boolean;
outlineMaxDepth?: number;
}) {
const keywords = article.frontmatter?.keywords ?? [];
const tree = copyNode(article.mdast);
Expand All @@ -43,7 +45,7 @@ export function Article({
{!hideTitle && <FrontmatterBlock frontmatter={{ title, subtitle }} className="mb-5" />}
{!hideOutline && (
<div className="block my-10 lg:sticky lg:top-0 lg:z-10 lg:h-0 lg:pt-2 lg:my-0 lg:ml-10 lg:col-margin-right">
<DocumentOutline className="relative">
<DocumentOutline className="relative" maxdepth={outlineMaxDepth}>
<SupportingDocuments />
</DocumentOutline>
</div>
Expand Down
43 changes: 33 additions & 10 deletions themes/article/app/components/ArticlePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { PageLoader } from '@myst-theme/common';
import { FooterLinksBlock, ArticleHeader, Error404 } from '@myst-theme/site';
import {
FooterLinksBlock,
ArticleHeader,
Error404,
ErrorProjectNotFound,
ErrorDocumentNotFound,
} from '@myst-theme/site';
import { LaunchBinder, useComputeOptions } from '@myst-theme/jupyter';
import { ArrowLeftIcon } from '@heroicons/react/24/outline';
import { DocumentArrowDownIcon } from '@heroicons/react/24/outline';
Expand All @@ -15,17 +21,20 @@ import classNames from 'classnames';
import { BusyScopeProvider, ExecuteScopeProvider } from '@myst-theme/jupyter';
import { DownloadLinksArea } from './Downloads';
import { Article } from './Article';

export interface ArticleTemplateOptions {
hide_toc?: boolean;
hide_footer_links?: boolean;
numbered_references?: boolean;
}
import type { TemplateOptions } from '../types.js';

export function ArticlePage({ article }: { article: PageLoader }) {
const grid = useGridSystemProvider();
const { projects, hide_footer_links } = (useSiteManifest() ?? {}) as SiteManifest &
ArticleTemplateOptions;

const siteManifest = useSiteManifest() as SiteManifest;
const pageDesign: TemplateOptions = (article.frontmatter as any)?.options ?? {};
const siteDesign: TemplateOptions = siteManifest?.options ?? {};

const { projects } = siteManifest;
const { hide_footer_links, hide_outline, outline_maxdepth } = {
...siteDesign,
...pageDesign,
};
const Link = useLinkProvider();
const baseurl = useBaseurl();
const compute = useComputeOptions();
Expand Down Expand Up @@ -91,11 +100,25 @@ export function ArticlePage({ article }: { article: PageLoader }) {
</a>
</div>
)}
<Article article={article} hideKeywords={!isIndex} hideTitle={isIndex} />
<Article
article={article}
hideKeywords={!isIndex}
hideTitle={isIndex}
hideOutline={hide_outline}
outlineMaxDepth={outline_maxdepth}
/>
</main>
{!hide_footer_links && <FooterLinksBlock links={article.footer} />}
</ExecuteScopeProvider>
</BusyScopeProvider>
</ReferencesProvider>
);
}

export function ProjectPageCatchBoundary() {
return <ErrorProjectNotFound />;
}

export function ArticlePageCatchBoundary() {
return <ErrorDocumentNotFound />;
}
3 changes: 2 additions & 1 deletion themes/article/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
type LoaderFunction,
type V2_MetaFunction,
} from '@remix-run/node';
import { getMetaTagsForArticle, KatexCSS, ArticlePageCatchBoundary } from '@myst-theme/site';
import { getMetaTagsForArticle, KatexCSS } from '@myst-theme/site';
import { ArticlePageCatchBoundary } from '../components/ArticlePage';
import { getConfig, getPage } from '~/utils/loaders.server';
import { useLoaderData } from '@remix-run/react';
import type { SiteManifest } from 'myst-config';
Expand Down
8 changes: 2 additions & 6 deletions themes/article/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
ProjectPageCatchBoundary,
getMetaTagsForArticle,
responseNoArticle,
responseNoSite,
} from '@myst-theme/site';
import { getMetaTagsForArticle, responseNoArticle, responseNoSite } from '@myst-theme/site';
import Page from './$';
import { ArticlePageAndNavigation } from '../components/ArticlePageAndNavigation';
import { ProjectPageCatchBoundary } from '../components/ArticlePage';
import { getConfig, getPage } from '../utils/loaders.server';
import type { LoaderFunction, V2_MetaFunction } from '@remix-run/node';
import { redirect } from '@remix-run/node';
Expand Down
15 changes: 11 additions & 4 deletions themes/book/app/components/ArticlePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ReferencesProvider, useProjectManifest } from '@myst-theme/providers';
import { ReferencesProvider, useProjectManifest, useSiteManifest } from '@myst-theme/providers';
import {
Bibliography,
ContentBlocks,
Expand All @@ -11,6 +11,7 @@ import {
ErrorProjectNotFound,
extractKnownParts,
} from '@myst-theme/site';
import type { SiteManifest } from 'myst-config';
import type { PageLoader } from '@myst-theme/common';
import { copyNode, type GenericParent } from 'myst-common';
import { SourceFileKind } from 'myst-spec-ext';
Expand All @@ -24,6 +25,7 @@ import {
} from '@myst-theme/jupyter';
import { FrontmatterBlock } from '@myst-theme/frontmatter';
import type { SiteAction } from 'myst-config';
import type { TemplateOptions } from '../types.js';

/**
* Combines the project downloads and the export options
Expand Down Expand Up @@ -54,8 +56,13 @@ export const ArticlePage = React.memo(function ({
const manifest = useProjectManifest();
const compute = useComputeOptions();

const { hide_title_block, hide_footer_links, hide_outline, outline_maxdepth } =
(article.frontmatter as any)?.options ?? {};
const pageDesign: TemplateOptions = (article.frontmatter as any)?.options ?? {};
const siteDesign: TemplateOptions =
(useSiteManifest() as SiteManifest & TemplateOptions)?.options ?? {};
const { hide_toc, hide_title_block, hide_footer_links, hide_outline, outline_maxdepth } = {
...siteDesign,
...pageDesign,
};
const downloads = combineDownloads(manifest?.downloads, article.frontmatter);
const tree = copyNode(article.mdast);
const keywords = article.frontmatter?.keywords ?? [];
Expand All @@ -77,7 +84,7 @@ export const ArticlePage = React.memo(function ({
)}
{!hide_outline && (
<div className="block my-10 lg:sticky lg:top-0 lg:z-10 lg:h-0 lg:pt-2 lg:my-0 lg:ml-10 lg:col-margin-right">
<DocumentOutline className="relative" />
<DocumentOutline className="relative" maxdepth={outline_maxdepth} />
</div>
)}
{compute?.enabled &&
Expand Down
15 changes: 4 additions & 11 deletions themes/book/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import { MadeWithMyst } from '@myst-theme/icons';
import { ComputeOptionsProvider, ThebeLoaderAndServer } from '@myst-theme/jupyter';
import { ArticlePage, ArticlePageCatchBoundary } from '../components/ArticlePage.js';
import type { TemplateOptions } from '../types.js';
type ManifestProject = Required<SiteManifest>['projects'][0];

export const meta: V2_MetaFunction = ({ data, matches, location }) => {
Expand Down Expand Up @@ -104,22 +105,14 @@ export function ArticlePageAndNavigation({
);
}

export interface BookThemeTemplateOptions {
hide_toc?: boolean;
hide_outline?: boolean;
hide_footer_links?: boolean;
outline_maxdepth?: number;
numbered_references?: boolean;
}

export default function Page() {
const { container } = useOutlineHeight();
const data = useLoaderData() as { page: PageLoader; project: ManifestProject };

const baseurl = useBaseurl();
const pageDesign: BookThemeTemplateOptions = (data.page.frontmatter as any)?.options ?? {};
const siteDesign: BookThemeTemplateOptions =
(useSiteManifest() as SiteManifest & BookThemeTemplateOptions)?.options ?? {};
const pageDesign: TemplateOptions = (data.page.frontmatter as any)?.options ?? {};
const siteDesign: TemplateOptions =
(useSiteManifest() as SiteManifest & TemplateOptions)?.options ?? {};
const { hide_toc, hide_footer_links } = {
...siteDesign,
...pageDesign,
Expand Down

0 comments on commit d2bb502

Please sign in to comment.