mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 07:43:49 +01:00
start of hero
This commit is contained in:
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));
|
||||
}
|
||||
Reference in new issue
Block a user