changelogs

This commit is contained in:
tresabhi committed 2026-12-04 17:45:02 -06:00
1 parent 0d8fcacdbf
commit f43b0455ab
18 files changed
+414 -157

No files matched your search

+1
View File
@@ -38,6 +38,7 @@
"react-dom": "^19.3.0",
"react-error-boundary": "^6.1.3",
"react-promise-suspense": "^0.3.4",
"simple-git": "^4.1.0",
"soapstone": "^1.2.0",
"three": "^0.180.0",
"three-stdlib": "^2.36.0",
@@ -0,0 +1,218 @@
---
import { changelogs } from "../core/blitzkit/changelogs";
import { Heading } from "./Heading";
import { Link } from "./Link";
import { Markdown } from "./Markdown";
import { ScrollerOrientation } from "./Scroller";
import { ScrollerCurtains } from "./ScrollerCurtains";
import { Separator } from "./Separator";
import { Text } from "./Text";
interface Props {
locale: string;
}
const { locale } = Astro.props;
const dateFormat = new Intl.DateTimeFormat(locale, { dateStyle: "long" });
// Patches grouped under their major.minor release: releases newest first,
// patches within one oldest first
const groups = new Map<string, string[]>();
for (const key of changelogs.keys()) {
const release = key.split(".").slice(0, 2).join(".");
const group = groups.get(release);
if (group) {
group.unshift(key);
} else {
groups.set(release, [key]);
}
}
---
<style>
.page {
flex-grow: 1;
/* Centered within the page width, lined up with the navbar */
align-self: center;
width: 100%;
max-width: var(--page-width);
/* The navbar's gap above the page is matched on the sides and below */
padding: 0 var(--page-padding) var(--page-padding);
box-sizing: border-box;
display: grid;
grid-template-columns: auto 1fr;
grid-template-areas: "panel content";
.panel {
grid-area: panel;
display: flex;
flex-direction: column;
gap: var(--space-4);
background-color: var(--gray-2);
position: sticky;
align-self: start;
top: calc(var(--navbar-big-height, 0px) + var(--page-padding));
/* Floats with the page padding clear above and below it */
max-height: calc(
100dvh - var(--navbar-big-height, 0px) - var(--page-padding) * 2
);
overflow-y: auto;
border-radius: var(--space-4);
padding: var(--space-5);
box-sizing: border-box;
.release {
display: flex;
flex-direction: column;
gap: var(--space-3);
.versions {
display: grid;
grid-template-columns: repeat(3, auto);
gap: var(--space-2) var(--space-4);
.version {
justify-content: start;
}
}
}
}
.content {
--padding: var(--space-5);
--page-compensated-padding: calc(var(--padding) - var(--page-padding));
grid-area: content;
display: flex;
flex-direction: column;
gap: var(--space-5);
min-width: 0;
padding: var(--padding);
padding-top: var(--page-compensated-padding);
box-sizing: border-box;
/* Keeps versions below the navbar, read by the panel's script too */
.entry {
display: flex;
flex-direction: column;
gap: var(--space-3);
scroll-margin-top: calc(
var(--navbar-big-height, 0px) + var(--page-padding)
);
/* The title and its date share a line, wrapping once it runs out */
.header {
display: flex;
flex-wrap: wrap;
align-items: start;
justify-content: space-between;
gap: var(--space-2) var(--space-4);
}
}
}
@media (width < 44rem) {
grid-template-columns: 1fr;
grid-template-areas: "content";
.panel {
display: none;
}
.content {
padding: var(--page-compensated-padding);
}
}
}
</style>
<div class="page">
<nav class="panel" id="changelog-panel">
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} client:load />
{[...groups].map(([release, versions]) => (
<section class="release">
<Heading size="5" lowContrast>
{release}
</Heading>
<div class="versions">
{versions.map((key) => (
<Link
className="version"
href={`#${key}`}
color="gray"
highContrast
underline="hover"
>
{key}
</Link>
))}
</div>
</section>
))}
</nav>
<div class="content">
{[...changelogs].map(([version, { title, content, date }], index) => (
<>
{index > 0 && <Separator />}
<article class="entry" id={version}>
<header class="header">
<Heading size="2" className="title">
{title}
</Heading>
{date && (
<Text size="minor" lowContrast>
{dateFormat.format(date)}
</Text>
)}
</header>
<Markdown {content} />
</article>
</>
))}
</div>
</div>
<script>
import { reducesMotion } from "../core/blitzkit/reducesMotion";
const panel = document.getElementById("changelog-panel")!;
// Glides to the version below the navbar rather than jumping behind it
panel.addEventListener("click", (event) => {
const link = (event.target as HTMLElement).closest<HTMLAnchorElement>(
".version",
);
if (!link) return;
const hash = link.getAttribute("href")!;
const entry = document.getElementById(hash.slice(1))!;
// The same offset the CSS gives links that open the page on a version
const margin = parseFloat(getComputedStyle(entry).scrollMarginTop);
const top = entry.getBoundingClientRect().top + window.scrollY - margin;
const behavior = reducesMotion() ? "instant" : "smooth";
event.preventDefault();
history.replaceState(null, "", hash);
window.scrollTo({ top, behavior });
});
</script>
+1 -1
View File
@@ -98,7 +98,7 @@ const strings = await api.strings(locale);
>
{strings.website.footer.about.github}
</Link>
<LinkI18n {locale} href="/docs/patches" color="gray">
<LinkI18n {locale} href="/changelogs" color="gray">
{strings.website.footer.about.patches}
</LinkI18n>
</Flex>
@@ -0,0 +1,31 @@
.markdown {
display: flex;
flex-direction: column;
gap: var(--space-3);
line-height: 1.5;
.heading-1 {
line-height: 1.2;
}
/* Sections set themselves apart from the content before them */
.heading-2 {
margin-top: var(--space-4);
}
.heading-3 {
margin-top: var(--space-3);
}
/* TODO: make formal ul/ol compoentns */
.list {
margin: 0;
padding-left: var(--space-5);
}
.image {
max-width: 100%;
border-radius: var(--space-4);
}
}
@@ -1,40 +1,60 @@
import { Link, Table } from '@radix-ui/themes';
import MarkdownToJSX from 'markdown-to-jsx';
import type { ComponentProps } from 'react';
import { docImageUrl, isExternalImage } from '../../core/blitzkit/docImages';
import { LazyImage } from '../LazyImage';
import MarkdownToJSX from "markdown-to-jsx";
import { Fragment, type ComponentProps } from "react";
import { docImageUrl, isExternalImage } from "../../core/blitzkit/docImages";
import { Code } from "../Code";
import { Heading } from "../Heading";
import { Link } from "../Link";
import { Table } from "../Table";
import { Text } from "../Text";
import styles from "./index.module.css";
interface MarkdownProps {
children: string;
content: string;
}
function Image({ src, ...props }: ComponentProps<'img'>) {
return (
<LazyImage
style={{ maxWidth: '100%' }}
src={src && isExternalImage(src) ? docImageUrl(src) : src}
{...props}
/>
);
// Loads right away rather than lazily, so images don't grow the page while it
// scrolls to a version and push the target away
function Image({ src, ...props }: ComponentProps<"img">) {
const resolved = src && isExternalImage(src) ? docImageUrl(src) : src;
return <img {...props} className={styles.image} src={resolved} />;
}
export function Markdown({ children }: MarkdownProps) {
export function Markdown({ content }: MarkdownProps) {
return (
<MarkdownToJSX
options={{
overrides: {
a: { component: Link },
table: { component: Table.Root },
thead: { component: Table.Header },
tbody: { component: Table.Body },
tr: { component: Table.Row },
th: { component: Table.ColumnHeaderCell },
td: { component: Table.Cell },
img: { component: Image },
},
}}
>
{children}
</MarkdownToJSX>
<div className={styles.markdown}>
<MarkdownToJSX
options={{
wrapper: Fragment,
overrides: {
h1: {
component: Heading,
props: { size: "2", className: styles["heading-1"] },
},
h2: {
component: Heading,
props: { size: "4", className: styles["heading-2"] },
},
h3: {
component: Heading,
props: { size: "5", className: styles["heading-3"] },
},
p: { component: Text },
ul: { props: { className: styles.list } },
ol: { props: { className: styles.list } },
code: { component: Code },
a: { component: Link },
table: { component: Table.Root },
thead: { component: Table.Head },
tbody: { component: Table.Body },
tr: { component: Table.Row },
th: { component: Table.ColumnHeader },
td: { component: Table.Cell },
img: { component: Image },
},
}}
>
{content}
</MarkdownToJSX>
</div>
);
}
@@ -1,31 +1,18 @@
<script>
import { App, ReduceMotion } from "../stores/app";
import {
reducedMotionMedia,
reducesMotion,
} from "../core/blitzkit/reducesMotion";
import { App } from "../stores/app";
// Runs before hydration so nothing animates before the setting applies
const root = document.documentElement;
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
function apply() {
let reduceMotion: boolean;
switch (App.state.reduceMotion) {
case ReduceMotion.Device:
reduceMotion = media.matches;
break;
case ReduceMotion.On:
reduceMotion = true;
break;
case ReduceMotion.Off:
reduceMotion = false;
break;
}
root.dataset.reduceMotion = `${reduceMotion}`;
root.dataset.reduceMotion = `${reducesMotion()}`;
}
apply();
media.addEventListener("change", apply);
reducedMotionMedia.addEventListener("change", apply);
App.on((state) => state.reduceMotion, apply);
</script>
@@ -1,2 +1,7 @@
.separator {
flex-shrink: 0;
height: var(--space-0);
background-color: var(--gray-a4);
}
-1
View File
@@ -83,7 +83,6 @@ export const tools: Record<string, Tool> = {
banner_background_position: "bottom",
},
changelogs: {
disabled: true,
id: "changelogs",
banner_background_position: "bottom",
},
@@ -0,0 +1,45 @@
import { compareVersions } from "compare-versions";
import { git } from "./git";
export interface Changelog {
// The leading "# " heading, split out so pages can lay it out themselves
title: string;
content: string;
// When the changelog was committed under its version, missing until it is
date: Date | undefined;
}
const ROOT = "../../../../../docs/changelogs/";
const files = import.meta.glob<string>("../../../../../docs/changelogs/*.md", {
eager: true,
query: "?raw",
import: "default",
});
const entries = await Promise.all(
Object.entries(files).map(async ([file, markdown]) => {
const version = file.replace(ROOT, "").replace(".md", "");
// The oldest add or rename, so a promoted version dates from its promotion
const log = await git.raw([
"log",
"--follow",
"--diff-filter=AR",
"--format=%aI",
"--",
`docs/changelogs/${version}.md`,
]);
const added = log.trim().split("\n").at(-1);
const date = added ? new Date(added) : undefined;
const lineEnd = markdown.indexOf("\n");
const title = markdown.slice("# ".length, lineEnd).trim();
const content = markdown.slice(lineEnd + 1);
return [version, { title, content, date } satisfies Changelog] as const;
}),
);
// Every changelog keyed by version, newest first
export const changelogs = new Map(
entries.sort(([a], [b]) => compareVersions(b, a)),
);
@@ -0,0 +1,7 @@
import { simpleGit } from "simple-git";
const repository = (await simpleGit().revparse(["--show-toplevel"])).trim();
// Runs from the repository root, so paths are relative to it wherever this is
// imported from. Server only: it spawns git processes
export const git = simpleGit(repository);
@@ -1,4 +1,4 @@
import { Quicklime } from 'quicklime';
import { Quicklime } from "quicklime";
export interface ModelTransformEventData {
yaw: number;
+1 -1
View File
@@ -1,4 +1,4 @@
import { EventManager } from '@blitzkit/core';
import { EventManager } from "@blitzkit/core";
export enum Pose {
HullDown,
@@ -0,0 +1,20 @@
import { App, ReduceMotion } from "../../stores/app";
// The device preference, followed when the setting is left on Device
export const reducedMotionMedia = window.matchMedia(
"(prefers-reduced-motion: reduce)",
);
// Whether motion is reduced, following the device when the setting says to
export function reducesMotion() {
switch (App.state.reduceMotion) {
case ReduceMotion.Device:
return reducedMotionMedia.matches;
case ReduceMotion.On:
return true;
case ReduceMotion.Off:
return false;
}
}
@@ -0,0 +1,15 @@
---
import Changelog from "../../../../components/Changelog.astro";
import ToolBanner from "../../../../components/ToolBanner.astro";
import { tools } from "../../../../config/tools";
import BaseLayout from "../../../../layouts/BaseLayout.astro";
export { getStaticPaths } from "../index.astro";
const { locale } = Astro.props;
---
<BaseLayout tool={tools.changelogs} accent="bronze" {locale}>
<ToolBanner tool={tools.changelogs} {locale} />
<Changelog {locale} />
</BaseLayout>
@@ -1,36 +0,0 @@
---
import { readFile } from "fs/promises";
import { mixStaticPaths } from "../../../../../../core/blitzkit/mixStaticPaths";
import { tools } from "../../../../../../config/tools";
import BaseLayout from "../../../../../../layouts/BaseLayout.astro";
import { getStaticPaths as _getStaticPaths } from "../../../index.astro";
import { Page } from "./_index";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
const ROOT = "../../../../../../../../../docs/";
const files = import.meta.glob("../../../../../../../../../docs/**/*.md", {
eager: true,
});
return await Promise.all(
Object.keys(files).map(async (file) => {
const couple = file.replace(ROOT, "").split("/");
couple[1] = couple[1].replace(".md", "");
const content = await readFile(
`../../docs/${couple[0]}/${couple[1]}.md`,
).then((buffer) => buffer.toString());
return {
params: { directory: couple[0], document: couple[1] },
props: { content },
};
}),
);
});
const { content, locale } = Astro.props;
---
<BaseLayout tool={tools.home} {locale}>
<Page content={content} />
</BaseLayout>
@@ -1,14 +0,0 @@
import { Markdown } from "../../../../../../components/Markdown";
import { PageWrapper } from "../../../../../../components/PageWrapper";
interface PageProps {
content: string;
}
export function Page({ content }: PageProps) {
return (
<PageWrapper maxWidth="50rem">
<Markdown>{content}</Markdown>
</PageWrapper>
);
}
@@ -1,52 +0,0 @@
---
import { MagicWandIcon, StarFilledIcon } from "@radix-ui/react-icons";
import { Flex, Heading, Link } from "@radix-ui/themes";
import { compareVersions } from "compare-versions";
import { PageWrapper } from "../../../../../components/PageWrapper";
import { tools } from "../../../../../config/tools";
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
export { getStaticPaths } from "../../index.astro";
// this can't be used in template literal :(
const ROOT = "../../../../../../../../docs/changelogs/";
const { locale } = Astro.props;
const versions = Object.keys(
import.meta.glob("../../../../../../../../docs/changelogs/*.md", {
eager: true,
}),
)
.map((file) => file.replace(ROOT, "").replace(".md", ""))
.sort(compareVersions)
.reverse();
---
<BaseLayout tool={tools.changelogs} {locale}>
<PageWrapper align="center">
<Heading mt="6" mb="4">BlitzKit patches</Heading>
<Flex direction="column" gap="2" align="center">
{
versions.map((version) => {
const split = version.split(".").map(Number);
const isMajor = split[2] === 0;
return (
<Link
size="5"
href={`/docs/changelogs/${version}`}
mb={isMajor ? "6" : "0"}
>
<Flex align="center" gap="2">
{!isMajor && <MagicWandIcon />}
{isMajor && <StarFilledIcon />}
{version}
</Flex>
</Link>
);
})
}
</Flex>
</PageWrapper>
</BaseLayout>