From 1ae27a79d2086275b5ca3a1f60c5d67103dbadcb Mon Sep 17 00:00:00 2001 From: Marshall Cottrell Date: Tue, 8 Nov 2022 21:22:59 +0000 Subject: Add layout and styling for blueprint index page --- lib/helpers/blueprints.rb | 33 +++++++++++++++++++++++++++++++++ lib/helpers_.rb | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 lib/helpers/blueprints.rb (limited to 'lib') 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? + + %( + + #{scope} + #{%(#{text}) if is_scoped} + + ) + 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 -- cgit v1.2.3