Class: Locomotive::Steam::Liquid::Tags::AltPageLinks

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Concerns::I18nPage
Defined in:
lib/locomotive/steam/liquid/tags/alt_page_links.rb

Instance Method Summary collapse

Methods included from Concerns::I18nPage

#change_page_locale

Instance Method Details

#render(context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/locomotive/steam/liquid/tags/alt_page_links.rb', line 10

def render(context)
  set_vars_from_context(context)

  if @site.locales.size == 1
    ''
  else
    ending_path = context['alt_page_links_ending_path'] || ''

    (
      [%(<link rel="alternate" hreflang="x-default" href="#{url_for(@site.default_locale, ending_path, true)}" />)] +
      @site.locales.map do |locale|
        %(<link rel="alternate" hreflang="#{locale}" href="#{url_for(locale, ending_path)}" />)
      end
    ).join("\n")
  end
end