diff --git a/Gemfile b/Gemfile index 121f076ff38c..7d2559db02e3 100644 --- a/Gemfile +++ b/Gemfile @@ -18,3 +18,7 @@ group :jekyll_plugins do gem 'htmlcompressor' gem 'htmlbeautifier' end +group :other_plugins do + gem 'httparty' + gem 'feedjira' +end diff --git a/_config.yml b/_config.yml index 3e4e49f29242..bdafe4ee7b0c 100644 --- a/_config.yml +++ b/_config.yml @@ -96,6 +96,13 @@ pagination: disqus_shortname: al-folio # put your disqus shortname # https://help.disqus.com/en/articles/1717111-what-s-a-shortname +# External sources. +# If you have blog posts published on medium.com or other exteranl sources, +# you can display them in your blog by adding a link to the RSS feed. +external_sources: + - name: medium.com + rss_url: https://medium.com/@al-folio/feed + # ----------------------------------------------------------------------------- # Collections # ----------------------------------------------------------------------------- @@ -161,9 +168,9 @@ plugins: # Sitemap settings defaults: - scope: - path: "assets/**/*.*" + path: "assets/**/*.*" values: - sitemap: false + sitemap: false # Extras github: [metadata] @@ -174,10 +181,12 @@ github: [metadata] # HTML remove comments () remove_HTML_comments: false -# HTML beautifier (_plugins/beautify.rb) / https://github.com/threedaymonk/htmlbeautifier +# HTML beautifier (_plugins/beautify.rb). +# Source: https://github.com/threedaymonk/htmlbeautifier beautify: false # This function has conflict with the code snippets, they can be displayed incorrectly -# HTML minify (_plugins/minify.rb) Thanks to: https://www.ffbit.com/blog/2021/03/17/html-minification-in-jekyll.html +# HTML minify (_plugins/minify.rb). +# Source: https://www.ffbit.com/blog/2021/03/17/html-minification-in-jekyll.html minify: false # CSS/SASS minify @@ -189,7 +198,7 @@ sass: # ----------------------------------------------------------------------------- jekyll-archives: - enabled: [year, tags, categories] # enables year, tag and category archives (remove if you need to disable one of them). + enabled: [year, tags, categories] # enables year, tag and category archives (remove if you need to disable one of them). layouts: year: archive-year tag: archive-tag diff --git a/_plugins/external-posts.rb b/_plugins/external-posts.rb new file mode 100644 index 000000000000..953d0602160d --- /dev/null +++ b/_plugins/external-posts.rb @@ -0,0 +1,34 @@ +require 'feedjira' +require 'httparty' +require 'jekyll' + +module ExternalPosts + class ExternalPostsGenerator < Jekyll::Generator + safe true + priority :high + + def generate(site) + site.config['external_sources'].each do |src| + p "Fetching external posts from #{src['name']}:" + xml = HTTParty.get(src['rss_url']).body + feed = Feedjira.parse(xml) + feed.entries.each do |e| + p "...fetching #{e.url}" + slug = e.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') + path = site.in_source_dir("_posts/#{slug}.md") + doc = Jekyll::Document.new( + path, { :site => site, :collection => site.collections['posts'] } + ) + doc.data['external_source'] = src['name']; + doc.data['feed_content'] = e.content; + doc.data['title'] = "#{e.title}"; + doc.data['description'] = e.summary; + doc.data['date'] = e.published; + doc.data['redirect'] = e.url; + site.collections['posts'].docs << doc + end + end + end + end + +end diff --git a/blog/index.html b/blog/index.html index 4e2f16819da9..bd85f14f005e 100644 --- a/blog/index.html +++ b/blog/index.html @@ -24,7 +24,11 @@

{{ site.blog_description }}