diff --git a/_plugins/external-posts.rb b/_plugins/external-posts.rb index 41a6c4360657..1f66a8c853f8 100644 --- a/_plugins/external-posts.rb +++ b/_plugins/external-posts.rb @@ -62,6 +62,7 @@ def create_document(site, source_name, url, content) doc.data['description'] = content[:summary] doc.data['date'] = content[:published] doc.data['redirect'] = url + doc.content = content[:content] site.collections['posts'].docs << doc end @@ -90,8 +91,12 @@ def fetch_content_from_url(url) parsed_html = Nokogiri::HTML(html) title = parsed_html.at('head title')&.text.strip || '' - description = parsed_html.at('head meta[name="description"]')&.attr('content') || '' - body_content = parsed_html.at('body')&.inner_html || '' + description = parsed_html.at('head meta[name="description"]')&.attr('content') + description ||= parsed_html.at('head meta[name="og:description"]')&.attr('content') + description ||= parsed_html.at('head meta[property="og:description"]')&.attr('content') + + body_content = parsed_html.search('p').map { |e| e.text } + body_content = body_content.join() || '' { title: title,