Skip to content
Snippets Groups Projects
Unverified Commit d49a5393 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

menu

parent 68f9817c
No related branches found
No related tags found
No related merge requests found
...@@ -73,31 +73,34 @@ class Communication::Website::Menu::Item < ApplicationRecord ...@@ -73,31 +73,34 @@ class Communication::Website::Menu::Item < ApplicationRecord
end end
def static_target def static_target
target = '' target = nil
case self.kind case self.kind
when 'url' when 'url'
target = url target = url
when 'page', 'news_article'
target = about.path if about&.published_at
when 'programs' when 'programs'
target = "/#{website.programs_github_directory}" target = "/#{website.programs_github_directory}" if website.programs.any?
when 'program' when 'program'
target = "/#{website.programs_github_directory}#{about.path}" target = "/#{website.programs_github_directory}#{about.path}" if website.about_school?
when 'news' when 'news'
target = "/#{website.posts_github_directory}" target = "/#{website.posts_github_directory}" if website.posts.published.any?
when 'staff' when 'staff'
target = "/#{website.staff_github_directory}" target = "/#{website.staff_github_directory}" if website.people.any?
when 'research_volumes' when 'research_volumes'
target = "/#{website.research_volumes_github_directory}" target = "/#{website.research_volumes_github_directory}" if website.research_volumes.published.any?
when 'research_volume' when 'research_volume'
target = "/#{website.research_volumes_github_directory}#{about.path}" target = "/#{website.research_volumes_github_directory}#{about.path}" if about&.published_at
when 'research_articles' when 'research_articles'
target = "/#{website.research_articles_github_directory}" target = "/#{website.research_articles_github_directory}" if website.research_articles.published.any?
when 'research_article' when 'research_article'
target = "/#{website.research_articles_github_directory}#{about.path}" target = "/#{website.research_articles_github_directory}#{about.path}" if about&.published_at
when 'blank' when 'blank'
target = '' target = ''
else else
target = about&.path target = about&.path
end end
return nil if target.nil?
target.end_with?('/') ? target target.end_with?('/') ? target
: "#{target}/" : "#{target}/"
end end
...@@ -112,12 +115,12 @@ class Communication::Website::Menu::Item < ApplicationRecord ...@@ -112,12 +115,12 @@ class Communication::Website::Menu::Item < ApplicationRecord
end end
def to_static_hash def to_static_hash
return {} if kind_news_article? && !about.published return nil if static_target.nil?
{ {
'title' => title, 'title' => title,
'target' => static_target, 'target' => static_target,
'kind' => kind, 'kind' => kind,
'children' => children.ordered.map(&:to_static_hash) 'children' => children.ordered.map(&:to_static_hash).compact
} }
end end
......
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
.root .root
.ordered .ordered
.map(&:to_static_hash) .map(&:to_static_hash)
.compact
.to_yaml %> .to_yaml %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment