start of hero

This commit is contained in:
tresabhi committed 2026-11-27 22:29:00 -06:00
1 parent 639de710c8
commit b4e0079352
5 files changed
+80 -153

No files matched your search

@@ -0,0 +1,32 @@
import type { APIContext, GetStaticPathsItem } from "astro";
import { readdirSync } from "fs";
import { parse } from "path";
import sharp from "sharp";
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
import { getStaticPaths as _getStaticPaths } from "../_index";
interface HeroProps {
path: string;
}
const HEROS = "src/media/heros";
const HERO_HEIGHT = 800;
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () =>
readdirSync(HEROS).map(
(file) =>
({
params: { season: parse(file).name },
props: { path: `${HEROS}/${file}` } satisfies HeroProps,
}) satisfies GetStaticPathsItem,
),
);
export async function GET({ props }: APIContext<HeroProps>) {
const image = await sharp(props.path)
.resize({ height: HERO_HEIGHT })
.webp()
.toBuffer();
return new Response(new Uint8Array(image));
}