Class: BridgetownNotable::Builder
- Inherits:
-
Bridgetown::Builder
- Object
- Bridgetown::Builder
- BridgetownNotable::Builder
- Defined in:
- lib/bridgetown-notable/builder.rb
Constant Summary collapse
- LINK_PATTERN =
%r!\[\[([^\]]+)\]\]!.freeze
Instance Method Summary collapse
Instance Method Details
#attachments ⇒ Object
13 14 15 16 17 |
# File 'lib/bridgetown-notable/builder.rb', line 13 def notable_pages.each do |page| page.content.gsub!("(@attachment/", "(/attachments/") end end |
#backlinks ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/bridgetown-notable/builder.rb', line 19 def backlinks notable_pages.each do |page| pagename = page.data[:title] backlinks = site.pages.select { |pg| pg.content =~ %r!\[\[#{pagename}\]\]!i } page.data[:backlinks] = backlinks if backlinks.any? end end |
#build ⇒ Object
7 8 9 10 11 |
# File 'lib/bridgetown-notable/builder.rb', line 7 def build generator :attachments generator :backlinks generator :wikilinks end |
#wikilinks ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bridgetown-notable/builder.rb', line 27 def wikilinks notable_pages.each do |page| page.content.gsub!(LINK_PATTERN) do |match_string| title = match_string.match(LINK_PATTERN)[1] link = site.pages.detect { |pg| pg.data[:title] == title } if link %(<a href="#{link.url}" class="wikilink">#{link.data[:title]}</a>) else title end end end end |