Manual
Almnck.
Price: 50ⓐ

Front Page Navigation Design

Problem

Readers want to browse through front page history—“what was featured yesterday?”—but the current site only supports direct article links and the almanac-day index.

Two key distinctions: - almanac-day: The in-universe publication date (could be 4000 BCE) - frontpage date: When an article appeared on the actual front page

Articles may be re-run (featured multiple times), so the same article can have different prev/next neighbors depending on which frontpage appearance you’re viewing.

Solution Overview

  1. Track frontpage appearances in article frontmatter
  2. Generate a static JSON manifest of frontpage history
  3. Use HTMX to swap article content while navigating prev/next
  4. Provide a /chronology/ archive page as no-JS fallback

Data Model

Frontmatter Change

Rename published to frontpage. Support array values for re-runs:

almanac-day: "-4000-01-01"
frontpage:
  - 2026-01-10
  - 2026-03-15  # re-run

URL Parameter

?fp=YYYY-MM-DD indicates which frontpage context you’re navigating through.

  • /6024/1/1/slug/?fp=2026-01-10 = viewing this article in the context of January 10th’s front page
  • Prev/next navigation uses this to find neighbors in the frontpage timeline
  • If ?fp= doesn’t match any of the article’s frontpage dates, redirect to bare URL

Static Assets

Frontpage Manifests

Distill /frontpage-index-YYYY.json files, sharded by year:

[
  ["2026-01-12", "/6024/1/23/some-article/"],
  ["2026-01-10", "/6024/1/15/older-article/"],
  ["2026-01-03", "/6024/1/8/another/"]
]

Array of [date, url] tuples, sorted by date descending. Compact format to minimize payload.

Chronology Archive Page

Distill /chronology/ with date-anchored entries:

<h1>Chronology</h1>

<div id="2026-01-12" class="chronology-entry">
  <time>January 12, 2026</time>
  <a href="/6024/1/23/some-article/">Article Title</a>
</div>

<div id="2026-01-10" class="chronology-entry">
  <time>January 10, 2026</time>
  <a href="/6024/1/15/older-article/">Older Article</a>
</div>

Each entry has id matching the date for fragment navigation.

Template Changes

article.html

Add id to article element for HTMX selection:

<article id="article-swap" class="body-text">
    {% include "partials/_article_header.html" with item=unit %}
    <div class="maintext">
        {{ content|safe }}
    </div>
</article>

base.html

Add HTMX script and frontpage date span in masthead:

<div class="meta-left">
  <span id="frontpage-date">{{ frontpage_date }}</span>
  <br><a href="/index/">Index</a>
</div>
<script src="{% cdnstatic 'js/htmx.min.js' %}" defer></script>

No-JS Fallback

On article pages, show a link to the chronology archive:

  • Single appearance: Featured, January 4th 2026
  • Multiple appearances: Last Featured, January 4th 2026

Links to /chronology/#2026-01-04 (deep link to that date).

JavaScript

JS reads the manifest, constructs prev/next links with HTMX attributes:

<a href="/6024/1/15/older-article/?fp=2026-01-10"
   hx-get="/6024/1/15/older-article/?fp=2026-01-10"
   hx-select="#article-swap"
   hx-target="#article-swap"
   hx-swap="outerHTML"
   hx-push-url="true">← Previous</a>
  • href = no-JS fallback
  • hx-get = HTMX fetches full page
  • hx-select = extracts just the article
  • hx-swap="outerHTML" = replaces current article
  • hx-push-url = updates browser URL

Manifest Loading

async function loadManifest(year) {
  const resp = await fetch(`/frontpage-index-${year}.json`);
  return resp.json();
}
  • Homepage: hardcode “previous” link at build time (known statically)
  • Pages with ?fp=: load relevant year’s manifest, find neighbors
  • Cross-year navigation: load adjacent manifest as needed

Post-Swap Handling

document.body.addEventListener('htmx:afterSwap', (event) => {
  if (event.detail.target.id === 'article-swap') {
    // 1. Update masthead date from URL param
    const fp = new URLSearchParams(window.location.search).get('fp');
    updateMastheadDate(fp);

    // 2. Re-run sidenote positioning
    positionSidenotes();

    // 3. Inject topical margin-boxes (TODO - stub for now)
    // injectTopicalMargins();
  }
});

Date Sanitization

The ?fp= parameter is user-supplied. Validate strictly before use:

function parseFrontpageDate(fp) {
  const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(fp);
  if (!match) return null;

  const [, year, month, day] = match.map(Number);
  if (month < 1 || month > 12 || day < 1 || day > 31) return null;

  return { year, month, day };
}

function updateMastheadDate(fp) {
  const parsed = parseFrontpageDate(fp);
  if (!parsed) return;  // Invalid param, leave masthead alone

  const el = document.getElementById('frontpage-date');
  if (el) {
    el.textContent = formatFrontpageDate(parsed);
  }
}

View Changes

Homepage

Change from “latest article where almanac-day <= today” to “article where frontpage array contains the most recent date <= today.”

Article Detail

  • Pass frontpage_date to template context (for masthead)
  • Pass frontpage array info for constructing fallback link

Implementation Order

  1. Frontmatter change: rename published → frontpage, support arrays
  2. Update sync to handle new field
  3. Homepage view: query by frontpage date
  4. Article view: pass frontpage context to template
  5. Template changes: id="article-swap", #frontpage-date span
  6. Create /chronology/ archive page and view
  7. Manifest generation: distill frontpage-index JSON files
  8. Add HTMX to base template
  9. Navigation JS: manifest loading, prev/next link construction
  10. Post-swap JS: date update, sidenote repositioning

Future Work

  • Topical margin-box stash system
  • injectTopicalMargins() implementation
  • Potentially cache manifest in localStorage