knowledge_base_public_page_title_helper.rb 537 B

123456789101112131415161718192021
  1. module KnowledgeBasePublicPageTitleHelper
  2. def kb_public_page_title(leading, trailing, exception)
  3. [
  4. leading&.translation&.title,
  5. kb_public_page_title_suffix(trailing, exception)
  6. ].compact.join(' - ')
  7. end
  8. def kb_public_page_title_suffix(item, exception)
  9. return item&.translation&.title if exception.blank?
  10. suffix = case exception
  11. when :not_found
  12. 'Not Found'
  13. when :alternatives
  14. 'Alternative Translations'
  15. end
  16. zt(suffix)
  17. end
  18. end