Commit e46dc9fc authored by Magnus Rembold's avatar Magnus Rembold
Browse files

added new method link_url for pages to also allow external links in menu

parent acd51c16
......@@ -27,6 +27,12 @@ class Page < ApplicationRecord
path.gsub '/', '_'
end
def link_url
return path if path.start_with? 'http'
return path if path.start_with? '/'
return "/#{path}"
end
# --- Predicates -----------------------------
def published?
......
......@@ -10,12 +10,12 @@
- @pages.each do |page|
- unless page.menu.blank?
%li
= link_to page.menu, "/#{page.path}"
= link_to page.menu, page.link_url
- unless page.pages.published.blank?
%ul.sub_nav
- page.pages.published.each do |p|
%li= link_to p.menu, "/#{p.path}"
%li= link_to p.menu, page.link_url
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment