{% comment %} Per-page version switcher (document pages only; rendered in the site header). Resolves each target channel honestly, in order: 1. same channel-relative URL exists in the target channel, 2. otherwise the page's WSTG ID exists there (renamed/renumbered path), 3. otherwise the nearest existing ancestor section, 4. otherwise the target channel's home ("no direct equivalent"). Targets come from _data/version_map.yaml (generated by prepare_site.py), so a target is never invented for a page that does not exist. {% endcomment %} {% if page.channel_label and page.channel_path and site.data.version_map %} {% assign vmap = site.data.version_map %} {% assign cur_map = vmap.by_channel[page.collection_name] %} {% assign chan_prefix = '/' | append: page.channel_path %} {% assign rel = page.url | remove_first: chan_prefix %} {% assign cur_id = cur_map[rel] %} {% comment %} Badge tone reuses the channel banner colour classes (light + dark). {% endcomment %} {% if page.collection_name == "latest" %} {% assign badge_tone = "latest" %} {% elsif page.collection_name == "stable" or page.channel_label == site.stable_version %} {% assign badge_tone = "stable" %} {% else %} {% assign badge_tone = "past" %} {% endif %}
{{ page.channel_label }} Switch version

Switch version

{% endif %}