Fix: bibliography month persists to subsequent entries without month (#3391)

Fixes #3386 (the part about the wrong months; the other part (layouting
of bibtex) is fixed in #3387)

## Summary
- Fixes incorrect month shown for bibliography entries that do not
specify a `month` in BibTeX.
- Ensures `month`/`year` do not persist between entries in
`_layouts/bib.liquid`.

## Root Cause
- In Liquid, captured variables persist across iterations if not
reinitialized.
- `entrymonth` and `entryyear` were only set when
`entry.month`/`entry.year` existed, causing values from a previous entry
to leak into the next one when those fields were missing.

## Changes
- Reinitialize date-related variables per entry before conditional
captures:

## Behavior
- Before: Entries without a `month` could display the previous entry's
month.
- After: Entries without a `month` display only the `year`; entries with
a `month` display the correct month and year.


<img width="1956" height="918" alt="image"
src="https://github.com/user-attachments/assets/7a9682e7-55ab-43b7-8f82-f638d14ce08e"
/>
This commit is contained in:
Dominik Fuchß 2026-01-02 23:56:18 +01:00 committed by GitHub
parent 6023fd809f
commit f521c0ae5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -160,9 +160,11 @@
{% else %}
{% capture entrytype %}{% endcapture %}
{% endif %}
{% assign entrymonth = '' %}
{% if entry.month %}
{% capture entrymonth %}{{ " " }}{{ entry.month | capitalize }}{% endcapture %}
{% endif %}
{% assign entryyear = '' %}
{% if entry.year %}
{% capture entryyear %}{{ " " }}{{ entry.year }}{% endcapture %}
{% endif %}