diff options
author | Marshall Cottrell <mcottrell@gitlab.com> | 2022-11-09 00:22:59 +0300 |
---|---|---|
committer | Sarah German <sgerman@gitlab.com> | 2022-11-09 00:22:59 +0300 |
commit | 1ae27a79d2086275b5ca3a1f60c5d67103dbadcb (patch) | |
tree | 4796c2cba286a35392846cb6f78f889a3ca0d391 /lib | |
parent | 618007f8e9cc711a616e6186e178f429e1e656b2 (diff) |
Add layout and styling for blueprint index page
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers/blueprints.rb | 33 | ||||
-rw-r--r-- | lib/helpers_.rb | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/helpers/blueprints.rb b/lib/helpers/blueprints.rb new file mode 100644 index 00000000..2e889732 --- /dev/null +++ b/lib/helpers/blueprints.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Nanoc::Helpers + module Blueprints + def all_blueprints + @items.find_all('/ee/architecture/blueprints/**/*.md').sort_by { |i| blueprint_creation_date(i) }.reverse + end + + def author_link(author) + username = author.tr('@', '') + link_to("@#{username}", "https://gitlab.com/#{username}") + end + + def blueprint_creation_date(blueprint) + blueprint[:'creation-date'].nil? ? '-' : Time.parse(blueprint[:'creation-date']).strftime('%Y-%m-%d') + end + + # TODO: this is generic, should live elsewhere + def gl_label(label) + return if label.nil? + + scope, text = label.tr('~', '').split('::') + is_scoped = !text.nil? + + %( + <span class="gl-label #{is_scoped ? 'gl-label-scoped' : ''} #{scope}"> + <span class="gl-label-text">#{scope}</span> + #{%(<span class="gl-label-text-scoped">#{text}</span>) if is_scoped} + </span> + ) + end + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index ed7eaeda..cb831720 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true use_helper Nanoc::Helpers::AlgoliaRank +use_helper Nanoc::Helpers::Blueprints use_helper Nanoc::Helpers::EditOnGitLab use_helper Nanoc::Helpers::Generic use_helper Nanoc::Helpers::GitLabKramdown @@ -9,3 +10,4 @@ use_helper Nanoc::Helpers::ReadingTimeHelper use_helper Nanoc::Helpers::Rendering use_helper Nanoc::Helpers::VersionsDropdown use_helper Nanoc::Helpers::XMLSitemap +use_helper Nanoc::Helpers::LinkTo |