Compare commits
7
Commits
70af555189
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
809e51bae0
|
||
|
|
70bf783ca8
|
||
|
|
e21219aba6
|
||
|
|
a2dea4b210
|
||
|
|
2001963035
|
||
|
|
57c906082f
|
||
|
|
af8f99feb0
|
No files matched your search
@@ -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
@@ -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: {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -20,6 +20,7 @@ interface Props {
|
|||||||
quality?: number;
|
quality?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
shuffle?: boolean;
|
shuffle?: boolean;
|
||||||
|
eagerCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -37,10 +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 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"]}>
|
||||||
@@ -58,13 +63,13 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
|
|||||||
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"
|
||||||
@@ -87,21 +92,53 @@ const imagesArray = shuffle ? shuffleArray(images) : images;
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script
|
<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(
|
const current = document.querySelectorAll(
|
||||||
`[data-id="${carouselId}-${currentIndex}"]`
|
`[data-id="${carouselId}-${state.index}"]`
|
||||||
)[0];
|
)[0];
|
||||||
const nextIndex = (currentIndex + 1) % imageCount;
|
const nextIndex = (state.index + 1) % imageCount;
|
||||||
const next = document.querySelectorAll(
|
const next = document.querySelectorAll(
|
||||||
`[data-id="${carouselId}-${nextIndex}"]`
|
`[data-id="${carouselId}-${nextIndex}"]`
|
||||||
)[0];
|
)[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");
|
||||||
@@ -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>
|
||||||
@@ -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", () => {
|
||||||
|
|||||||
@@ -171,12 +171,14 @@ const playerArtworkOpacity = 0.4;
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-grow flex-col text-sm">
|
<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>
|
||||||
@@ -404,6 +406,13 @@ const playerArtworkOpacity = 0.4;
|
|||||||
|
|
||||||
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"),
|
||||||
@@ -925,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 (
|
||||||
@@ -946,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 */
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ const link = `/projects/${slugify(project.data.type)}/${slugify(project.data.slu
|
|||||||
{project.data.keyFigure.map((figure) => {
|
{project.data.keyFigure.map((figure) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<span class="font-bold">{figure.title}:</span>
|
<span class="font-bold">{figure.title}: </span>
|
||||||
<span>
|
<span>
|
||||||
{figure.href && (
|
{figure.href && (
|
||||||
<TextLink href={figure.href}>{figure.name}</TextLink>
|
<TextLink href={figure.href}>{figure.name}</TextLink>
|
||||||
|
|||||||
@@ -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,7 @@ 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 property="og:type" content="website" />
|
||||||
<meta
|
<meta
|
||||||
property="og:image"
|
property="og:image"
|
||||||
|
|||||||
@@ -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={[
|
||||||
|
|||||||
@@ -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 />
|
||||||
|
|||||||
+26
-11
@@ -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";
|
||||||
@@ -24,6 +24,27 @@ export function constructEmailHtml(props: Email) {
|
|||||||
return `<div>${escapeHtml(props.message)}</div>`;
|
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) {
|
export default async function sendContactEmail(props: Email) {
|
||||||
const port = parseInt(
|
const port = parseInt(
|
||||||
process.env.EMAIL_PORT || import.meta.env.EMAIL_PORT || "",
|
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.");
|
throw new Error("Email transport is not configured.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const transporter = createTransport({
|
const secure =
|
||||||
host: process.env.EMAIL_HOST || import.meta.env.EMAIL_HOST,
|
|
||||||
port,
|
|
||||||
secure:
|
|
||||||
process.env.EMAIL_SECURE === "true" ||
|
process.env.EMAIL_SECURE === "true" ||
|
||||||
import.meta.env.EMAIL_SECURE === "true",
|
import.meta.env.EMAIL_SECURE === "true";
|
||||||
auth: {
|
|
||||||
user: process.env.EMAIL_USER || import.meta.env.EMAIL_USER,
|
const transporter = getTransporter(port, secure);
|
||||||
pass: process.env.EMAIL_PASS || import.meta.env.EMAIL_PASS
|
|
||||||
}
|
|
||||||
} as SMTPTransport.Options);
|
|
||||||
|
|
||||||
if (!props.html) {
|
if (!props.html) {
|
||||||
props.html = constructEmailHtml(props);
|
props.html = constructEmailHtml(props);
|
||||||
|
|||||||
@@ -20,10 +20,19 @@ function isRateLimited(ip: string): boolean {
|
|||||||
(t) => now - t < RATE_WINDOW_MS
|
(t) => now - t < RATE_WINDOW_MS
|
||||||
);
|
);
|
||||||
if (history.length >= RATE_MAX) {
|
if (history.length >= RATE_MAX) {
|
||||||
|
recentSends.set(ip, history);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
history.push(now);
|
history.push(now);
|
||||||
recentSends.set(ip, history);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +45,8 @@ function json(message: string, status: number, statusText: string): Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request, clientAddress }) => {
|
export const POST: APIRoute = async ({ request, clientAddress }) => {
|
||||||
const ip =
|
// Prefer the socket address: x-forwarded-for is client-controlled.
|
||||||
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ||
|
const ip = clientAddress || "unknown";
|
||||||
clientAddress ||
|
|
||||||
"unknown";
|
|
||||||
if (isRateLimited(ip)) {
|
if (isRateLimited(ip)) {
|
||||||
return json(
|
return json(
|
||||||
"Too many messages sent. Please try again later.",
|
"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 email = (data.get("email") as string | null)?.trim() ?? "";
|
||||||
const subject = (data.get("subject") as string | null)?.trim() ?? "";
|
const subject = (data.get("subject") as string | null)?.trim() ?? "";
|
||||||
const message = (data.get("message") 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
|
html
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Contact email failed to send:", error);
|
||||||
return json(
|
return json(
|
||||||
`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,
|
500,
|
||||||
|
|||||||
@@ -25,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
|
||||||
>
|
>
|
||||||
|
|||||||
+23
-15
@@ -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,7 +53,7 @@ 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"
|
id="hero"
|
||||||
@@ -68,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"
|
||||||
@@ -120,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/"
|
||||||
@@ -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"
|
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>
|
||||||
@@ -207,6 +214,7 @@ const tracks = (
|
|||||||
quality={5}
|
quality={5}
|
||||||
height={384}
|
height={384}
|
||||||
shuffle={true}
|
shuffle={true}
|
||||||
|
eagerCount={4}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ import P from "@components/MDX/P.astro";
|
|||||||
{project.data.keyFigure.map((figure) => {
|
{project.data.keyFigure.map((figure) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<span class="font-bold">{figure.title}:</span>
|
<span class="font-bold">{figure.title}: </span>
|
||||||
<span>
|
<span>
|
||||||
{figure.href && (
|
{figure.href && (
|
||||||
<TextLink href={figure.href}>
|
<TextLink href={figure.href}>
|
||||||
|
|||||||
Reference in new issue
Block a user