From 69db6f4c63696e2adc85072fc02225d7026851de Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Fri, 20 Sep 2024 11:17:03 -0400 Subject: [PATCH] Add markdown helper for catalog fields --- app/controllers/catalog_controller.rb | 2 +- app/helpers/hyrax_helper.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 76b8266..dc7f902 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -79,7 +79,7 @@ def self.modified_field # solr fields to be displayed in the index (search results) view # The ordering of the field names is the order of the display config.add_index_field "title_tesim", label: "Title", itemprop: 'name', if: false - config.add_index_field "summary_tesim", label: "Summary", itemprop: 'summary', helper_method: :iconify_auto_link + config.add_index_field "summary_tesim", label: "Summary", itemprop: 'summary', helper_method: :render_markdown config.add_index_field "keyword_tesim", itemprop: 'keywords', link_to_facet: "keyword_sim" # config.add_index_field "subject_tesim", itemprop: 'about', link_to_facet: "subject_sim" config.add_index_field "creator_tesim", itemprop: 'creator', link_to_facet: "creator_sim" diff --git a/app/helpers/hyrax_helper.rb b/app/helpers/hyrax_helper.rb index 9b695c3..4783956 100644 --- a/app/helpers/hyrax_helper.rb +++ b/app/helpers/hyrax_helper.rb @@ -3,4 +3,10 @@ module HyraxHelper include ::BlacklightHelper include Hyrax::BlacklightOverride include Hyrax::HyraxHelperBehavior + + # For use as helper method in catalog controller field definitions. + def render_markdown(field) + text = field[:value].join("\n\n") + DataCatalog::MarkdownService.call(text).html_safe + end end