Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout du chemin de fichier au menu #2451

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions app/models/communication/website/menu/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def static_target
when "url"
url
else
about_l10n = about.localization_for(language)
if about_l10n.present?
about_l10n_permalink = about_l10n.new_permalink_in_website(website)
about_l10n_permalink.computed_path
Expand All @@ -131,6 +130,10 @@ def static_target
end
end

def static_file
hugo.file if about.present?
end

def list_of_other_items
items = []
menu.items.where.not(id: id).root.ordered.each do |item|
Expand All @@ -142,12 +145,14 @@ def list_of_other_items

def to_static_hash
return nil if static_target.nil?
{
hash = {
'title' => title,
'target' => static_target,
'kind' => kind,
'children' => children.ordered.map(&:to_static_hash).compact
}
hash['file'] = static_file if static_file.present?
hash
end

def has_about?
Expand All @@ -174,6 +179,14 @@ def siblings

protected

def hugo
@hugo ||= about_l10n.hugo(website)
end

def about_l10n
@about_l10n ||= about.localization_for(language)
end

def last_ordered_element
menu.items.where(parent_id: parent_id).ordered.last
end
Expand Down
Loading