Skip to content

feat(blocks): show the date on entries from earlier days - #352

Merged
thomasguillot merged 9 commits into
trunkfrom
feat/earlier-day-dates
Nov 27, 2026
Merged

thomasguillot merged 9 commits into
trunkfrom
feat/earlier-day-dates

Conversation

@thomasguillot

Copy link
Copy Markdown
Contributor

Most built-in layouts show only the time of each entry. On a liveblog that runs across days, the feed can go from 12:49 pm straight to 5:27 pm with nothing to say the second entry is from the day before. This adds the date to entries from earlier days, using the same rule Clock got in #338.

What changes

Layouts that show the time now add the date in the site's date format for entries from an earlier day. Today's entries look exactly as before. Pages check again in the browser, so a cached page or one left open past midnight shows the date on yesterday's entries without a reload.

With this change:

  • Bulletin, Byline, Margin, Rail, Split and Wire show the date right after the time on entries from earlier days, small and semibold like Clock's.
  • Bulletin's pinned entry shows the clock time like its other entries, instead of "2 days ago".
  • Digest and Flash keep only the time: they show the newest entries of a live story, where a day-old entry is rare. Digest's time column is narrower (4.5rem, sized to the longest time), so the text gets the room.
  • Byline on phones: the time, date and New label share one line under the name, and the label keeps its space while hidden, so nothing moves when it clears.
  • Stream and Ticker keep their relative dates ("5 min ago"), which already say which day.

Closes #351.

Before After
Choose a layout, before Choose a layout, after
Bulletin, before Bulletin, after
Wire, before Wire, after
Digest, before Digest, after
Rail, before Rail, after

How to test

  1. Use a liveblog with entries from today and from an earlier day.
  2. Put its Rolling Coverage block on a page and pick each of Bulletin, Byline, Margin, Rail, Split and Wire in turn. Today's entries show only the time; earlier ones show the time followed by the date.
  3. Pick Bulletin and pin an entry. The pinned entry shows the clock time, with the date when it's from an earlier day.
  4. Pick Digest and Flash. They show only the time.
  5. Pick Stream and Ticker. They still show "… ago".
  6. On a phone-width window, pick Byline with an author whose name is about 20 characters, and publish a new entry while the page is open. When "New" clears, nothing below it moves.
  7. In the layout picker and the layout editor, the date line shows on every sample entry, so it can be styled.
  8. Switch to the classic Newspack Theme and repeat step 2. No block shows as invalid.
Technical details
  • One builder: earlierDayDate() in template.ts builds the Post Date with EARLIER_DAY_DATE_CLASS and the {{date_format}} token, which Clock now uses too (its server copy is unchanged). The server filter mark_earlier_day_entry_date() and the view's refreshEarlierDayDates() from feat: add ready-made liveblog page patterns #338 handle hiding and the midnight re-check, so there is no new server code.
  • Placement: Bulletin's Details row (time, date, Share), Byline's new newspack-rolling-coverage-byline-time row, Margin and Wire through timeRow(), Rail and Split under the time (Split wraps the New label and time in a stack so the phone row-reverse rule still applies).
  • Byline: the Author + Date group wraps; the Time row doesn't. A hidden New label in that row keeps its room (display: block; visibility: hidden), and the time has flex-shrink: 0; white-space: nowrap, so on the narrowest phones only an earlier-day date breaks after its comma. The layout test now requires a New label that shares a line to sit in a row that never wraps.
  • Hidden dates: .newspack-rolling-coverage-earlier-day-date[hidden] { display: none; }, so a theme setting display on post dates can't show today's date.
  • Tests: layout template tests for placement in every time-only layout, Bulletin's pinned clock time, relative dates kept in Stream and Ticker; test-earlier-day-date.php renders all seven layouts with today's date hidden and an earlier day's shown.
  • Saved layouts: sites keep their own copy of a built-in layout they've saved, so they get this only from new or reset layouts; Update page patterns and built-in layouts that are already in use #350 covers updating them.

Self-review: two rounds (Opus 5.5), one blocker fixed.

thomasguillot and others added 9 commits November 27, 2026 20:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomasguillot

Copy link
Copy Markdown
Contributor Author

Self-review summary: 2 rounds on this branch before handoff.

Accepted:

  • 5989e9d, 5ff8b8f, fb90f05: in Byline, the New label could wrap onto a line of its own under a long author name and shift the entry when it cleared. The time, date and label now share a row that never wraps, the hidden label keeps its space so clearing it moves nothing, and the time stays on one line on the narrowest phones. The layout test now requires a label that shares a line to sit in a row that never wraps.
  • 46223b4: today's hidden date stays hidden even on a theme that sets display on post dates.
  • c05bd18: two tests that also passed on trunk are trimmed, and a test name now says what it checks.
  • 829fea1: docs and docblocks describe the date in Bulletin's row, Stream as the remaining relative-date example, and where long dates break in narrow columns.
  • Round 2: no changes; confirmed the above holds.

Declined:

  • Widening Digest's time column: it's sized on purpose to the longest time plus a little room.
  • Long custom date formats wrapping in narrow time columns: wrapping is the right fallback, and the default format fits.
Deferred (not blocking)
  • Dropped: a test could read today's entry as an earlier day if it ran across the site's midnight (a one-second window).

@thomasguillot
thomasguillot merged commit 05ec466 into trunk Nov 27, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Hey @thomasguillot, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

@thomasguillot
thomasguillot deleted the feat/earlier-day-dates branch November 27, 2026 22:44
@tiffehr

tiffehr commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

@thomasguillot Thank you! This looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the date on entries from earlier days in every layout

2 participants