Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open
middleman-recursive-nav
Commits
2158ee61
Commit
2158ee61
authored
Apr 24, 2018
by
Maarten de Waard
🤘🏻
Browse files
fix translation_links function for changes in greenhost/website#78
parent
23b5060a
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/middleman-recursive-nav/extension.rb
View file @
2158ee61
...
...
@@ -13,7 +13,9 @@ class RecursiveNav < ::Middleman::Extension
helpers
do
# Return a list of links with translated versions of this page
#
#
# Uses global variable `locale`, which is probably set by the config.rb (or
# maybe by I18n
# Also uses global variable current_page which is part of the sitemap
def
translation_links
links
=
{}
locales
.
select
{
|
l
|
l
!=
locale
}.
each
do
|
loc
|
...
...
@@ -21,8 +23,8 @@ class RecursiveNav < ::Middleman::Extension
# solutions for blog posts than for other pages.
if
current_page
.
path
.
start_with?
"blog"
# Check if same file exists in other language
if
File
.
exists?
current_page
.
source_file
.
sub
(
"
/
#{
locale
}
/
"
,
"
/
#{
loc
}
/
"
)
links
[
loc
]
=
url_for
(
'/'
+
current_page
.
path
.
sub
(
"
/
#{
locale
}
/
"
,
"
/
#{
loc
}
/
"
))
if
File
.
exists?
current_page
.
source_file
.
g
sub
(
/
\b
#{
locale
}
\b
/
,
"
#{
loc
}
"
)
links
[
loc
]
=
url_for
(
'/'
+
current_page
.
path
.
g
sub
(
/
\b
#{
locale
}
\b
/
,
"
#{
loc
}
"
))
end
else
path
=
current_page
.
target
.
sub
(
"pages/"
,
""
).
sub
(
/([\.\/])
#{
locale
}
([\.\/])/
,
"
\\
1
#{
loc
}
\\
2"
)
...
...
@@ -35,6 +37,8 @@ class RecursiveNav < ::Middleman::Extension
links
end
# Test en dit is /en/ ook een /en/en/bla test.
class
NavNode
attr_reader
:type
attr_accessor
:children
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment