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 || [],