/** * Thumbnail Helper * @description Get the thumbnail url from a post * @example * <%- thumbnail(post) %> */ hexo.extend.helper.register('thumbnail', function (post) { var url = post.thumbnail || ''; if (!url) { var imgPattern = /\/ig; var result = imgPattern.exec(post.content); if (result && result.length > 1) { url = result[1]; } } return url; });