Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dist-tags and dates are read from the npm registry when the site builds (`vite.c
unreleased; in CI (`CI` set) the build fails instead.

The changelog's notes are the published GitHub releases, as GitHub renders them (`vite.config.ts` →
`src/lib/github.ts` → `src/lib/release-notes.ts`): to change what the site says about a version, edit
`src/lib/github.ts` → `src/routes/docs/changelog/`): to change what the site says about a version, edit
its release on GitHub and redeploy. A release is a draft until its version is approved on npm, so the
site never shows notes for a version that isn't out (see `CONTRIBUTING.md` → Releases). Set
`GITHUB_TOKEN` to read them with a token. Offline or rate-limited, a local or preview build goes on
Expand Down
8 changes: 0 additions & 8 deletions website/src/lib/release-notes.ts

This file was deleted.

50 changes: 30 additions & 20 deletions website/src/routes/docs/changelog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component$, useSignal } from "@qwik.dev/core";
import { Link, type DocumentHead } from "@qwik.dev/router";
import type { Releases } from "~/lib/github";
import { majorOf, newestFirst, NPM, tagsOf } from "~/lib/release";
import { RELEASES } from "~/lib/release-notes";
import { GITHUB_URL, NPM_URL } from "~/lib/versions";
import styles from "../pages.module.css";

Expand All @@ -14,24 +14,33 @@ const FILTERS = [

type Filter = (typeof FILTERS)[number]["id"];

// The notes of each GitHub release: vite.config.ts reads them when the site
// builds and defines `__RELEASES__` with them, so only this page carries them.
declare const __RELEASES__: Releases;
const RELEASES: Releases = __RELEASES__;

// Every version on npm, newest first, with its notes from the GitHub release
// of its tag; versions, tags and days come from npm.
const VERSIONS = Object.keys(NPM.dates)
.sort(newestFirst)
.map((version, index, all) => {
const major = majorOf(version);
return {
version,
major,
date: NPM.dates[version],
tags: tagsOf(NPM, version),
notes: RELEASES[version] ?? null,
/** the version before it, for the commits between both */
previous: all[index + 1] ?? null,
/** the newest version of its major carries the link to that major's docs */
newestOfMajor: all.findIndex((other) => majorOf(other) === major) === index,
};
});
// of its tag; versions, tags and days come from npm. Built when the page
// renders, not when the module loads: in the client build Rolldown can put the
// modules this reads in a chunk that imports this one back, and a module-level
// read would run before they're initialized (an empty page after a <Link>).
const versionsOf = () =>
Object.keys(NPM.dates)
.sort(newestFirst)
.map((version, index, all) => {
const major = majorOf(version);
return {
version,
major,
date: NPM.dates[version],
tags: tagsOf(NPM, version),
notes: RELEASES[version] ?? null,
/** the version before it, for the commits between both */
previous: all[index + 1] ?? null,
/** the newest version of its major carries the link to that major's docs */
newestOfMajor: all.findIndex((other) => majorOf(other) === major) === index,
};
});

const formatDate = (iso: string) =>
new Date(`${iso}T12:00:00Z`).toLocaleDateString("en-US", {
Expand All @@ -44,7 +53,8 @@ const formatDate = (iso: string) =>
export default component$(() => {
const filter = useSignal<Filter>("all");

const visible = VERSIONS.filter((v) => filter.value === "all" || v.major === filter.value);
const versions = versionsOf();
const visible = versions.filter((v) => filter.value === "all" || v.major === filter.value);

return (
<>
Expand Down Expand Up @@ -76,7 +86,7 @@ export default component$(() => {
))}
</div>

{VERSIONS.length === 0 ? (
{versions.length === 0 ? (
<p class={styles.noNotes}>
npm couldn't be read when this page was built, so there are no versions to show.
</p>
Expand Down
Loading