Compare commits

..
7 Commits
Author SHA1 Message Date
encie22 809e51bae0 Fix whitespace issues due to JSX whitespace change, small deploy improvements
Build and Deploy to Web Server / deploy (push) Successful in 10m18s
2026-10-16 14:47:11 +10:30
encie22 70bf783ca8 Hide duplicated awards from accessibility readers, disallow API routes, fix footer re-run
Build and Deploy to Web Server / deploy (push) Successful in 10m25s
2026-10-16 13:24:08 +10:30
encie22 e21219aba6 Tidy icon noise, URL strings, and null guards
Build and Deploy to Web Server / deploy (push) Successful in 7m8s
2026-10-16 13:08:26 +10:30
encie22 a2dea4b210 Harden contact throttle, logging, TLS, and transporter reuse 2026-10-16 12:58:29 +10:30
encie22 2001963035 Reset carousels on page load, tidy navbar state across transitions, proper preloading for carousels 2026-10-16 12:32:07 +10:30
encie22 57c906082f Harden player against shell re-creation with an empty queue guard 2026-10-16 09:33:18 +10:30
encie22 af8f99feb0 Only hero images for CTA carousels, honour reduced motion 2026-10-16 09:17:58 +10:30
16 changed files with 204 additions and 58 deletions

No files matched your search

+8 -2
View File
@@ -22,7 +22,9 @@ jobs:
path: |
node_modules/.astro/
node_modules/.vite/
key: ${{ runner.os }}-buildcache
key: ${{ runner.os }}-buildcache-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-buildcache-
- name: Setup Node
uses: actions/setup-node@v5
@@ -33,11 +35,15 @@ jobs:
- name: Install
shell: "bash"
working-directory: .
run: npm install
run: npm ci
- name: Build
shell: "bash"
working-directory: .
env:
# Bound libuv/sharp thread usage: the builder is small and
# full parallelism OOMs it. Raise if the host grows.
UV_THREADPOOLSIZE: 4
run: npm run build
- name: Set up SSH
+14 -1
View File
@@ -32,7 +32,20 @@ export default defineConfig({
}
},
integrations: [icon(), mdx(), sitemap(), robotsTxt()],
integrations: [
icon(),
mdx(),
sitemap(),
robotsTxt({
policy: [
{
userAgent: "*",
allow: "/",
disallow: "/api/"
}
]
})
],
markdown: {
shikiConfig: {
+1
View File
@@ -86,6 +86,7 @@ const { id: ID = "contact-form" } = Astro.props;
const loadingIcon = form.querySelector(
`#${CSS.escape(ID + "-loading-icon")}`
);
if (!responseMsg || !button || !loadingIcon) return;
form.addEventListener("submit", async function (event) {
event.preventDefault();
+4 -1
View File
@@ -62,5 +62,8 @@ import TextLink from "@components/TextLink.astro";
</footer>
<script is:inline data-astro-rerun>
document.getElementById("footer-year").innerText = new Date().getFullYear();
{
const year = document.getElementById("footer-year");
if (year) year.innerText = new Date().getFullYear();
}
</script>
+50 -9
View File
@@ -20,6 +20,7 @@ interface Props {
quality?: number;
height?: number;
shuffle?: boolean;
eagerCount?: number;
}
const {
@@ -37,10 +38,14 @@ const {
foregroundOpacity = "opacity-50",
quality = "80",
height,
shuffle = false
shuffle = false,
eagerCount = 2
} = Astro.props as Props;
const imagesArray = shuffle ? shuffleArray(images) : images;
// Slides kept in the layout (first visible, rest preloaded) so their eager loads actually fire; anything past this stays hidden until its turn.
const preloadCount = Math.max(eagerCount, 2);
---
<div class:list={[className, "relative overflow-hidden"]}>
@@ -58,13 +63,13 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
transitionStyle,
transitionDuration,
index > 0 ? "opacity-0" : "",
index < 2 ? "" : "hidden"
index < preloadCount ? "" : "hidden"
]}
src={image}
alt={
typeof altText === "function" ? altText(index) : (altText ?? "")
}
loading={index < 2 ? "eager" : "lazy"}
loading={index < eagerCount ? "eager" : "lazy"}
aria-hidden={index === 0 ? "false" : "true"}
layout="full-width"
fit="cover"
@@ -87,21 +92,53 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
</div>
<script
define:vars={{ imageCount: imagesArray.length, carouselId: id, interval }}
define:vars={{
imageCount: imagesArray.length,
carouselId: id,
interval,
preloadCount
}}
>
let currentIndex = 0;
window.__carousels = window.__carousels || {};
setInterval(() => {
// Reset the carousel and (re)start it. Runs on initial load and after
// every page transition, so navigation always restarts the fade sequence.
function initCarousel() {
const state = (window.__carousels[carouselId] = window.__carousels[
carouselId
] || { index: 0, timer: null });
state.index = 0;
if (state.timer) {
clearInterval(state.timer);
state.timer = null;
}
const slides = Array.from(
document.querySelectorAll(`[data-id^="${carouselId}-"]`)
);
slides.forEach((slide, index) => {
slide.classList.toggle("opacity-0", index !== 0);
slide.classList.toggle("hidden", index >= preloadCount);
slide.setAttribute("aria-hidden", index === 0 ? "false" : "true");
});
// Honour reduced-motion: leave the first image showing, no rotation.
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
state.timer = setInterval(() => {
const current = document.querySelectorAll(
`[data-id="${carouselId}-${currentIndex}"]`
`[data-id="${carouselId}-${state.index}"]`
)[0];
const nextIndex = (currentIndex + 1) % imageCount;
const nextIndex = (state.index + 1) % imageCount;
const next = document.querySelectorAll(
`[data-id="${carouselId}-${nextIndex}"]`
)[0];
if (!current || !next) return;
// Wait until the incoming image has loaded, or the fade pops in.
if (next.tagName === "IMG" && !next.complete) return;
// Fade out current, fade in next
current.classList.add("opacity-0");
current.setAttribute("aria-hidden", "true");
@@ -119,6 +156,10 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
preloadImage.setAttribute("aria-hidden", "true");
}
currentIndex = nextIndex;
state.index = nextIndex;
}, interval);
}
document.addEventListener("astro:page-load", initCarousel);
initCarousel();
</script>
+5 -1
View File
@@ -64,7 +64,7 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
<div class="md:hidden">
<button
id="menu-toggle"
class="text-2xl focus:outline-none"
class="focus-visible:ring-primary text-2xl focus:outline-none focus-visible:ring-2"
aria-label="Toggle navigation menu"
aria-expanded="false"
aria-controls="mobile-menu"
@@ -139,6 +139,10 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
nav = document.getElementById("nav");
toggle = document.getElementById("menu-toggle");
// The nav persists across transitions: always start with a closed menu.
nav?.setAttribute("data-mobile-menu", "hidden");
toggle?.setAttribute("aria-expanded", "false");
if (toggle && !toggle.dataset.bound) {
toggle.dataset.bound = "true";
toggle.addEventListener("click", () => {
+41 -5
View File
@@ -171,12 +171,14 @@ const playerArtworkOpacity = 0.4;
</span>
</div>
</div>
<div class="flex flex-grow flex-col text-sm">
<div class="flex min-w-0 flex-grow flex-col text-sm">
<span
id="player:metadata:title"
class="w-full text-right font-semibold"></span>
<span id="player:metadata:subtitle" class="w-full text-right"></span>
<span id="player:metadata:extra" class="w-full text-right"></span>
class="w-full truncate text-right font-semibold"></span>
<span id="player:metadata:subtitle" class="w-full truncate text-right"
></span>
<span id="player:metadata:extra" class="w-full truncate text-right"
></span>
</div>
</div>
</div>
@@ -404,6 +406,13 @@ const playerArtworkOpacity = 0.4;
this.RING_C = 182.2; // 2 * PI * 29, must match dasharray in markup
if (!this.playlist.length) {
// Nothing to play: hide the shell instead of crashing below.
$("player-shell")?.style.setProperty("display", "none");
$("player:spacer")?.style.setProperty("display", "none");
return;
}
this.UI = {
root: $("player-shell"),
spacer: $("player:spacer"),
@@ -925,6 +934,7 @@ const playerArtworkOpacity = 0.4;
}
addToQueue(track, immediatePlay = false) {
if (!this.playlist.length) return;
var current = this.playlist[this.index];
if (
@@ -946,13 +956,39 @@ const playerArtworkOpacity = 0.4;
if (!window.playerIsInitialised) {
window.player = new Player(initialQueue);
} else {
// View-transition restore: re-grab nodes and re-apply.
// View-transition restore: re-grab every node without re-binding listeners (they persist with the shell), then re-apply.
try {
const p = window.player;
p.UI.root = $("player-shell");
p.UI.spacer = $("player:spacer");
p.UI.full = document.querySelector("#player-shell .player-full");
p.UI.face = document.querySelector("#player-shell .player-face");
p.UI.controls.play = $("player:controls:play");
p.UI.controls.pause = $("player:controls:pause");
p.UI.controls.previous = $("player:controls:previous");
p.UI.controls.next = $("player:controls:next");
p.UI.controls.minimise = $("player:controls:minimise");
p.UI.controls.mute = $("player:controls:mute");
p.UI.controls.volumeOn = $("player:controls:volume-on");
p.UI.controls.volumeOff = $("player:controls:volume-off");
p.UI.controls.volume = $("player:controls:volume");
p.UI.times.current = $("player:times:current");
p.UI.times.duration = $("player:times:duration");
p.UI.metadata.title = $("player:metadata:title");
p.UI.metadata.subtitle = $("player:metadata:subtitle");
p.UI.metadata.extra = $("player:metadata:extra");
p.UI.progress.bar = $("player:time:progress");
p.UI.progress.buffered = $("player:time:progress:buffered");
p.UI.progress.played = $("player:time:progress:played");
p.UI.artwork.background = $("player:artwork:background");
p.UI.faceArtwork.img = $("player:face:artwork");
p.UI.faceArtwork.fallback = $("player:face:fallback");
p.UI.faceProgress.buffered = $("player:face:progress:buffered");
p.UI.faceProgress.played = $("player:face:progress:played");
p.UI.faceControls.toggle = $("player:face:controls:toggle");
p.UI.faceControls.play = $("player:face:controls:play");
p.UI.faceControls.pause = $("player:face:controls:pause");
p.UI.faceControls.expand = $("player:face:controls:expand");
p.applyminimised();
} catch (e) {
/* ignore */
+1 -1
View File
@@ -171,7 +171,7 @@ const link = `/projects/${slugify(project.data.type)}/${slugify(project.data.slu
{project.data.keyFigure.map((figure) => {
return (
<div>
<span class="font-bold">{figure.title}:</span>
<span class="font-bold">{figure.title}: </span>
<span>
{figure.href && (
<TextLink href={figure.href}>{figure.name}</TextLink>
+3 -2
View File
@@ -7,6 +7,7 @@ interface Props {
}
const { title, description, url = Astro.url, image } = Astro.props;
const canonicalUrl = url.toString();
import person from "@data/person";
import site from "@data/site";
@@ -15,7 +16,7 @@ import { Schema } from "astro-seo-schema";
---
<!-- SEO -->
<link rel="canonical" href={url} />
<link rel="canonical" href={canonicalUrl} />
<meta name="robots" content="index, follow" />
<Schema
item={{
@@ -65,7 +66,7 @@ import { Schema } from "astro-seo-schema";
<meta property="og:site_name" content={site.title} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={url} />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:type" content="website" />
<meta
property="og:image"
+1 -1
View File
@@ -28,7 +28,7 @@ const linkIsExternal: boolean =
{...attrs}
><span class="group-hover:text-primary-600"><slot /></span>{
includeExternalLinkIcon && linkIsExternal && (
<sup class="ml-0.5 inline-block">
<sup class="ml-0.5 inline-block" aria-hidden="true">
<Icon
name="mdi:external-link"
class:list={[
+1 -1
View File
@@ -26,7 +26,7 @@ import MainHead from "@layouts/MainHead.astro";
<!doctype html>
<html lang="en">
<MainHead {title} {subtitle} {description} {image} />
<body class="flex min-h-svh flex-col">
<body class="flex min-h-svh flex-col overflow-x-clip">
<Navbar {navbarDisplay} />
<main class="grow bg-white dark:bg-gray-950">
<slot />
+26 -11
View File
@@ -1,4 +1,4 @@
import { createTransport } from "nodemailer";
import { createTransport, type Transporter } from "nodemailer";
import SMTPTransport from "nodemailer/lib/smtp-transport";
import type { Options } from "nodemailer/lib/mailer";
@@ -24,6 +24,27 @@ export function constructEmailHtml(props: Email) {
return `<div>${escapeHtml(props.message)}</div>`;
}
// Cached for the process lifetime: config comes from the environment and
// does not change between requests.
let cachedTransporter: Transporter | null = null;
function getTransporter(port: number, secure: boolean): Transporter {
if (!cachedTransporter) {
cachedTransporter = createTransport({
host: process.env.EMAIL_HOST || import.meta.env.EMAIL_HOST,
port,
secure,
// Refuse plaintext fallback on submission ports (e.g. 587, 2525).
requireTLS: !secure,
auth: {
user: process.env.EMAIL_USER || import.meta.env.EMAIL_USER,
pass: process.env.EMAIL_PASS || import.meta.env.EMAIL_PASS
}
} as SMTPTransport.Options);
}
return cachedTransporter;
}
export default async function sendContactEmail(props: Email) {
const port = parseInt(
process.env.EMAIL_PORT || import.meta.env.EMAIL_PORT || "",
@@ -35,17 +56,11 @@ export default async function sendContactEmail(props: Email) {
throw new Error("Email transport is not configured.");
}
const transporter = createTransport({
host: process.env.EMAIL_HOST || import.meta.env.EMAIL_HOST,
port,
secure:
const secure =
process.env.EMAIL_SECURE === "true" ||
import.meta.env.EMAIL_SECURE === "true",
auth: {
user: process.env.EMAIL_USER || import.meta.env.EMAIL_USER,
pass: process.env.EMAIL_PASS || import.meta.env.EMAIL_PASS
}
} as SMTPTransport.Options);
import.meta.env.EMAIL_SECURE === "true";
const transporter = getTransporter(port, secure);
if (!props.html) {
props.html = constructEmailHtml(props);
+19 -5
View File
@@ -20,10 +20,19 @@ function isRateLimited(ip: string): boolean {
(t) => now - t < RATE_WINDOW_MS
);
if (history.length >= RATE_MAX) {
recentSends.set(ip, history);
return true;
}
history.push(now);
recentSends.set(ip, history);
// Prune expired entries so the map cannot grow without bound.
if (recentSends.size > 500) {
for (const [key, times] of recentSends) {
if (!times.some((t) => now - t < RATE_WINDOW_MS)) {
recentSends.delete(key);
}
}
}
return false;
}
@@ -36,10 +45,8 @@ function json(message: string, status: number, statusText: string): Response {
}
export const POST: APIRoute = async ({ request, clientAddress }) => {
const ip =
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ||
clientAddress ||
"unknown";
// Prefer the socket address: x-forwarded-for is client-controlled.
const ip = clientAddress || "unknown";
if (isRateLimited(ip)) {
return json(
"Too many messages sent. Please try again later.",
@@ -48,7 +55,13 @@ export const POST: APIRoute = async ({ request, clientAddress }) => {
);
}
const data = await request.formData();
let data: FormData;
try {
data = await request.formData();
} catch (error) {
console.error("Contact form parse failed:", error);
return json("Invalid request.", 400, "Bad Request");
}
const email = (data.get("email") as string | null)?.trim() ?? "";
const subject = (data.get("subject") as string | null)?.trim() ?? "";
const message = (data.get("message") as string | null)?.trim() ?? "";
@@ -86,6 +99,7 @@ export const POST: APIRoute = async ({ request, clientAddress }) => {
html
});
} catch (error) {
console.error("Contact email failed to send:", error);
return json(
`Message failed to send with an internal server error. Please contact me directly via a method below.`,
500,
+6 -2
View File
@@ -25,13 +25,17 @@ import { Icon } from "astro-icon/components";
<SectionTitle>Other ways to reach me</SectionTitle>
<div class="grid grid-cols-1 text-lg md:grid-cols-2">
<div class="col-span-1 flex flex-col items-center justify-center p-4">
<Icon name="fa7-solid:at" class="text-4xl" />
<Icon name="fa7-solid:at" class="text-4xl" aria-hidden="true" />
<TextLink href="mailto:nathan@nathancummins.com.au" class="mt-4"
>nathan@nathancummins.com.au</TextLink
>
</div>
<div class="col-span-1 flex flex-col items-center justify-center p-4">
<Icon name="fa7-solid:envelope" class="text-4xl" />
<Icon
name="fa7-solid:envelope"
class="text-4xl"
aria-hidden="true"
/>
<Paragraph class="my-0 mt-4"
>PO Box 2112 Regency Park SA 5942</Paragraph
>
+23 -15
View File
@@ -17,28 +17,28 @@ import { Image } from "astro:assets";
import { Icon } from "astro-icon/components";
import { convertEagerImagesImportGlobToArray } from "@lib/utils";
import {
convertEagerImagesImportGlobToArray,
getProjectHero
} from "@lib/utils";
const heroImages = import.meta.glob<{ default: ImageMetadata; eager: true }>(
"../assets/img/hero/*"
);
const heroImagesArray = await convertEagerImagesImportGlobToArray(heroImages);
const imagesForCTA = import.meta.glob<{ default: ImageMetadata; eager: true }>([
"../assets/img/hero/*",
"../assets/img/project-heros/*",
"../assets/img/projects/**"
]);
const imagesForCTAArray =
await convertEagerImagesImportGlobToArray(imagesForCTA);
const projects = (
await getCollection("projects", ({ data }) => data.frontPage)
).sort(
(a, b) => (a.data.frontPage?.order || 0) - (b.data.frontPage?.order || 1)
);
// Curated carousel set: site heroes + heroes of featured projects only, instead of every image in the repo. Shared by both CTA carousels.
const imagesForCTAArray = [
...heroImagesArray,
...projects.map((project) => getProjectHero(project))
];
const awards = (await getCollection("awards")).sort(
(a, b) => b.data.date.valueOf() - a.data.date.valueOf()
);
@@ -53,7 +53,7 @@ const tracks = (
---
<MainLayout navbarDisplay="transparent">
<div class="h-screen w-full flex-row">
<div class="min-h-svh w-full flex-row">
<div class="absolute inset-0 h-full w-full bg-black">
<ImageCarousel
id="hero"
@@ -68,8 +68,7 @@ const tracks = (
<h1
class="font-header pb-8 text-5xl font-medium text-white uppercase text-shadow-lg/75 md:text-7xl lg:text-9xl"
>
{person.names.first}
{person.names.last}
{person.names.first}{" "}{person.names.last}
</h1>
<h2
class="font-header text-2xl font-medium text-gray-300 uppercase text-shadow-lg/75 md:text-2xl lg:text-4xl"
@@ -120,6 +119,7 @@ const tracks = (
quality={5}
height={192}
shuffle={true}
eagerCount={4}
><div class="flex h-full w-full items-center">
<a
href="/contact/"
@@ -185,8 +185,15 @@ const tracks = (
class="animate-scrolling-awards m-0 mx-auto flex max-w-md flex-col space-y-8 p-0"
>
{
awardsDoubled.map((award) => {
return <AwardCard award={award} />;
awardsDoubled.map((award, index) => {
// Second copy only feeds the scrolling loop: hide it from assistive tech so awards are not announced twice.
return index < awards.length ? (
<AwardCard award={award} />
) : (
<span aria-hidden="true" class="block">
<AwardCard award={award} />
</span>
);
})
}
</div>
@@ -207,6 +214,7 @@ const tracks = (
quality={5}
height={384}
shuffle={true}
eagerCount={4}
/>
</div>
</section>
+1 -1
View File
@@ -94,7 +94,7 @@ import P from "@components/MDX/P.astro";
{project.data.keyFigure.map((figure) => {
return (
<div>
<span class="font-bold">{figure.title}:</span>
<span class="font-bold">{figure.title}: </span>
<span>
{figure.href && (
<TextLink href={figure.href}>