mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-21 12:53:56 +01:00
home button
This commit is contained in:
5 files changed
+57
-76
No files matched your search
@@ -17,7 +17,7 @@ const { locale } = Astro.props;
|
||||
const strings = await api.strings(locale);
|
||||
|
||||
export const filtered = Object.values(tools).filter(
|
||||
(tool) => !tool.href && (tool.navbar ?? true) && !tool.disabled,
|
||||
(tool) => !tool.href && !tool.hide_in_navbar && !tool.disabled,
|
||||
);
|
||||
---
|
||||
|
||||
@@ -170,25 +170,27 @@ export const filtered = Object.values(tools).filter(
|
||||
</LinkI18nWrapper>
|
||||
|
||||
<div class="tools">
|
||||
{filtered.map((tool) => (
|
||||
<>
|
||||
<LinkI18nWrapper {locale} href={`/${tool.slug ?? tool.id}`}>
|
||||
<div class="tool">
|
||||
<div
|
||||
style={`background-image: url(${alias(
|
||||
"api",
|
||||
`/tools/${tool.id}/banners/thumbnail.webp`,
|
||||
)})`}
|
||||
class="logo"
|
||||
/>
|
||||
{filtered
|
||||
.filter((tool) => !tool.hide_in_navbar_desktop)
|
||||
.map((tool) => (
|
||||
<>
|
||||
<LinkI18nWrapper {locale} href={`/${tool.slug ?? tool.id}`}>
|
||||
<div class="tool">
|
||||
<div
|
||||
style={`background-image: url(${alias(
|
||||
"api",
|
||||
`/tools/${tool.id}/banners/thumbnail.webp`,
|
||||
)})`}
|
||||
class="logo"
|
||||
/>
|
||||
|
||||
<Text className="name">
|
||||
{strings.tools[tool.id as keyof typeof strings.tools].name}
|
||||
</Text>
|
||||
</div>
|
||||
</LinkI18nWrapper>
|
||||
</>
|
||||
))}
|
||||
<Text className="name">
|
||||
{strings.tools[tool.id as keyof typeof strings.tools].name}
|
||||
</Text>
|
||||
</div>
|
||||
</LinkI18nWrapper>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<LinkI18nWrapper {locale} href="/settings">
|
||||
|
||||
@@ -7,10 +7,16 @@ export interface Tool {
|
||||
disabled?: boolean;
|
||||
|
||||
banner_background_position: "top" | "center" | "bottom";
|
||||
navbar?: boolean;
|
||||
hide_in_navbar?: boolean;
|
||||
hide_in_navbar_desktop?: boolean;
|
||||
}
|
||||
|
||||
export const tools: Record<string, Tool> = {
|
||||
home: {
|
||||
id: "home",
|
||||
banner_background_position: "center",
|
||||
hide_in_navbar_desktop: true,
|
||||
},
|
||||
tanks: {
|
||||
id: "tanks",
|
||||
banner_background_position: "top",
|
||||
@@ -84,13 +90,13 @@ export const tools: Record<string, Tool> = {
|
||||
settings: {
|
||||
id: "settings",
|
||||
banner_background_position: "center",
|
||||
navbar: false,
|
||||
hide_in_navbar: true,
|
||||
},
|
||||
credits: {
|
||||
disabled: true,
|
||||
id: "credits",
|
||||
banner_background_position: "center",
|
||||
navbar: false,
|
||||
hide_in_navbar: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@@ -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