Class: Jekyll::JamComments::Tag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::JamComments::Tag
- Defined in:
- lib/jekyll_jam_comments.rb
Constant Summary collapse
- CLIENT_SCRIPT_URL =
"https://unpkg.com/@jam-comments/[email protected]/dist/index.umd.js"
Instance Attribute Summary collapse
-
#markup ⇒ Object
readonly
Returns the value of attribute markup.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #configuration ⇒ Object
-
#initialize(tag_name, path, tokens) ⇒ Tag
constructor
A new instance of Tag.
- #render(context) ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(tag_name, path, tokens) ⇒ Tag
Returns a new instance of Tag.
14 15 16 17 18 |
# File 'lib/jekyll_jam_comments.rb', line 14 def initialize(tag_name, path, tokens) super @path = path end |
Instance Attribute Details
#markup ⇒ Object (readonly)
Returns the value of attribute markup.
10 11 12 |
# File 'lib/jekyll_jam_comments.rb', line 10 def markup @markup end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/jekyll_jam_comments.rb', line 10 def path @path end |
Instance Method Details
#configuration ⇒ Object
42 43 44 |
# File 'lib/jekyll_jam_comments.rb', line 42 def configuration Jekyll.configuration({})["jam_comments"] end |
#render(context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll_jam_comments.rb', line 20 def render(context) path = context["page"] && context["page"]["url"] markup = service.fetch(:path => path) " #{markup} <script src=\"#{CLIENT_SCRIPT_URL}\"></script> <script> window.JamComments.initialize(); </script> " end |
#service ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/jekyll_jam_comments.rb', line 33 def service @service ||= Service.new( :domain => Jekyll::JamComments::Configuration.domain, :api_key => Jekyll::JamComments::Configuration.api_key, :base_url => Jekyll::JamComments::Configuration.base_url, :environment => Jekyll::JamComments::Configuration.environment ) end |