Class: BridgetownObsidian::Builder
- Inherits:
-
Bridgetown::Builder
- Object
- Bridgetown::Builder
- BridgetownObsidian::Builder
- Defined in:
- lib/bridgetown_obsidian/builder.rb
Constant Summary collapse
- REGEX_WIKILINK =
/(?<!!)\[\[([^\]]+?)(?:\|([^\]]+))?\]\]/
- REGEX_IMAGES =
/!\[\[(.+?)\]\]/
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
8 9 10 11 |
# File 'lib/bridgetown_obsidian/builder.rb', line 8 def build generator :wikilinks generator :images end |
#images ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/bridgetown_obsidian/builder.rb', line 23 def images resources.each do |post| post.content.gsub!(REGEX_IMAGES) do |match| image = Regexp.last_match(1) "" end end end |
#wikilinks ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bridgetown_obsidian/builder.rb', line 13 def wikilinks resources.each do |post| post.content.gsub!(REGEX_WIKILINK) do |match| wikilink = Regexp.last_match(1) wikilink_title = Regexp.last_match(2) || wikilink "[#{wikilink_title}](#{url_for("_posts/#{wikilink}.md")})" end end end |