Compare commits

..
13 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
encie22 70af555189 Polish SEO tags, fix dead classes, and tidy small accessibility details
Build and Deploy to Web Server / deploy (push) Successful in 14m7s
2026-10-15 17:41:26 +10:30
encie22 a346bd8064 Slim carousel page weight, with stable per-instance slide IDs
Build and Deploy to Web Server / deploy (push) Failing after 19m10s
2026-10-15 17:29:35 +10:30
encie22 da65d52319 Add a volume slider with mute toggle to the player controls 2026-10-15 17:17:19 +10:30
encie22 4624fe722b Make player controls keyboard-operable, with slider seeking, pre-play seeks, and an expand button 2026-10-15 15:58:47 +10:30
encie22 f5d2b417e6 Make track cards, track links, and project filters keyboard-operable 2026-10-15 15:30:24 +10:30
encie22 b75f17e604 Harden email setup 2026-10-15 15:21:17 +10:30
26 changed files with 1106 additions and 2624 deletions

No files matched your search

+8 -2
View File
@@ -22,7 +22,9 @@ jobs:
path: | path: |
node_modules/.astro/ node_modules/.astro/
node_modules/.vite/ node_modules/.vite/
key: ${{ runner.os }}-buildcache key: ${{ runner.os }}-buildcache-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-buildcache-
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v5 uses: actions/setup-node@v5
@@ -33,11 +35,15 @@ jobs:
- name: Install - name: Install
shell: "bash" shell: "bash"
working-directory: . working-directory: .
run: npm install run: npm ci
- name: Build - name: Build
shell: "bash" shell: "bash"
working-directory: . 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 run: npm run build
- name: Set up SSH - 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: { markdown: {
shikiConfig: { shikiConfig: {
+480 -2461
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -86,6 +86,7 @@ const { id: ID = "contact-form" } = Astro.props;
const loadingIcon = form.querySelector( const loadingIcon = form.querySelector(
`#${CSS.escape(ID + "-loading-icon")}` `#${CSS.escape(ID + "-loading-icon")}`
); );
if (!responseMsg || !button || !loadingIcon) return;
form.addEventListener("submit", async function (event) { form.addEventListener("submit", async function (event) {
event.preventDefault(); event.preventDefault();
+4 -1
View File
@@ -62,5 +62,8 @@ import TextLink from "@components/TextLink.astro";
</footer> </footer>
<script is:inline data-astro-rerun> <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> </script>
+60 -19
View File
@@ -6,6 +6,7 @@ import { shuffleArray } from "@lib/utils";
interface Props { interface Props {
images: Array<ImageMetadata>; images: Array<ImageMetadata>;
id?: string;
class: string; class: string;
altText?: string | ((index: number) => string); altText?: string | ((index: number) => string);
interval?: number; interval?: number;
@@ -19,10 +20,12 @@ interface Props {
quality?: number; quality?: number;
height?: number; height?: number;
shuffle?: boolean; shuffle?: boolean;
eagerCount?: number;
} }
const { const {
images, images,
id = "carousel",
class: className, class: className,
altText = null, altText = null,
interval = 5000, interval = 5000,
@@ -35,12 +38,14 @@ const {
foregroundOpacity = "opacity-50", foregroundOpacity = "opacity-50",
quality = "80", quality = "80",
height, height,
shuffle = false shuffle = false,
eagerCount = 2
} = Astro.props as Props; } = Astro.props as Props;
const IDs: string[] = [];
const imagesArray = shuffle ? shuffleArray(images) : images; 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"]}> <div class:list={[className, "relative overflow-hidden"]}>
@@ -50,24 +55,21 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
{ {
imagesArray.map((image, index) => { imagesArray.map((image, index) => {
const ID = `image-carousel-${Math.random().toString(36)}`;
IDs.push(ID);
return ( return (
<Image <Image
data-id={`${ID}`} data-id={`${id}-${index}`}
class:list={[ class:list={[
"absolute !h-full w-full object-cover object-center transition-opacity", "absolute !h-full w-full object-cover object-center transition-opacity",
transitionStyle, transitionStyle,
transitionDuration, transitionDuration,
index > 0 ? "opacity-0" : "", index > 0 ? "opacity-0" : "",
index < 2 ? "" : "hidden" index < preloadCount ? "" : "hidden"
]} ]}
src={image} src={image}
alt={ alt={
typeof altText === "function" ? altText(index) : (altText ?? "") typeof altText === "function" ? altText(index) : (altText ?? "")
} }
loading={index < 2 ? "eager" : "lazy"} loading={index < eagerCount ? "eager" : "lazy"}
aria-hidden={index === 0 ? "false" : "true"} aria-hidden={index === 0 ? "false" : "true"}
layout="full-width" layout="full-width"
fit="cover" fit="cover"
@@ -89,19 +91,54 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
<slot /> <slot />
</div> </div>
<script define:vars={{ imagesArray, interval, IDs }}> <script
let currentIndex = 0; define:vars={{
imageCount: imagesArray.length,
carouselId: id,
interval,
preloadCount
}}
>
window.__carousels = window.__carousels || {};
setInterval(() => { // Reset the carousel and (re)start it. Runs on initial load and after
const total = imagesArray.length; // 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( const current = document.querySelectorAll(
`[data-id="${IDs[currentIndex]}"]` `[data-id="${carouselId}-${state.index}"]`
)[0];
const nextIndex = (state.index + 1) % imageCount;
const next = document.querySelectorAll(
`[data-id="${carouselId}-${nextIndex}"]`
)[0]; )[0];
const nextIndex = (currentIndex + 1) % total;
const next = document.querySelectorAll(`[data-id="${IDs[nextIndex]}"]`)[0];
if (!current || !next) return; 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 // Fade out current, fade in next
current.classList.add("opacity-0"); current.classList.add("opacity-0");
current.setAttribute("aria-hidden", "true"); current.setAttribute("aria-hidden", "true");
@@ -109,9 +146,9 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
next.classList.remove("opacity-0", "hidden"); next.classList.remove("opacity-0", "hidden");
next.setAttribute("aria-hidden", "false"); next.setAttribute("aria-hidden", "false");
const preloadIndex = (nextIndex + 1) % total; const preloadIndex = (nextIndex + 1) % imageCount;
const preloadImage = document.querySelectorAll( const preloadImage = document.querySelectorAll(
`[data-id="${IDs[preloadIndex]}"]` `[data-id="${carouselId}-${preloadIndex}"]`
)[0]; )[0];
if (preloadImage) { if (preloadImage) {
preloadImage.classList.add("opacity-0"); preloadImage.classList.add("opacity-0");
@@ -119,6 +156,10 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
preloadImage.setAttribute("aria-hidden", "true"); preloadImage.setAttribute("aria-hidden", "true");
} }
currentIndex = nextIndex; state.index = nextIndex;
}, interval); }, interval);
}
document.addEventListener("astro:page-load", initCarousel);
initCarousel();
</script> </script>
+6 -2
View File
@@ -50,8 +50,12 @@ const copyID = Math.random().toString(36);
} }
{title && <p>{title}</p>} {title && <p>{title}</p>}
</div> </div>
<button class="font-bold" id=`copy-${copyID}`> <button
Copy <Icon name="mdi:content-copy" class="ml-0.5 inline-block" /> type="button"
aria-label="Copy code to clipboard"
class="font-bold"
id=`copy-${copyID}`
>Copy <Icon name="mdi:content-copy" class="ml-0.5 inline-block" />
</button> </button>
</div> </div>
</div> </div>
+5 -1
View File
@@ -64,7 +64,7 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
<div class="md:hidden"> <div class="md:hidden">
<button <button
id="menu-toggle" 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-label="Toggle navigation menu"
aria-expanded="false" aria-expanded="false"
aria-controls="mobile-menu" aria-controls="mobile-menu"
@@ -139,6 +139,10 @@ const { navbarDisplay = "normal" } = Astro.props as Props;
nav = document.getElementById("nav"); nav = document.getElementById("nav");
toggle = document.getElementById("menu-toggle"); 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) { if (toggle && !toggle.dataset.bound) {
toggle.dataset.bound = "true"; toggle.dataset.bound = "true";
toggle.addEventListener("click", () => { toggle.addEventListener("click", () => {
+302 -49
View File
@@ -35,7 +35,7 @@ const initialQueue = await Promise.all(
}) })
); );
const playerArtworkBlur = "10px"; const playerArtworkBlur = "15px";
const playerArtworkOpacity = 0.4; const playerArtworkOpacity = 0.4;
--- ---
@@ -62,6 +62,12 @@ const playerArtworkOpacity = 0.4;
</div> </div>
<div <div
id="player:time:progress" id="player:time:progress"
role="slider"
tabindex="0"
aria-label="Seek"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="0"
class="relative top-0 right-0 left-0 m-0 h-2 w-full rounded-t p-0 hover:cursor-pointer" class="relative top-0 right-0 left-0 m-0 h-2 w-full rounded-t p-0 hover:cursor-pointer"
> >
<div <div
@@ -89,8 +95,7 @@ const playerArtworkOpacity = 0.4;
title="Minimise player" title="Minimise player"
aria-label="Minimise player" aria-label="Minimise player"
class="col-span-1 rounded-full px-3 py-1 text-gray-400 hover:cursor-pointer hover:text-white" class="col-span-1 rounded-full px-3 py-1 text-gray-400 hover:cursor-pointer hover:text-white"
> ><Icon name="fa7-solid:chevron-down" class="pointer-events-none" />
<Icon name="fa7-solid:chevron-down" class="pointer-events-none" />
</button> </button>
<span id="player:times:duration" class="col-span-1 text-right" <span id="player:times:duration" class="col-span-1 text-right"
>0:00</span >0:00</span
@@ -99,28 +104,81 @@ const playerArtworkOpacity = 0.4;
<div <div
class="flex h-full flex-row items-center justify-center align-middle" class="flex h-full flex-row items-center justify-center align-middle"
> >
<div class="m-0 flex grow-0 flex-row space-x-2 p-0 text-3xl"> <div class="m-0 flex grow-0 flex-col p-0">
<span> <div class="mt-2 flex flex-row items-center space-x-4 text-2xl">
<Icon name="fa7-solid:backward" id="player:controls:previous" /> <button
</span> type="button"
<span> id="player:controls:previous"
<Icon name="fa7-solid:play" id="player:controls:play" /> aria-label="Previous track"
<Icon class="rounded-full bg-transparent p-0 hover:cursor-pointer"
name="fa7-solid:pause" ><Icon name="fa7-solid:backward" class="pointer-events-none" />
</button>
<button
type="button"
id="player:controls:play"
aria-label="Play"
class="rounded-full bg-transparent p-0 hover:cursor-pointer"
><Icon name="fa7-solid:play" class="pointer-events-none" />
</button>
<button
type="button"
id="player:controls:pause" id="player:controls:pause"
class="hidden" aria-label="Pause"
class="hidden rounded-full bg-transparent p-0 hover:cursor-pointer"
><Icon name="fa7-solid:pause" class="pointer-events-none" />
</button>
<button
type="button"
id="player:controls:next"
aria-label="Next track"
class="rounded-full bg-transparent p-0 hover:cursor-pointer"
><Icon name="fa7-solid:forward" class="pointer-events-none" />
</button>
</div>
<div
class="mt-3 hidden flex-row items-center space-x-2 pt-1 text-sm md:flex"
>
<span class="flex w-9 items-center justify-center">
<button
type="button"
id="player:controls:mute"
aria-label="Mute"
aria-pressed="false"
class="rounded-full bg-transparent p-0 hover:cursor-pointer"
>
<Icon
name="fa7-solid:volume-high"
id="player:controls:volume-on"
class="pointer-events-none"
/>
<Icon
name="fa7-solid:volume-xmark"
id="player:controls:volume-off"
class="pointer-events-none hidden"
/>
</button>
</span>
<span class="flex w-14 items-center md:w-16">
<input
type="range"
id="player:controls:volume"
aria-label="Volume"
min="0"
max="100"
value="100"
class="accent-primary w-full cursor-pointer"
/> />
</span> </span>
<span>
<Icon name="fa7-solid:forward" id="player:controls:next" />
</span>
</div> </div>
<div class="flex flex-grow flex-col text-sm"> </div>
<div class="flex min-w-0 flex-grow flex-col text-sm">
<span <span
id="player:metadata:title" id="player:metadata:title"
class="w-full text-right font-semibold"></span> class="w-full truncate text-right font-semibold"></span>
<span id="player:metadata:subtitle" class="w-full text-right"></span> <span id="player:metadata:subtitle" class="w-full truncate text-right"
<span id="player:metadata:extra" class="w-full text-right"></span> ></span>
<span id="player:metadata:extra" class="w-full truncate text-right"
></span>
</div> </div>
</div> </div>
</div> </div>
@@ -176,21 +234,26 @@ const playerArtworkOpacity = 0.4;
<button <button
id="player:face:controls:toggle" id="player:face:controls:toggle"
type="button" type="button"
title="Play / pause" title="Play"
aria-label="Play / pause" aria-label="Play"
class="absolute top-1/2 left-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white opacity-100 backdrop-blur-sm hover:cursor-pointer hover:bg-black/70 md:h-9 md:w-9 md:opacity-0 md:group-focus-within:opacity-100 md:group-hover:opacity-100" class="absolute top-1/2 left-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white opacity-100 backdrop-blur-sm hover:cursor-pointer hover:bg-black/70 md:h-9 md:w-9 md:opacity-0 md:group-focus-within:opacity-100 md:group-hover:opacity-100"
> ><Icon
<Icon
name="fa7-solid:play" name="fa7-solid:play"
id="player:face:controls:play" id="player:face:controls:play"
class="pointer-events-none text-sm drop-shadow" class="pointer-events-none text-sm drop-shadow"
/> /><Icon
<Icon
name="fa7-solid:pause" name="fa7-solid:pause"
id="player:face:controls:pause" id="player:face:controls:pause"
class="pointer-events-none hidden text-sm drop-shadow" class="pointer-events-none hidden text-sm drop-shadow"
/> />
</button> </button>
<button
id="player:face:controls:expand"
type="button"
aria-label="Expand player"
class="sr-only"
>Expand player
</button>
</div> </div>
</div> </div>
<div id="player:spacer" class:list={[height, "bg-gray-900"]}></div> <div id="player:spacer" class:list={[height, "bg-gray-900"]}></div>
@@ -237,6 +300,40 @@ const playerArtworkOpacity = 0.4;
display: none; display: none;
} }
/* Slim volume slider */
#player\:controls\:volume {
-webkit-appearance: none;
appearance: none;
background: transparent;
height: 12px;
}
#player\:controls\:volume::-webkit-slider-runnable-track {
height: 3px;
border-radius: 9999px;
background: rgba(255, 255, 255, 0.25);
}
#player\:controls\:volume::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
margin-top: -3.5px;
border-radius: 9999px;
background: #ff2d00;
}
#player\:controls\:volume::-moz-range-track {
height: 3px;
border-radius: 9999px;
background: rgba(255, 255, 255, 0.25);
}
#player\:controls\:volume::-moz-range-thumb {
width: 10px;
height: 10px;
border: none;
border-radius: 9999px;
background: #ff2d00;
}
/* Outgoing layer fades fast, incoming fades in late */ /* Outgoing layer fades fast, incoming fades in late */
.player-full { .player-full {
transition: transition:
@@ -301,9 +398,21 @@ const playerArtworkOpacity = 0.4;
this.playlist = window.player?.playlist ?? playlist; this.playlist = window.player?.playlist ?? playlist;
this.index = window.player?.index ?? 0; this.index = window.player?.index ?? 0;
this.minimised = window.player?.minimised ?? false; this.minimised = window.player?.minimised ?? false;
// Seek fraction requested before anything was loaded.
this.pendingSeek = null;
// Playback volume (0-1); restored from storage below.
this.volume = 1;
this.lastVolume = 1;
this.RING_C = 182.2; // 2 * PI * 29, must match dasharray in markup 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 = { this.UI = {
root: $("player-shell"), root: $("player-shell"),
spacer: $("player:spacer"), spacer: $("player:spacer"),
@@ -314,7 +423,11 @@ const playerArtworkOpacity = 0.4;
pause: $("player:controls:pause"), pause: $("player:controls:pause"),
previous: $("player:controls:previous"), previous: $("player:controls:previous"),
next: $("player:controls:next"), next: $("player:controls:next"),
minimise: $("player:controls:minimise") minimise: $("player:controls:minimise"),
mute: $("player:controls:mute"),
volumeOn: $("player:controls:volume-on"),
volumeOff: $("player:controls:volume-off"),
volume: $("player:controls:volume")
}, },
times: { times: {
current: $("player:times:current"), current: $("player:times:current"),
@@ -344,7 +457,8 @@ const playerArtworkOpacity = 0.4;
faceControls: { faceControls: {
toggle: $("player:face:controls:toggle"), toggle: $("player:face:controls:toggle"),
play: $("player:face:controls:play"), play: $("player:face:controls:play"),
pause: $("player:face:controls:pause") pause: $("player:face:controls:pause"),
expand: $("player:face:controls:expand")
} }
}; };
@@ -396,6 +510,25 @@ const playerArtworkOpacity = 0.4;
e.stopPropagation(); e.stopPropagation();
window.player.setminimised(true); window.player.setminimised(true);
}); });
this.UI.controls.mute.addEventListener("click", (e) => {
e.stopPropagation();
window.player.toggleMute();
});
this.UI.controls.volume.addEventListener("input", (e) => {
e.stopPropagation();
window.player.setVolume(e.target.value / 100);
});
try {
const stored = parseFloat(localStorage.getItem("player-volume"));
if (Number.isFinite(stored)) {
this.volume = Math.min(Math.max(stored, 0), 1);
this.lastVolume = this.volume > 0 ? this.volume : 1;
}
} catch (e) {
/* ignore */
}
this.syncVolumeUI();
this.UI.progress.bar.addEventListener("click", function (event) { this.UI.progress.bar.addEventListener("click", function (event) {
event.stopPropagation(); event.stopPropagation();
@@ -405,6 +538,34 @@ const playerArtworkOpacity = 0.4;
window.player.seek(Math.min(Math.max(per, 0), 1)); window.player.seek(Math.min(Math.max(per, 0), 1));
}); });
this.UI.progress.bar.addEventListener("keydown", (event) => {
if (
event.key !== "ArrowLeft" &&
event.key !== "ArrowRight" &&
event.key !== "Home" &&
event.key !== "End"
) {
return;
}
event.preventDefault();
event.stopPropagation();
const player = window.player;
const current = player.playlist[player.index];
if (!current) return;
const sound = current.howl;
const duration = sound?.duration() || 0 || current.duration || 0;
if (duration <= 0) return;
const position = sound
? sound.seek() || 0
: (player.pendingSeek ?? 0) * duration;
let target = position;
if (event.key === "ArrowLeft") target = position - 5;
if (event.key === "ArrowRight") target = position + 5;
if (event.key === "Home") target = 0;
if (event.key === "End") target = duration;
window.player.seek(duration > 0 ? target / duration : 0);
});
// Tap the circle to expand (not the play button). // Tap the circle to expand (not the play button).
const expand = (e) => { const expand = (e) => {
if (!window.player.minimised) return; if (!window.player.minimised) return;
@@ -414,12 +575,14 @@ const playerArtworkOpacity = 0.4;
) { ) {
return; return;
} }
if (e.type === "keydown" && e.key !== "Enter" && e.key !== " ") return;
e.preventDefault(); e.preventDefault();
window.player.setminimised(false); window.player.setminimised(false);
}; };
this.UI.root.addEventListener("click", expand); this.UI.root.addEventListener("click", expand);
this.UI.root.addEventListener("keydown", expand); this.UI.faceControls.expand.addEventListener("click", (e) => {
e.stopPropagation();
window.player.setminimised(false);
});
this.UI.faceControls.toggle.addEventListener("click", (e) => { this.UI.faceControls.toggle.addEventListener("click", (e) => {
e.stopPropagation(); e.stopPropagation();
const sound = window.player.playlist[window.player.index].howl; const sound = window.player.playlist[window.player.index].howl;
@@ -433,6 +596,38 @@ const playerArtworkOpacity = 0.4;
window.playerIsInitialised = true; window.playerIsInitialised = true;
} }
syncVolumeUI() {
Howler.volume(this.volume);
this.UI.controls.volume.value = String(Math.round(this.volume * 100));
const muted = this.volume <= 0;
this.UI.controls.volumeOn.classList.toggle("hidden", muted);
this.UI.controls.volumeOff.classList.toggle("hidden", !muted);
this.UI.controls.mute.setAttribute(
"aria-label",
muted ? "Unmute" : "Mute"
);
this.UI.controls.mute.setAttribute(
"aria-pressed",
muted ? "true" : "false"
);
try {
localStorage.setItem("player-volume", String(this.volume));
} catch (e) {
/* ignore */
}
}
setVolume(volume) {
if (!Number.isFinite(volume)) return;
this.volume = Math.min(Math.max(volume, 0), 1);
if (this.volume > 0) this.lastVolume = this.volume;
this.syncVolumeUI();
}
toggleMute() {
this.setVolume(this.volume > 0 ? 0 : this.lastVolume || 1);
}
setminimised(minimised) { setminimised(minimised) {
this.minimised = minimised; this.minimised = minimised;
try { try {
@@ -444,29 +639,17 @@ const playerArtworkOpacity = 0.4;
} }
// One class drives the morph; re-applying is a no-op. // One class drives the morph; re-applying is a no-op.
// Note: the shell stays a plain div so the face buttons inside it are
// never nested interactives; keyboard users get dedicated buttons.
applyminimised() { applyminimised() {
if (!this.UI.root) return; if (!this.UI.root) return;
if (this.minimised) { if (this.minimised) {
this.UI.root.classList.add("player--minimised"); this.UI.root.classList.add("player--minimised");
this.UI.root.setAttribute("role", "button");
this.UI.root.setAttribute("tabindex", "0");
this.UI.root.setAttribute(
"title",
"Expand player — click to restore full size"
);
this.UI.root.setAttribute(
"aria-label",
"Expand player — click to restore full size"
);
this.UI.spacer?.classList.add("player-spacer--hidden"); this.UI.spacer?.classList.add("player-spacer--hidden");
this.UI.full?.setAttribute("aria-hidden", "true"); this.UI.full?.setAttribute("aria-hidden", "true");
this.UI.face?.setAttribute("aria-hidden", "false"); this.UI.face?.setAttribute("aria-hidden", "false");
} else { } else {
this.UI.root.classList.remove("player--minimised"); this.UI.root.classList.remove("player--minimised");
this.UI.root.removeAttribute("role");
this.UI.root.removeAttribute("tabindex");
this.UI.root.removeAttribute("title");
this.UI.root.removeAttribute("aria-label");
this.UI.spacer?.classList.remove("player-spacer--hidden"); this.UI.spacer?.classList.remove("player-spacer--hidden");
this.UI.full?.removeAttribute("aria-hidden"); this.UI.full?.removeAttribute("aria-hidden");
this.UI.face?.setAttribute("aria-hidden", "true"); this.UI.face?.setAttribute("aria-hidden", "true");
@@ -506,6 +689,14 @@ const playerArtworkOpacity = 0.4;
set.pause.classList.toggle("hidden", !isPlaying); set.pause.classList.toggle("hidden", !isPlaying);
set.play.classList.toggle("hidden", isPlaying); set.play.classList.toggle("hidden", isPlaying);
} }
this.UI.faceControls.toggle?.setAttribute(
"aria-label",
isPlaying ? "Pause" : "Play"
);
this.UI.faceControls.toggle?.setAttribute(
"title",
isPlaying ? "Pause" : "Play"
);
} }
setRingProgress(el, per) { setRingProgress(el, per) {
@@ -559,6 +750,17 @@ const playerArtworkOpacity = 0.4;
// Begin playing the sound. // Begin playing the sound.
sound.play(); sound.play();
// Apply a seek requested before anything was loaded.
if (this.pendingSeek != null) {
const target = data.duration * this.pendingSeek;
this.pendingSeek = null;
if (sound.state() === "loaded") {
sound.seek(target);
} else {
sound.once("load", () => sound.seek(target));
}
}
// Update the track display. // Update the track display.
this.UI.metadata.title.textContent = data.metadata.title; this.UI.metadata.title.textContent = data.metadata.title;
this.UI.metadata.subtitle.textContent = data.metadata.subtitle; this.UI.metadata.subtitle.textContent = data.metadata.subtitle;
@@ -618,6 +820,9 @@ const playerArtworkOpacity = 0.4;
* @param {Number} index Index in the playlist. * @param {Number} index Index in the playlist.
*/ */
skipTo(index) { skipTo(index) {
// A pre-play seek belongs to the old track: drop it.
this.pendingSeek = null;
// Stop the current track. // Stop the current track.
if (this.playlist[this.index].howl) { if (this.playlist[this.index].howl) {
this.playlist[this.index].howl.stop(); this.playlist[this.index].howl.stop();
@@ -637,13 +842,30 @@ const playerArtworkOpacity = 0.4;
* @param {Number} per Percentage through the song to skip. * @param {Number} per Percentage through the song to skip.
*/ */
seek(per) { seek(per) {
// Get the Howl we want to manipulate. const entry = this.playlist[this.index];
var sound = this.playlist[this.index].howl; if (!entry) return;
const clamped = Math.min(Math.max(per, 0), 1);
const total = entry.duration || 0;
const target = total * clamped;
if (sound.playing()) { var sound = entry.howl;
// Convert the percent into a seek position. if (!sound) {
sound.seek(sound.duration() * per); // Nothing loaded yet: remember the request for play().
this.pendingSeek = clamped;
} else {
this.pendingSeek = null;
sound.seek((sound.duration() || total) * clamped);
} }
// Refresh the position display even when paused or unloaded.
this.UI.times.current.textContent = this.formatTime(Math.round(target));
const playedPer = total > 0 ? clamped : 0;
this.UI.progress.played.style.width = playedPer * 100 + "%";
this.UI.progress.bar.setAttribute(
"aria-valuenow",
String(Math.round(playedPer * 100))
);
this.setRingProgress(this.UI.faceProgress.played, playedPer);
} }
/** /**
@@ -657,6 +879,10 @@ const playerArtworkOpacity = 0.4;
this.UI.times.current.textContent = this.formatTime(Math.round(seek)); this.UI.times.current.textContent = this.formatTime(Math.round(seek));
const playedPer = seek / sound.duration() || 0; const playedPer = seek / sound.duration() || 0;
this.UI.progress.played.style.width = playedPer * 100 + "%"; this.UI.progress.played.style.width = playedPer * 100 + "%";
this.UI.progress.bar.setAttribute(
"aria-valuenow",
String(Math.round(playedPer * 100))
);
this.setRingProgress(this.UI.faceProgress.played, playedPer); this.setRingProgress(this.UI.faceProgress.played, playedPer);
const bufferedPercent = this.getBufferedAmount(sound).bufferedPercent; const bufferedPercent = this.getBufferedAmount(sound).bufferedPercent;
@@ -708,6 +934,7 @@ const playerArtworkOpacity = 0.4;
} }
addToQueue(track, immediatePlay = false) { addToQueue(track, immediatePlay = false) {
if (!this.playlist.length) return;
var current = this.playlist[this.index]; var current = this.playlist[this.index];
if ( if (
@@ -729,13 +956,39 @@ const playerArtworkOpacity = 0.4;
if (!window.playerIsInitialised) { if (!window.playerIsInitialised) {
window.player = new Player(initialQueue); window.player = new Player(initialQueue);
} else { } 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 { try {
const p = window.player; const p = window.player;
p.UI.root = $("player-shell"); p.UI.root = $("player-shell");
p.UI.spacer = $("player:spacer"); p.UI.spacer = $("player:spacer");
p.UI.full = document.querySelector("#player-shell .player-full"); p.UI.full = document.querySelector("#player-shell .player-full");
p.UI.face = document.querySelector("#player-shell .player-face"); 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(); p.applyminimised();
} catch (e) { } catch (e) {
/* ignore */ /* ignore */
+5 -3
View File
@@ -7,6 +7,7 @@ interface Props {
} }
const { title, description, url = Astro.url, image } = Astro.props; const { title, description, url = Astro.url, image } = Astro.props;
const canonicalUrl = url.toString();
import person from "@data/person"; import person from "@data/person";
import site from "@data/site"; import site from "@data/site";
@@ -15,7 +16,7 @@ import { Schema } from "astro-seo-schema";
--- ---
<!-- SEO --> <!-- SEO -->
<link rel="canonical" href={url} /> <link rel="canonical" href={canonicalUrl} />
<meta name="robots" content="index, follow" /> <meta name="robots" content="index, follow" />
<Schema <Schema
item={{ item={{
@@ -65,7 +66,8 @@ import { Schema } from "astro-seo-schema";
<meta property="og:site_name" content={site.title} /> <meta property="og:site_name" content={site.title} />
<meta property="og:title" content={title} /> <meta property="og:title" content={title} />
<meta property="og:description" content={description} /> <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 <meta
property="og:image" property="og:image"
content={image !== undefined && image.externalURL !== undefined content={image !== undefined && image.externalURL !== undefined
@@ -98,7 +100,7 @@ import { Schema } from "astro-seo-schema";
<meta name="twitter:description" content={description} /> <meta name="twitter:description" content={description} />
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta <meta
name="twitter:image:src" name="twitter:image"
content={image !== undefined && image.externalURL !== undefined content={image !== undefined && image.externalURL !== undefined
? image.externalURL ? image.externalURL
: site.image.externalURL} : site.image.externalURL}
+1 -1
View File
@@ -9,7 +9,7 @@ interface Props {
const { const {
Tag = "h2", Tag = "h2",
lineColour = "border-primary", lineColour = "border-primary",
lineColourDark = "dark:text-primary", lineColourDark = "dark:border-primary",
class: className class: className
} = Astro.props; } = Astro.props;
--- ---
+1 -1
View File
@@ -28,7 +28,7 @@ const linkIsExternal: boolean =
{...attrs} {...attrs}
><span class="group-hover:text-primary-600"><slot /></span>{ ><span class="group-hover:text-primary-600"><slot /></span>{
includeExternalLinkIcon && linkIsExternal && ( includeExternalLinkIcon && linkIsExternal && (
<sup class="ml-0.5 inline-block"> <sup class="ml-0.5 inline-block" aria-hidden="true">
<Icon <Icon
name="mdi:external-link" name="mdi:external-link"
class:list={[ class:list={[
+5 -2
View File
@@ -6,6 +6,7 @@ interface Props extends HTMLAttributes<"span"> {
textColour?: String; textColour?: String;
size?: String; size?: String;
hover?: String; hover?: String;
as?: "span" | "button";
} }
const { const {
@@ -14,11 +15,13 @@ const {
size = "text-xs", size = "text-xs",
hover = "hover:bg-white hover:text-primary hover:ring-primary hover:ring-2", hover = "hover:bg-white hover:text-primary hover:ring-primary hover:ring-2",
class: className, class: className,
as: Tag = "span",
...attrs ...attrs
} = Astro.props as Props; } = Astro.props as Props;
--- ---
<span <Tag
type={Tag === "button" ? "button" : undefined}
class:list={[ class:list={[
"inline-block rounded px-2 py-1 font-bold uppercase", "inline-block rounded px-2 py-1 font-bold uppercase",
colour, colour,
@@ -27,5 +30,5 @@ const {
size, size,
hover hover
]} ]}
{...attrs}><slot /></span {...attrs}><slot /></Tag
> >
+7 -5
View File
@@ -20,7 +20,9 @@ if (!track.data.card) {
} }
--- ---
<div <button
type="button"
aria-label={`Play ${track.data.card.text.primary}`}
class:list={[ class:list={[
"relative flex min-h-42 flex-auto hover:cursor-pointer", "relative flex min-h-42 flex-auto hover:cursor-pointer",
index < 2 ? "lg:w-1/2" : "sm:w-1/2 md:w-1/3 lg:w-1/4" index < 2 ? "lg:w-1/2" : "sm:w-1/2 md:w-1/3 lg:w-1/4"
@@ -33,8 +35,8 @@ if (!track.data.card) {
class="h-full w-full object-cover" class="h-full w-full object-cover"
/> />
<div <span
class="bg-primary absolute inset-0 z-10 flex h-full w-full flex-col items-center justify-center p-16 text-center opacity-0 transition duration-300 hover:opacity-90" class="bg-primary absolute inset-0 z-10 flex h-full w-full flex-col items-center justify-center p-16 text-center opacity-0 transition duration-300 hover:opacity-90 focus-visible:opacity-90"
> >
<span class="text-md md:text-l block font-bold text-gray-100" <span class="text-md md:text-l block font-bold text-gray-100"
>{track.data.card.text.secondary}</span >{track.data.card.text.secondary}</span
@@ -42,5 +44,5 @@ if (!track.data.card) {
<span class="block text-xl font-extrabold uppercase md:text-2xl" <span class="block text-xl font-extrabold uppercase md:text-2xl"
>{track.data.card.text.primary}</span >{track.data.card.text.primary}</span
> >
</div> </span>
</div> </button>
+4 -2
View File
@@ -21,7 +21,9 @@ const fullFilePath = join(process.cwd(), "public", track.data.src);
const duration = await getAudioDurationInSeconds(fullFilePath); const duration = await getAudioDurationInSeconds(fullFilePath);
--- ---
<div <button
type="button"
aria-label={`Play ${track.data.metadata.title}`}
class:list={[ class:list={[
"text-primary flex items-center transition hover:cursor-pointer hover:text-gray-300", "text-primary flex items-center transition hover:cursor-pointer hover:text-gray-300",
className className
@@ -31,4 +33,4 @@ const duration = await getAudioDurationInSeconds(fullFilePath);
> >
<Icon name="fa7-solid:play-circle" class="mr-2 inline-block" /> <Icon name="fa7-solid:play-circle" class="mr-2 inline-block" />
<span class="inline-block">{track.data.metadata.title}</span> <span class="inline-block">{track.data.metadata.title}</span>
</div> </button>
+1 -1
View File
@@ -6,7 +6,7 @@ export default {
"Nathan Cummins is an award-winning composer, orchestrator, sound designer, and conductor known for his vibrant music across video games, film, and live performance. Based in Adelaide, he brings classical craft, bold creativity, and technical innovation to every project.", "Nathan Cummins is an award-winning composer, orchestrator, sound designer, and conductor known for his vibrant music across video games, film, and live performance. Based in Adelaide, he brings classical craft, bold creativity, and technical innovation to every project.",
tagline: "Composer, Orchestrator, Conductor, Sound Designer", tagline: "Composer, Orchestrator, Conductor, Sound Designer",
image: { image: {
externalURL: `${import.meta.env.SITE}/nathan-cummins-composer-orchestrator-conductor.jpg`, externalURL: `${import.meta.env.SITE ?? "https://www.nathancummins.com.au"}/nathan-cummins-composer-orchestrator-conductor.jpg`,
src: "nathan-cummins-composer-orchestrator-conductor.jpg", src: "nathan-cummins-composer-orchestrator-conductor.jpg",
alt: "Picture of Nathan Cummins, Adelaide composer, orchestrator, and conductor" alt: "Picture of Nathan Cummins, Adelaide composer, orchestrator, and conductor"
} as SiteImage } as SiteImage
+1 -1
View File
@@ -16,7 +16,7 @@ interface Window {
interface ImportMetaEnv { interface ImportMetaEnv {
readonly EMAIL_USER: string; readonly EMAIL_USER: string;
readonly EMAIL_PASS: string; readonly EMAIL_PASS: string;
readonly EMAIL_PORT: number; readonly EMAIL_PORT: string;
readonly EMAIL_SECURE: "true" | "false"; readonly EMAIL_SECURE: "true" | "false";
readonly EMAIL_HOST: string; readonly EMAIL_HOST: string;
readonly EMAIL_FROM: string; readonly EMAIL_FROM: string;
+1 -1
View File
@@ -26,7 +26,7 @@ import MainHead from "@layouts/MainHead.astro";
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<MainHead {title} {subtitle} {description} {image} /> <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} /> <Navbar {navbarDisplay} />
<main class="grow bg-white dark:bg-gray-950"> <main class="grow bg-white dark:bg-gray-950">
<slot /> <slot />
+44 -10
View File
@@ -1,4 +1,4 @@
import { createTransport } from "nodemailer"; import { createTransport, type Transporter } from "nodemailer";
import SMTPTransport from "nodemailer/lib/smtp-transport"; import SMTPTransport from "nodemailer/lib/smtp-transport";
import type { Options } from "nodemailer/lib/mailer"; import type { Options } from "nodemailer/lib/mailer";
@@ -11,29 +11,63 @@ interface Email {
name: string; name: string;
} }
export function constructEmailHtml(props: Email) { export function escapeHtml(input: string): string {
return `<div>${props.message}</div>`; return input
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#39;");
} }
export default async function (props: Email) { export function constructEmailHtml(props: Email) {
const transporter = createTransport({ 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, host: process.env.EMAIL_HOST || import.meta.env.EMAIL_HOST,
port: process.env.EMAIL_PORT || import.meta.env.EMAIL_PORT, port,
secure: secure,
process.env.EMAIL_SECURE === "true" || // Refuse plaintext fallback on submission ports (e.g. 587, 2525).
import.meta.env.EMAIL_SECURE === "true", requireTLS: !secure,
auth: { auth: {
user: process.env.EMAIL_USER || import.meta.env.EMAIL_USER, user: process.env.EMAIL_USER || import.meta.env.EMAIL_USER,
pass: process.env.EMAIL_PASS || import.meta.env.EMAIL_PASS pass: process.env.EMAIL_PASS || import.meta.env.EMAIL_PASS
} }
} as SMTPTransport.Options); } as SMTPTransport.Options);
}
return cachedTransporter;
}
export default async function sendContactEmail(props: Email) {
const port = parseInt(
process.env.EMAIL_PORT || import.meta.env.EMAIL_PORT || "",
10
);
const fromMailbox =
process.env.EMAIL_FROM || import.meta.env.EMAIL_FROM || "";
if (!Number.isFinite(port) || !fromMailbox) {
throw new Error("Email transport is not configured.");
}
const secure =
process.env.EMAIL_SECURE === "true" ||
import.meta.env.EMAIL_SECURE === "true";
const transporter = getTransporter(port, secure);
if (!props.html) { if (!props.html) {
props.html = constructEmailHtml(props); props.html = constructEmailHtml(props);
} }
const message: Options = { const message: Options = {
from: `${props.name} (Website) <${process.env.EMAIL_FROM || import.meta.env.EMAIL_FROM}>`, from: `Website Contact <${fromMailbox}>`,
to: "nathan@nathancummins.com.au", to: "nathan@nathancummins.com.au",
replyTo: props.email, replyTo: props.email,
subject: props.subject, subject: props.subject,
+1
View File
@@ -14,6 +14,7 @@ const heroImagesArray = await convertEagerImagesImportGlobToArray(heroImages);
<MainLayout title="Oops! 404" navbarDisplay="transparent"> <MainLayout title="Oops! 404" navbarDisplay="transparent">
<div class="absolute inset-0 h-full w-full bg-black"> <div class="absolute inset-0 h-full w-full bg-black">
<ImageCarousel <ImageCarousel
id="not-found"
images={heroImagesArray} images={heroImagesArray}
class="h-full w-full" class="h-full w-full"
foreground={true} foreground={true}
+1 -1
View File
@@ -122,7 +122,7 @@ import { Image } from "astro:assets";
</ul> </ul>
</div> </div>
</section> </section>
<section id="Conducting"> <section id="conducting">
<div class="mx-auto max-w-4xl px-8 text-left"> <div class="mx-auto max-w-4xl px-8 text-left">
<H2>Conducting</H2> <H2>Conducting</H2>
<Paragraph <Paragraph
+97 -34
View File
@@ -1,52 +1,115 @@
import sendEmail from "@lib/email"; import sendEmail, { escapeHtml } from "@lib/email";
import type { APIRoute } from "astro"; import type { APIRoute } from "astro";
export const prerender = false; export const prerender = false;
export const POST: APIRoute = async ({ request }) => { const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const data = await request.formData(); const MAX_NAME = 100;
const email = data.get("email") as string | null; const MAX_EMAIL = 254;
const subject = data.get("subject") as string | null; const MAX_SUBJECT = 150;
const message = data.get("message") as string | null; const MAX_MESSAGE = 5000;
const name = data.get("name") as string | null;
// Minimal in-memory throttle (single instance): 5 sends per IP per 10 min.
const RATE_WINDOW_MS = 10 * 60 * 1000;
const RATE_MAX = 5;
const recentSends = new Map<string, number[]>();
function isRateLimited(ip: string): boolean {
const now = Date.now();
const history = (recentSends.get(ip) ?? []).filter(
(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;
}
function json(message: string, status: number, statusText: string): Response {
return new Response(JSON.stringify({ message }), {
status,
statusText,
headers: { "Content-Type": "application/json" }
});
}
export const POST: APIRoute = async ({ request, clientAddress }) => {
// 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.",
429,
"Too Many Requests"
);
}
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() ?? "";
const name = (data.get("name") as string | null)?.trim() ?? "";
if (!email || !subject || !message || !name) { if (!email || !subject || !message || !name) {
return new Response( return json("Required field missing.", 400, "Bad Request");
JSON.stringify({ message: "Required field missing." }),
{
status: 400,
statusText: "Missing required fields."
} }
);
if (
!EMAIL_RE.test(email) ||
email.length > MAX_EMAIL ||
subject.length > MAX_SUBJECT ||
message.length > MAX_MESSAGE ||
name.length > MAX_NAME
) {
return json("Invalid field value.", 400, "Bad Request");
} }
// Strip line breaks so values can never smuggle SMTP headers.
const safeSubject = subject.replace(/[\r\n]+/g, " ");
const safeName = name.replace(/[\r\n]+/g, " ");
const html = `<h1>Message Received via Contact Form</h1><br> const html = `<h1>Message Received via Contact Form</h1><br>
<b>Name</b>: ${name}<br> <b>Name</b>: ${escapeHtml(safeName)}<br>
<b>Email</b>: ${email}<br> <b>Email</b>: ${escapeHtml(email)}<br>
<b>Message</b>: ${message}`; <b>Message</b>: ${escapeHtml(message).replace(/\n/g, "<br>")}`;
try { try {
await sendEmail({ email, subject, message, name, html }); await sendEmail({
email,
subject: safeSubject,
message,
name: safeName,
html
});
} catch (error) { } catch (error) {
return new Response( console.error("Contact email failed to send:", error);
JSON.stringify({ return json(
message: `Message failed to send with an internal server error. Please contact me directly via a method below.` `Message failed to send with an internal server error. Please contact me directly via a method below.`,
}), 500,
{ "Internal Server Error"
status: 500,
statusText: `Message failed to send with an internal server error. Please contact me directly via a method below.`
}
); );
} }
return new Response( return json(
JSON.stringify({ "Thanks for getting in touch! I will try to get back to you as soon as I can.",
message: 200,
"Thanks for getting in touch! I will try to get back to you as soon as I can." "OK"
}),
{
status: 200,
statusText: "OK"
}
); );
}; };
+11 -4
View File
@@ -11,8 +11,11 @@ import { Icon } from "astro-icon/components";
<div class="w-full"> <div class="w-full">
<section id="contact" class="bg-primary dark:bg-gray-800"> <section id="contact" class="bg-primary dark:bg-gray-800">
<div class="mx-auto max-w-4xl px-8 py-16 text-center"> <div class="mx-auto max-w-4xl px-8 py-16 text-center">
<SectionTitle Tag="h1" class="text-white" lineColour="text-white" <SectionTitle
>Let's get in touch!</SectionTitle Tag="h1"
class="text-white"
lineColour="border-white"
lineColourDark="dark:border-white">Let's get in touch!</SectionTitle
> >
<ContactForm /> <ContactForm />
</div> </div>
@@ -22,13 +25,17 @@ import { Icon } from "astro-icon/components";
<SectionTitle>Other ways to reach me</SectionTitle> <SectionTitle>Other ways to reach me</SectionTitle>
<div class="grid grid-cols-1 text-lg md:grid-cols-2"> <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"> <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" <TextLink href="mailto:nathan@nathancummins.com.au" class="mt-4"
>nathan@nathancummins.com.au</TextLink >nathan@nathancummins.com.au</TextLink
> >
</div> </div>
<div class="col-span-1 flex flex-col items-center justify-center p-4"> <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" <Paragraph class="my-0 mt-4"
>PO Box 2112 Regency Park SA 5942</Paragraph >PO Box 2112 Regency Park SA 5942</Paragraph
> >
+37 -20
View File
@@ -17,28 +17,28 @@ import { Image } from "astro:assets";
import { Icon } from "astro-icon/components"; 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 }>( const heroImages = import.meta.glob<{ default: ImageMetadata; eager: true }>(
"../assets/img/hero/*" "../assets/img/hero/*"
); );
const heroImagesArray = await convertEagerImagesImportGlobToArray(heroImages); 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 = ( const projects = (
await getCollection("projects", ({ data }) => data.frontPage) await getCollection("projects", ({ data }) => data.frontPage)
).sort( ).sort(
(a, b) => (a.data.frontPage?.order || 0) - (b.data.frontPage?.order || 1) (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( const awards = (await getCollection("awards")).sort(
(a, b) => b.data.date.valueOf() - a.data.date.valueOf() (a, b) => b.data.date.valueOf() - a.data.date.valueOf()
); );
@@ -53,9 +53,10 @@ const tracks = (
--- ---
<MainLayout navbarDisplay="transparent"> <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"> <div class="absolute inset-0 h-full w-full bg-black">
<ImageCarousel <ImageCarousel
id="hero"
images={heroImagesArray} images={heroImagesArray}
class="h-full w-full" class="h-full w-full"
foreground={true} foreground={true}
@@ -67,8 +68,7 @@ const tracks = (
<h1 <h1
class="font-header pb-8 text-5xl font-medium text-white uppercase text-shadow-lg/75 md:text-7xl lg:text-9xl" 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.first}{" "}{person.names.last}
{person.names.last}
</h1> </h1>
<h2 <h2
class="font-header text-2xl font-medium text-gray-300 uppercase text-shadow-lg/75 md:text-2xl lg:text-4xl" class="font-header text-2xl font-medium text-gray-300 uppercase text-shadow-lg/75 md:text-2xl lg:text-4xl"
@@ -108,6 +108,7 @@ const tracks = (
<section id="cta" class="text-white"> <section id="cta" class="text-white">
<div class="flex h-48 w-full items-center justify-center"> <div class="flex h-48 w-full items-center justify-center">
<ImageCarousel <ImageCarousel
id="cta"
images={imagesForCTAArray} images={imagesForCTAArray}
class="h-full w-full" class="h-full w-full"
foreground={true} foreground={true}
@@ -118,6 +119,7 @@ const tracks = (
quality={5} quality={5}
height={192} height={192}
shuffle={true} shuffle={true}
eagerCount={4}
><div class="flex h-full w-full items-center"> ><div class="flex h-full w-full items-center">
<a <a
href="/contact/" href="/contact/"
@@ -159,8 +161,10 @@ const tracks = (
<section id="listen" class="bg-primary text-white dark:bg-gray-800"> <section id="listen" class="bg-primary text-white dark:bg-gray-800">
<div class="w-full overflow-hidden"> <div class="w-full overflow-hidden">
<div class="pt-16 text-center"> <div class="pt-16 text-center">
<SectionTitle lineColour="text-white">Listen</SectionTitle> <SectionTitle
lineColour="border-white"
lineColourDark="dark:border-white">Listen</SectionTitle
>
<Paragraph <Paragraph
>Click or tap on an image below to listen to the work.</Paragraph >Click or tap on an image below to listen to the work.</Paragraph
> >
@@ -176,13 +180,20 @@ const tracks = (
<Paragraph <Paragraph
>I am very grateful to have been recognised and awarded for my work.</Paragraph >I am very grateful to have been recognised and awarded for my work.</Paragraph
> >
<div class="md-8 h-48 overflow-hidden scroll-smooth p-0"> <div class="mb-8 h-48 overflow-hidden scroll-smooth p-0">
<div <div
class="animate-scrolling-awards m-0 mx-auto flex max-w-md flex-col space-y-8 p-0" class="animate-scrolling-awards m-0 mx-auto flex max-w-md flex-col space-y-8 p-0"
> >
{ {
awardsDoubled.map((award) => { awardsDoubled.map((award, index) => {
return <AwardCard award={award} />; // 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> </div>
@@ -192,6 +203,7 @@ const tracks = (
<section id="fillerUntilServicesIsComplete" class="text-white"> <section id="fillerUntilServicesIsComplete" class="text-white">
<div class="flex h-96 w-full items-center justify-center"> <div class="flex h-96 w-full items-center justify-center">
<ImageCarousel <ImageCarousel
id="filler"
images={imagesForCTAArray} images={imagesForCTAArray}
class="h-full w-full" class="h-full w-full"
foreground={true} foreground={true}
@@ -202,6 +214,7 @@ const tracks = (
quality={5} quality={5}
height={384} height={384}
shuffle={true} shuffle={true}
eagerCount={4}
/> />
</div> </div>
</section> </section>
@@ -210,13 +223,17 @@ const tracks = (
<SectionTitle>Let's get in touch!</SectionTitle> <SectionTitle>Let's get in touch!</SectionTitle>
<div class="grid grid-cols-1 text-lg md:grid-cols-2"> <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"> <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" <TextLink href="mailto:nathan@nathancummins.com.au" class="mt-4"
>nathan@nathancummins.com.au</TextLink >nathan@nathancummins.com.au</TextLink
> >
</div> </div>
<div class="col-span-1 flex flex-col items-center justify-center p-4"> <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" <Paragraph class="my-0 mt-4"
>PO Box 2112 Regency Park SA 5942</Paragraph >PO Box 2112 Regency Park SA 5942</Paragraph
> >
+8 -2
View File
@@ -23,12 +23,16 @@ const types = [...new Set(projects.map((project) => project.data.type))];
<SectionTitle Tag="h1">Recent Projects</SectionTitle> <SectionTitle Tag="h1">Recent Projects</SectionTitle>
<div id="filter-tokens" class="my-8 space-y-2 space-x-2"> <div id="filter-tokens" class="my-8 space-y-2 space-x-2">
<Token <Token
as="button"
aria-pressed="true"
class="filter-token !text-primary ring-primary bg-white ring-2 hover:cursor-pointer" class="filter-token !text-primary ring-primary bg-white ring-2 hover:cursor-pointer"
data-type="all">All</Token data-type="all">All</Token
> >
{ {
types.map((type) => ( types.map((type) => (
<Token <Token
as="button"
aria-pressed="false"
class="filter-token hover:cursor-pointer" class="filter-token hover:cursor-pointer"
data-type={slugify(type)} data-type={slugify(type)}
> >
@@ -70,14 +74,15 @@ const types = [...new Set(projects.map((project) => project.data.type))];
const token = (e.target as Element).closest<HTMLElement>(".filter-token"); const token = (e.target as Element).closest<HTMLElement>(".filter-token");
if (!token) return; if (!token) return;
tokens.forEach((t) => tokens.forEach((t) => {
t.classList.remove( t.classList.remove(
"bg-white", "bg-white",
"!text-primary", "!text-primary",
"ring-primary", "ring-primary",
"ring-2" "ring-2"
)
); );
t.setAttribute("aria-pressed", "false");
});
token.classList.add( token.classList.add(
"bg-white", "bg-white",
@@ -85,6 +90,7 @@ const types = [...new Set(projects.map((project) => project.data.type))];
"ring-primary", "ring-primary",
"ring-2" "ring-2"
); );
token.setAttribute("aria-pressed", "true");
const type = token.dataset.type; const type = token.dataset.type;
+1
View File
@@ -65,6 +65,7 @@ import P from "@components/MDX/P.astro";
<section id="title" class="text-white"> <section id="title" class="text-white">
<div class="flex h-100 w-full items-center justify-center"> <div class="flex h-100 w-full items-center justify-center">
<ImageCarousel <ImageCarousel
id="project-hero"
images={images} images={images}
class="h-full w-full" class="h-full w-full"
foreground={true} foreground={true}