Skip to content

Commit 9c52a20

Browse files
committed
More forgiving CI build
1 parent 125a80a commit 9c52a20

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎content/_layouts/page.ejs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@
4141
if (imageInfo == null) {
4242
const sizeOf = js.require('image-size');
4343
const path = js.require('path');
44-
imageInfo = sizeOf(path.join('content', (imageRealPath != null ? imageRealPath : imageMeta)));
44+
try {
45+
imageInfo = sizeOf(path.join('content', (imageRealPath != null ? imageRealPath : imageMeta)));
46+
}
47+
catch (e) {
48+
// Image file not available (e.g. a new sample whose build
49+
// hasn't been published yet): fall back to the default
50+
// og:image instead of failing the whole site build
51+
console.warn('Missing og:image file for ' + imageMeta + ', using default image instead');
52+
imageMeta = defaultImage;
53+
imageInfo = sizeOf(path.join('content', defaultImage));
54+
}
4555
}
4656
%><meta property="og:image" content="<%- imageMeta %>" />
4757
<meta property="og:image:type" content="image/<%- imageInfo.type %>" />

0 commit comments

Comments
 (0)