Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilii Iakliushin <viakliushin@gitlab.com>2020-11-09 19:26:58 +0300
committerVasilii Iakliushin <viakliushin@gitlab.com>2020-11-13 15:23:29 +0300
commit6208a268079b3974a8cf4c5eafe3c07a544f41b5 (patch)
treedfa7bef8576e7aa91a440d19b621c29fe657b161
parent1495bb1e6aacd7389155ca48ecaddd221ea0efd7 (diff)
Include svg icons from external file
Contributes to https://gitlab.com/gitlab-org/gitlab-docs/-/issues/879 In-lined svg definition increases the size of the generated documentation file. External file usage removes this overhead.
-rw-r--r--commands/frontend.rb10
-rw-r--r--layouts/default.html1
-rw-r--r--layouts/home.html1
-rw-r--r--lib/helpers/icons_helper.rb8
4 files changed, 12 insertions, 8 deletions
diff --git a/commands/frontend.rb b/commands/frontend.rb
index 24d64d4b..2473a277 100644
--- a/commands/frontend.rb
+++ b/commands/frontend.rb
@@ -23,4 +23,14 @@ run do |opts, args, cmd|
ERROR
end
+
+ puts 'Create icons.svg ...'
+ root = File.expand_path('../', __dir__)
+ path = 'node_modules/@gitlab/svgs/dist/icons.svg'
+
+ if File.write('public/assets/images/icons.svg', File.read("#{root}/#{path}"))
+ puts 'Done!'
+ else
+ puts 'Failed to create icons.svg!'
+ end
end
diff --git a/layouts/default.html b/layouts/default.html
index 4ec6f3ca..4aa79de8 100644
--- a/layouts/default.html
+++ b/layouts/default.html
@@ -91,6 +91,5 @@
<script src="<%= @items['/assets/javascripts/global-nav.*'].path %>"></script>
<script src="<%= @items['/assets/javascripts/tables.*'].path %>"></script>
<script src="<%= @items['/frontend/default/default.*'].path %>" data-cookieconsent="ignore"></script>
- <%= icons_sprite %>
</body>
</html>
diff --git a/layouts/home.html b/layouts/home.html
index 22519333..b66b60ee 100644
--- a/layouts/home.html
+++ b/layouts/home.html
@@ -5,7 +5,6 @@
<link rel="canonical" href="<%= @config[:base_url] %>/">
</head>
<body class="landing">
- <%= icons_sprite %>
<%= render '/gtm.*' %>
<%= render '/header.*' %>
<%= yield %>
diff --git a/lib/helpers/icons_helper.rb b/lib/helpers/icons_helper.rb
index 473b1d6f..b4f22edd 100644
--- a/lib/helpers/icons_helper.rb
+++ b/lib/helpers/icons_helper.rb
@@ -6,11 +6,7 @@ module Nanoc::Helpers
module IconsHelper
extend self
- def icons_sprite
- sprite_path = "node_modules/@gitlab/svgs/dist/icons.svg"
-
- %(<div class="d-none">#{read_file(sprite_path)}</div>)
- end
+ ICONS_SVG = '/assets/images/icons.svg'.freeze
def icon(icon_name, size = nil, css_class = nil)
unless known_sprites.include?(icon_name)
@@ -26,7 +22,7 @@ module Nanoc::Helpers
*css_class
].join(' ')
- %(<svg class="#{svg_class}"><use href="##{icon_name}" /></svg>)
+ %(<svg class="#{svg_class}"><use href="#{ICONS_SVG}##{icon_name}" /></svg>)
end
private