Class: Middleman::Hatenastar::Generator
- Inherits:
-
Object
- Object
- Middleman::Hatenastar::Generator
- Defined in:
- lib/middleman-hatenastar/generator.rb
Instance Method Summary collapse
- #generate(uri: nil, title: nil, container: nil, entry_node: nil) ⇒ Object
-
#initialize(option) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(option) ⇒ Generator
Returns a new instance of Generator.
4 5 6 7 8 9 10 |
# File 'lib/middleman-hatenastar/generator.rb', line 4 def initialize(option) @token = option[:token] @uri = option[:uri] @title = option[:title] @container = option[:container] @entry_node = option[:entry_node] end |
Instance Method Details
#generate(uri: nil, title: nil, container: nil, entry_node: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/middleman-hatenastar/generator.rb', line 12 def generate(uri: nil, title: nil, container: nil, entry_node: nil) _uri = uri || @uri _title = title || @title _container = container || @container _entry_node = entry_node || @entry_node <<~TAG <script type="text/javascript" src="//s.hatena.ne.jp/js/HatenaStar.js"></script> <script type="text/javascript"> Hatena.Star.Token = '#{@token}'; Hatena.Star.SiteConfig = { entryNodes: { "#{_entry_node}": { uri: "#{_uri}", title: "#{_title}", container: "#{_container}" } } }; </script> TAG end |