[blog] finding hero image in ANY paragraph
This commit is contained in:
parent
22b9837f2c
commit
bc33d5953a
|
@ -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 {
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue