mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 07:43:49 +01:00
home button
This commit is contained in:
5 files changed
+57
-76
No files matched your search
@@ -14,13 +14,17 @@ interface ToolBannerProps {
|
||||
size: ToolBannerSize;
|
||||
}
|
||||
|
||||
const BANNER_EXTENSIONS = ["webp", "png", "jpg", "jpeg"];
|
||||
|
||||
function bannerPath(tool: string) {
|
||||
return `src/media/banners/${tool}.webp`;
|
||||
return BANNER_EXTENSIONS.map(
|
||||
(extension) => `src/media/banners/${tool}.${extension}`,
|
||||
).find((path) => existsSync(path));
|
||||
}
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () =>
|
||||
Object.values(tools)
|
||||
.filter((tool) => existsSync(bannerPath(tool.id)))
|
||||
.filter((tool) => bannerPath(tool.id) !== undefined)
|
||||
.flatMap((tool) =>
|
||||
Object.values(ToolBannerSize).map(
|
||||
(size) =>
|
||||
@@ -34,7 +38,7 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, () =>
|
||||
|
||||
export async function GET({ props }: APIContext<ToolBannerProps>) {
|
||||
const height = TOOL_BANNER_HEIGHTS[props.size];
|
||||
let image = sharp(bannerPath(props.tool));
|
||||
let image = sharp(bannerPath(props.tool)!);
|
||||
|
||||
if (height !== null) image = image.resize({ height });
|
||||
|
||||
|
||||
Reference in new issue
Block a user