From bc33d5953a283d3d83147023840ffb1e29489ed4 Mon Sep 17 00:00:00 2001 From: Avris Date: Mon, 12 Jul 2021 15:11:42 +0200 Subject: [PATCH] [blog] finding hero image in ANY paragraph --- server/routes/blog.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/routes/blog.js b/server/routes/blog.js index ba1f4f90..a3a4e115 100644 --- a/server/routes/blog.js +++ b/server/routes/blog.js @@ -41,7 +41,10 @@ router.get('/blog', handleErrorAsync(async (req, res) => { } try { - hero = content[2].match(/^!\[[^\]]*]\(([^)]+)\)$/)[1]; + const images = content.map(x => x.match(/^!\[[^\]]*]\(([^)]+)\)$/)).filter(x => !!x); + if (images.length) { + hero = images[0][1]; + } } catch { }