From 6326cf5965ec96461a3c4b80e3b5c53c1f0cdaa6 Mon Sep 17 00:00:00 2001 From: Franklin Koch Date: Fri, 14 Jun 2024 12:57:51 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=86=20Optimize=20project=20thumbnail/b?= =?UTF-8?q?anner=20and=20fallback=20correctly=20(#1316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/chilly-flies-appear.md | 5 +++++ packages/myst-cli/src/build/site/manifest.ts | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/chilly-flies-appear.md diff --git a/.changeset/chilly-flies-appear.md b/.changeset/chilly-flies-appear.md new file mode 100644 index 000000000..96ed68c5a --- /dev/null +++ b/.changeset/chilly-flies-appear.md @@ -0,0 +1,5 @@ +--- +'myst-cli': patch +--- + +Optimize project thumbnail/banner and fallback correctly diff --git a/packages/myst-cli/src/build/site/manifest.ts b/packages/myst-cli/src/build/site/manifest.ts index 312b25bdf..696909fce 100644 --- a/packages/myst-cli/src/build/site/manifest.ts +++ b/packages/myst-cli/src/build/site/manifest.ts @@ -178,7 +178,7 @@ export async function localToManifestProject( path.join(projectPath, 'myst.yml'), projFrontmatter, session.publicPath(), - { altOutputFolder: '/' }, + { altOutputFolder: '/', webp: true }, ); const thumbnail = await transformThumbnail( session, @@ -186,15 +186,22 @@ export async function localToManifestProject( path.join(projectPath, 'myst.yml'), projFrontmatter, session.publicPath(), - { altOutputFolder: '/' }, + { altOutputFolder: '/', webp: true }, ); return { ...projFrontmatter, // TODO: a null in the project frontmatter should not fall back to index page thumbnail: thumbnail?.url || projectFileInfo.thumbnail, - thumbnailOptimized: thumbnail?.urlOptimized || projectFileInfo.thumbnailOptimized || undefined, + thumbnailOptimized: + thumbnail?.urlOptimized || + // Do not fall back to optimized page thumbnail if unoptimized project thumbnail exists + (thumbnail?.url ? undefined : projectFileInfo.thumbnailOptimized) || + undefined, banner: banner?.url || projectFileInfo.banner, - bannerOptimized: banner?.urlOptimized || projectFileInfo.bannerOptimized || undefined, + bannerOptimized: + banner?.urlOptimized || + (banner?.url ? undefined : projectFileInfo.bannerOptimized) || + undefined, exports, downloads, bibliography: projFrontmatter.bibliography || [],