From 9f596456c72b7b1000c140746c54eb6aad524429 Mon Sep 17 00:00:00 2001 From: Franklin Koch Date: Tue, 14 Nov 2023 11:11:33 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B1=20Respect=20`visibility:=20remove`?= =?UTF-8?q?=20on=20blocks=20(#259)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🧱 Respect visibility: remove on blocks * 🌆 Move logo into options * 👩‍🎨 Get design fields directly from options (#261) --------- Co-authored-by: Rowan Cockett --- .changeset/clean-ears-allow.md | 5 +++++ .changeset/little-trains-beam.md | 5 +++++ .changeset/stupid-socks-report.md | 7 ++++++ packages/common/src/utils.ts | 22 +++++++++++++++++-- .../site/src/components/ContentBlocks.tsx | 14 +++++++++--- .../site/src/components/Navigation/TopNav.tsx | 11 +++------- packages/site/src/pages/Article.tsx | 2 +- themes/article/app/routes/$.tsx | 2 +- themes/book/app/routes/$.tsx | 4 ++-- 9 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 .changeset/clean-ears-allow.md create mode 100644 .changeset/little-trains-beam.md create mode 100644 .changeset/stupid-socks-report.md diff --git a/.changeset/clean-ears-allow.md b/.changeset/clean-ears-allow.md new file mode 100644 index 000000000..8f2cd4c71 --- /dev/null +++ b/.changeset/clean-ears-allow.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/site': patch +--- + +Respect visibility: remove on blocks diff --git a/.changeset/little-trains-beam.md b/.changeset/little-trains-beam.md new file mode 100644 index 000000000..3a912b05d --- /dev/null +++ b/.changeset/little-trains-beam.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/common': patch +--- + +Move logo and logo_dark to options. diff --git a/.changeset/stupid-socks-report.md b/.changeset/stupid-socks-report.md new file mode 100644 index 000000000..3ca9fefae --- /dev/null +++ b/.changeset/stupid-socks-report.md @@ -0,0 +1,7 @@ +--- +'@myst-theme/article': patch +'@myst-theme/site': patch +'@myst-theme/book': patch +--- + +Get design fields from options diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index 3f881dedb..da006eef1 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -97,8 +97,26 @@ export function updateSiteManifestStaticLinksInplace( action.url = updateUrl(action.url); }); // TODO: this needs to be based on the template.yml in the future - if (data.logo) data.logo = updateUrl(data.logo); - if (data.logo_dark) data.logo_dark = updateUrl(data.logo_dark); + // We have moved logo/logo_dark to options in v1.1.28 + data.options ??= {}; + if (data.logo) { + data.options.logo = data.logo; + delete data.logo; + } + if (data.logo_dark) { + data.options.logo_dark = data.logo_dark; + delete data.logo_dark; + } + if (data.logoText) { + data.options.logo_text = data.logoText; + delete data.logoText; + } + if (data.logo_text) { + data.options.logo_text = data.logo_text; + delete data.logo_text; + } + if (data.options.logo) data.options.logo = updateUrl(data.options.logo); + if (data.options.logo_dark) data.options.logo_dark = updateUrl(data.options.logo_dark); // Update the thumbnails to point at the CDN data.projects?.forEach((project) => { if (project.banner) project.banner = updateUrl(project.banner); diff --git a/packages/site/src/components/ContentBlocks.tsx b/packages/site/src/components/ContentBlocks.tsx index 10fb28d87..22795a178 100644 --- a/packages/site/src/components/ContentBlocks.tsx +++ b/packages/site/src/components/ContentBlocks.tsx @@ -78,9 +78,17 @@ export function ContentBlocks({ const blocks = mdast.children as GenericParent[]; return ( <> - {blocks.map((node) => ( - - ))} + {blocks + .filter((node) => node.visibility !== 'remove') + .map((node) => ( + + ))} ); } diff --git a/packages/site/src/components/Navigation/TopNav.tsx b/packages/site/src/components/Navigation/TopNav.tsx index 939ca35f5..8e235ff03 100644 --- a/packages/site/src/components/Navigation/TopNav.tsx +++ b/packages/site/src/components/Navigation/TopNav.tsx @@ -244,8 +244,8 @@ function HomeLink({ export function TopNav() { const [open, setOpen] = useNavOpen(); const config = useSiteManifest(); - const { logo, logo_dark, logo_text, logoText, actions, title, nav } = - config ?? ({} as SiteManifest); + const { title, nav, actions } = config ?? {}; + const { logo, logo_dark, logo_text } = config?.options ?? {}; return (
- +
diff --git a/packages/site/src/pages/Article.tsx b/packages/site/src/pages/Article.tsx index d62ae9ed3..45aa96077 100644 --- a/packages/site/src/pages/Article.tsx +++ b/packages/site/src/pages/Article.tsx @@ -35,7 +35,7 @@ export const ArticlePage = React.memo(function ({ }) { const canCompute = useCanCompute(); - const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.design ?? {}; + const { hide_title_block, hide_footer_links } = (article.frontmatter as any)?.options ?? {}; const tree = copyNode(article.mdast); const keywords = article.frontmatter?.keywords ?? []; diff --git a/themes/article/app/routes/$.tsx b/themes/article/app/routes/$.tsx index 3e4cc9585..437c9f08e 100644 --- a/themes/article/app/routes/$.tsx +++ b/themes/article/app/routes/$.tsx @@ -248,7 +248,7 @@ export function ArticlePage({ article }: { article: PageLoader }) { export default function Page() { // const { container, outline } = useOutlineHeight(); const article = useLoaderData() as PageLoader; - const { hide_outline } = (article.frontmatter as any)?.design ?? {}; + const { hide_outline } = (article.frontmatter as any)?.options ?? {}; return ( diff --git a/themes/book/app/routes/$.tsx b/themes/book/app/routes/$.tsx index 2a455b4cc..ff237a0dd 100644 --- a/themes/book/app/routes/$.tsx +++ b/themes/book/app/routes/$.tsx @@ -96,9 +96,9 @@ export default function Page() { const { container, outline } = useOutlineHeight(); const top = useThemeTop(); const article = useLoaderData() as PageLoader; - const pageDesign: BookThemeTemplateOptions = (article.frontmatter as any)?.design ?? {}; + const pageDesign: BookThemeTemplateOptions = (article.frontmatter as any)?.options ?? {}; const siteDesign: BookThemeTemplateOptions = - (useSiteManifest() as SiteManifest & BookThemeTemplateOptions) ?? {}; + (useSiteManifest() as SiteManifest & BookThemeTemplateOptions)?.options ?? {}; const { hide_toc, hide_outline, hide_footer_links } = { ...siteDesign, ...pageDesign }; return (