Class: Jekyll::ActionNetwork::Action
- Inherits:
-
Object
- Object
- Jekyll::ActionNetwork::Action
- Defined in:
- lib/jekyll/action-network/action.rb
Overview
An action network action, call the doc method to get a Jekyll::Document for this action
Instance Method Summary collapse
- #content ⇒ Object
- #doc ⇒ Object
- #front_matter ⇒ Object
-
#initialize(site, name, collection, config, action) ⇒ Action
constructor
A new instance of Action.
- #path ⇒ Object
- #slug ⇒ Object
Constructor Details
#initialize(site, name, collection, config, action) ⇒ Action
Returns a new instance of Action.
9 10 11 12 13 14 15 16 |
# File 'lib/jekyll/action-network/action.rb', line 9 def initialize(site, name, collection, config, action) @site = site @collection = collection @config = config @action = action @name = name @utils = Jekyll::ActionNetwork::Utils.new end |
Instance Method Details
#content ⇒ Object
49 50 51 |
# File 'lib/jekyll/action-network/action.rb', line 49 def content @content ||= @action[@config["content"]] end |
#doc ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/action-network/action.rb', line 18 def doc return @doc if @doc @doc = Jekyll::Document.new(path, collection: @collection, site: @site) @doc.content = content @doc.merge_data!(front_matter) @doc end |
#front_matter ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jekyll/action-network/action.rb', line 35 def front_matter return @front_matter if @front_matter @front_matter = {} @config["mappings"].each do |a, d| front_matter[d] = @action[a] end @front_matter["layout"] = @config["layout"] @front_matter["slug"] = slug @front_matter["embed_code"] = @utils.(@action["browser_url"]) @front_matter["action_type"] = @name @front_matter end |
#path ⇒ Object
31 32 33 |
# File 'lib/jekyll/action-network/action.rb', line 31 def path @path ||= File.join(@site.source, "_#{@config["collection"]}", "#{slug}.md") end |
#slug ⇒ Object
27 28 29 |
# File 'lib/jekyll/action-network/action.rb', line 27 def slug @slug ||= @action["browser_url"].split("/")[-1] if @action["browser_url"] end |