Browse Source

Add insert_git_code plugin

bryan 4 years ago
parent
commit
928eea77d4
1 changed files with 21 additions and 0 deletions
  1. 21 0
      blog.bryanroessler.com/_plugins/insert_git_code.rb

+ 21 - 0
blog.bryanroessler.com/_plugins/insert_git_code.rb

@@ -0,0 +1,21 @@
+require 'open-uri'
+
+module Jekyll
+    class InsertGitCode < Liquid::Tag
+
+        def initialize(tag_name, url, tokens)
+            super
+            url = url.strip()
+            @filename = File.basename(url)
+            encoded_url = URI.encode(url)
+            @file = URI.parse(encoded_url).read
+        end
+
+        def render(_context)
+            @file
+        end
+
+    end
+end
+
+Liquid::Template.register_tag('insert_git_code', Jekyll::InsertGitCode)