diff options
author | Marcia Ramos <virtua.creative@gmail.com> | 2018-04-17 19:51:38 +0300 |
---|---|---|
committer | Marcia Ramos <virtua.creative@gmail.com> | 2018-04-17 19:51:38 +0300 |
commit | ae32b71aaca0c024d7fabfb81850626b042a548a (patch) | |
tree | a3db85fde5ab82c8d0575a3ad6964f39e40b2c8d /Rules | |
parent | bea80f92f7d9fe2ad61e736466f4aab00a4b32e4 (diff) |
Add badges to docs
Diffstat (limited to 'Rules')
-rw-r--r-- | Rules | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -1,6 +1,10 @@ #!/usr/bin/env ruby +TITLE_FILTER_REGEXP = /(#\s|#{BadgesFilter::BADGES_PATTERN})/ + preprocess do + badges_filter = BadgesFilter.new + @items.each do |item| if item.identifier.to_s.end_with?(".md") && !item.binary? # If there isn't already a 'redirect_to' defined in the yaml frontmatter, @@ -19,11 +23,15 @@ preprocess do end end - unless item[:title] - title = item.raw_content.match(/^[#] .*$/).to_s - title.gsub!('# ', '') - item[:title] = title unless title.empty? - end + # We need to do some transformations for the title + # Let's extract and keep it first: + raw_title = item.raw_content.match(/^[#] .*$/).to_s + + # If we don't have a title in frontmatter, reuse the one we just fetch + item[:title] ||= raw_title.gsub(TITLE_FILTER_REGEXP, '') + + # Run badges filter with title fragment + item[:title_badge] = badges_filter.run(raw_title.match(BadgesFilter::BADGES_PATTERN).to_s) end end end @@ -51,6 +59,9 @@ compile '/**/*.md' do # Set to 'toc: false' to disable it. include_toc = item[:toc].nil? ? true : false + # GitLab price / tiers specific badges + filter :badges + # Use Redcarpet with Rouge. filter :redcarpet, renderer: HTML, |