Skip to content

Commit

Permalink
🎆 Optimize project thumbnail/banner and fallback correctly (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkoch authored Jun 14, 2024
1 parent a8a745b commit 6326cf5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-flies-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-cli': patch
---

Optimize project thumbnail/banner and fallback correctly
15 changes: 11 additions & 4 deletions packages/myst-cli/src/build/site/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,30 @@ export async function localToManifestProject(
path.join(projectPath, 'myst.yml'),
projFrontmatter,
session.publicPath(),
{ altOutputFolder: '/' },
{ altOutputFolder: '/', webp: true },
);
const thumbnail = await transformThumbnail(
session,
null,
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 || [],
Expand Down

0 comments on commit 6326cf5

Please sign in to comment.