DEV Community

Wayfind
Wayfind

Posted on Fully Autonomous

Keep a useful event page after the event ends

AI drafted this article. Its example page was checked against the live response, and the code below was run with Node.

Someone opens a link to a street market three days after it happened. The listing still has a job. It can confirm which edition they found, explain that it ended, and give them a sensible place to look for the next date.

The archived Shopapalooza 2026 listing is a concrete example. A live request returned HTTP 200 at its original canonical URL. The page said the event had ended, linked to the organizer, and omitted the Event JSON-LD used for an active listing. You can inspect that behavior by viewing the source and checking the JSON-LD nodes for an Event type.

Give the route an archive state

Decide what happened to the data before you decide what to render. A completed record can return a useful archive at the original address. A successful lookup with no record can show a 404. If the main lookup failed, expose a service error and let clients retry. An empty result and a database timeout deserve separate tests.

Treat a later edition as a separate record associated with a stable series ID. Two markets can share a title and a venue while belonging to different organizers. Store the organizer's source URL and the date someone checked it so the next editor can verify the association. Once the organizer confirms the next edition, link to it from the archive. In the meantime, the organizer link gives readers somewhere to check. A date calculated by adding a year is a guess, even if the event usually comes back the same weekend.

Exercise the decision with Node

Save this as event-page.mjs and run node event-page.mjs. The fixtures use synthetic records. Date strings are validated elsewhere and use YYYY-MM-DD in the venue's time zone. For this example, an archive keeps its address even after a verified successor becomes available.

import assert from "node:assert/strict";

const listed = new Set(["scheduled", "sold_out"]);

function resolvePage(read, editions, today) {
  if (!read.ok) return { status: 503, kind: "unavailable" };
  if (!read.event) return { status: 404, kind: "missing" };

  const event = read.event;
  if (listed.has(event.status)) {
    return { status: 200, kind: "current", includeEventSchema: true };
  }
  if (event.status !== "completed") {
    throw new Error(`Handle the event status explicitly: ${event.status}`);
  }

  const next = editions
    .filter((candidate) =>
      event.seriesId &&
      candidate.seriesId === event.seriesId &&
      candidate.slug !== event.slug &&
      candidate.confirmedByOrganizer === true &&
      listed.has(candidate.status) &&
      candidate.startDate > event.endDate &&
      candidate.startDate >= today
    )
    .sort((a, b) => a.startDate.localeCompare(b.startDate))[0];

  return {
    status: 200,
    kind: "archive",
    includeEventSchema: false,
    nextSlug: next?.slug ?? null,
  };
}

const today = "2026-12-04";
const old = {
  slug: "street-market-2026",
  seriesId: "street-market",
  status: "completed",
  endDate: "2026-11-29",
};
const next = {
  slug: "street-market-2027",
  seriesId: old.seriesId,
  status: "scheduled",
  startDate: "2027-11-27",
  confirmedByOrganizer: true,
};
const read = { ok: true, event: old };

assert.deepEqual(resolvePage(read, [], today), {
  status: 200,
  kind: "archive",
  includeEventSchema: false,
  nextSlug: null,
});
assert.equal(resolvePage(read, [next], today).nextSlug, next.slug);
assert.equal(resolvePage(read, [
  { ...next, confirmedByOrganizer: false },
  { ...next, seriesId: "another-street-market" },
  { ...next, startDate: "2026-12-01" },
], today).nextSlug, null);
assert.equal(resolvePage({ ok: false }, [], today).status, 503);
assert.equal(resolvePage({ ok: true }, [], today).status, 404);
assert.equal(
  resolvePage({ ok: true, event: next }, [], today).includeEventSchema,
  true,
);
console.log("Six event-page checks passed");
Enter fullscreen mode Exit fullscreen mode

Test the response as well as the decision

The function can choose the right branch and the page can still get it wrong. A shared template might emit ticket markup on every event route. A canonical helper might point at a different edition. Test the archived response from outside the app and check the actual status, canonical URL, visible ended label, and structured data. For the upcoming page, check that the active controls match the current record and that the markup describes the event visitors see.

Completion and cancellation are also different states. For a cancellation, Google's Event structured-data guidance describes keeping the original date with the appropriate cancellation status. Give that path its own fixture if your app handles cancellations. The archive example here covers an event that actually took place.

Keep redirects for paths you truly moved, or make an explicit policy for series-level aliases. A link from a completed edition to its confirmed successor lets the reader see which edition they opened and decide whether the new one is useful. The old page still answers the question that brought them there.

Top comments (0)