Only collapse cross-refs when 3+ are hidden

Show +1 or +2 refs expanded inline. Only show the +N collapse
indicator when there are 3 or more hidden refs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-05 00:08:08 -05:00
parent 84b2316bb5
commit 4f22d1ef02
+2 -1
View File
@@ -466,9 +466,10 @@ document.body.dataset.resourceReader = 'false';
{% if commentary.cross_reference_groups %}
{% set total_refs = commentary.cross_reference_groups | sum(attribute='refs', start=[]) | length %}
{% set preview_count = [commentary.cross_reference_groups|length, 3]|min %}
{% set hidden_count = total_refs - preview_count %}
<label for="sn-{{ verse.verse }}-xrefs" class="margin-toggle sidenote-number"></label>
<input type="checkbox" id="sn-{{ verse.verse }}-xrefs" class="margin-toggle"/>
<span class="sidenote cross-refs">{% for group in commentary.cross_reference_groups[:3] %}<strong>{{ group.description }}:</strong> <a href="{{ group.refs[0].url }}">{{ group.refs[0].text }}</a>{% if group.refs|length > 1 %}<span class="xref-extra">; {% for ref in group.refs[1:] %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}</span>{% endif %}{% if not loop.last %}. {% endif %}{% endfor %}{% if commentary.cross_reference_groups|length > 3 %}<span class="xref-extra">. {% for group in commentary.cross_reference_groups[3:] %}<strong>{{ group.description }}:</strong> {% for ref in group.refs %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% if not loop.last %}. {% endif %}{% endfor %}</span>{% endif %}{% if total_refs > preview_count %}<span class="xref-more"> +{{ total_refs - preview_count }}</span>{% endif %}</span>
<span class="sidenote cross-refs">{% for group in commentary.cross_reference_groups[:3] %}<strong>{{ group.description }}:</strong> <a href="{{ group.refs[0].url }}">{{ group.refs[0].text }}</a>{% if group.refs|length > 1 %}{% if hidden_count >= 3 %}<span class="xref-extra">; {% for ref in group.refs[1:] %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}</span>{% else %}; {% for ref in group.refs[1:] %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% endif %}{% endif %}{% if not loop.last %}. {% endif %}{% endfor %}{% if commentary.cross_reference_groups|length > 3 %}{% if hidden_count >= 3 %}<span class="xref-extra">. {% for group in commentary.cross_reference_groups[3:] %}<strong>{{ group.description }}:</strong> {% for ref in group.refs %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% if not loop.last %}. {% endif %}{% endfor %}</span>{% else %}. {% for group in commentary.cross_reference_groups[3:] %}<strong>{{ group.description }}:</strong> {% for ref in group.refs %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% if not loop.last %}. {% endif %}{% endfor %}{% endif %}{% endif %}{% if hidden_count >= 3 %}<span class="xref-more"> +{{ hidden_count }}</span>{% endif %}</span>
{% endif %}
{% endif %}
</p>