class LingualLink < Liquid::Tag
  def initialize(tag_name, dest, _tokens)
    super
    @dest = dest
  end

  def render(context)
    lang = context.environments.first["page"]["lang"]
    ( lang == "en" ) ? "/#{@dest.strip}/" : "/#{lang}/#{@dest.strip}/"
  end
end

Liquid::Template.register_tag('lingual_link', LingualLink)

Add custom tag for creating local links
Add custom tag for creating local links

English pages are at /page while non-English pages are at /lang/page.
This makes linking to translated pages a bit messy.

The custom tag added in this commit makes local page links simpler:
`{% lingual_link <page> %}` yields the correct relative link for <page>.
The tag determines the language from the current page's front matter
`lang` attribute.
