diff --git a/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder b/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder index d10707b76..20a9948f5 100644 --- a/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +++ b/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder @@ -8,9 +8,11 @@ json.theme do json.icons({}) json.icons do + icons_directory = theme.options.fetch(:custom_icons_directory, 'icons') + theme.options.fetch(:custom_icons, []).each do |icon_name| json.set!(icon_name, - scrolled_theme_asset_path(theme, "icons/#{icon_name}.svg", + scrolled_theme_asset_path(theme, File.join(icons_directory, "#{icon_name}.svg"), relative_url: true)) end end diff --git a/entry_types/scrolled/spec/helpers/pageflow_scrolled/entry_json_seed_helper_spec.rb b/entry_types/scrolled/spec/helpers/pageflow_scrolled/entry_json_seed_helper_spec.rb index 58a9c9936..61eb8ea6a 100644 --- a/entry_types/scrolled/spec/helpers/pageflow_scrolled/entry_json_seed_helper_spec.rb +++ b/entry_types/scrolled/spec/helpers/pageflow_scrolled/entry_json_seed_helper_spec.rb @@ -698,6 +698,7 @@ def render(helper, entry, options = {}) config.themes.register(:default, custom_icons: [:share]) end entry = create(:published_entry, type_name: 'scrolled') + result = render(helper, entry) expect(result).to include_json(config: { @@ -711,6 +712,31 @@ def render(helper, entry, options = {}) }) end + it 'supports custom icons directories' do + pageflow_configure do |config| + config.themes.register(:default, + custom_icons: [:share], + custom_icons_directory: 'icons/someSet') + end + entry = create(:published_entry, type_name: 'scrolled') + theme_directory = Rails.root.join('app/javascript/pageflow-scrolled/themes/default') + FileUtils.mkdir_p(theme_directory.join('icons/someSet')) + FileUtils.cp(theme_directory.join('icons/share.svg'), + theme_directory.join('icons/someSet/share.svg')) + + result = render(helper, entry) + + expect(result).to include_json(config: { + theme: { + assets: { + icons: { + share: %r{themes/default/icons/someSet/share.*svg$} + } + } + } + }) + end + it 'does not use asset host in icon paths to allow xlink:href usage' do controller.config.asset_host = 'some-asset-host' pageflow_configure do |config|