mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-09 08:55:00 -05:00
Compare commits
No commits in common. "c4b1e41b82e6877c0e7f36be2a47f1f4683c662a" and "53f7cdb171ea2fab272108c3ee6b7e67d4b479ae" have entirely different histories.
c4b1e41b82
...
53f7cdb171
Binary file not shown.
@ -4,13 +4,10 @@ export async function loadFonts() {
|
|||||||
new URL("./Inter-Regular.ttf", import.meta.url)
|
new URL("./Inter-Regular.ttf", import.meta.url)
|
||||||
).then((res) => res.arrayBuffer());
|
).then((res) => res.arrayBuffer());
|
||||||
|
|
||||||
const interMediumFontP = fetch(
|
|
||||||
new URL("./Inter-Medium.ttf", import.meta.url)
|
|
||||||
).then((res) => res.arrayBuffer());
|
|
||||||
|
|
||||||
const interBoldFontP = fetch(
|
const interBoldFontP = fetch(
|
||||||
new URL("./Inter-Bold.ttf", import.meta.url)
|
new URL("./Inter-Bold.ttf", import.meta.url)
|
||||||
).then((res) => res.arrayBuffer());
|
).then((res) => res.arrayBuffer());
|
||||||
|
|
||||||
return Promise.all([interRegularFontP, interMediumFontP, interBoldFontP]);
|
return Promise.all([interRegularFontP, interBoldFontP]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ImageResponse } from "@vercel/og";
|
import { ImageResponse } from "@vercel/og";
|
||||||
import type { NextRequest } from "next/server";
|
import { NextRequest } from "next/server";
|
||||||
import { MongoClient } from "mongodb";
|
import { MongoClient } from "mongodb";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
@ -26,7 +26,6 @@ async function loadLocalFonts() {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
fs.readFileSync(path.join(fontPath, "Inter-Regular.ttf")),
|
fs.readFileSync(path.join(fontPath, "Inter-Regular.ttf")),
|
||||||
fs.readFileSync(path.join(fontPath, "Inter-Medium.ttf")),
|
|
||||||
fs.readFileSync(path.join(fontPath, "Inter-Bold.ttf")),
|
fs.readFileSync(path.join(fontPath, "Inter-Bold.ttf")),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -36,19 +35,11 @@ export async function GET(
|
|||||||
{ params }: { params: Promise<{ id: string }> }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
// Load banner image from filesystem
|
|
||||||
const bannerPath = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
"public",
|
|
||||||
"branding",
|
|
||||||
"bg-banner.png"
|
|
||||||
);
|
|
||||||
const bannerImageData = fs.readFileSync(bannerPath);
|
|
||||||
|
|
||||||
const id = (await params).id;
|
const id = (await params).id;
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
const [interRegular, interMedium, interBold] = await loadLocalFonts();
|
const [interRegular, interBold] = await loadLocalFonts();
|
||||||
|
|
||||||
// Verify server exists
|
// Verify server exists
|
||||||
const serverResponse = await fetch(`https://api.minehut.com/server/${id}`);
|
const serverResponse = await fetch(`https://api.minehut.com/server/${id}`);
|
||||||
@ -69,7 +60,7 @@ export async function GET(
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
backgroundImage: `url(data:image/png;base64,${bannerImageData.toString("base64")})`,
|
backgroundColor: "white",
|
||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
backgroundPosition: "center",
|
backgroundPosition: "center",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
@ -257,7 +248,7 @@ export async function GET(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
backgroundImage: `url(data:image/png;base64,${bannerImageData.toString("base64")})`,
|
backgroundColor: "white",
|
||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
backgroundPosition: "center",
|
backgroundPosition: "center",
|
||||||
}}
|
}}
|
||||||
@ -549,12 +540,6 @@ export async function GET(
|
|||||||
style: "normal",
|
style: "normal",
|
||||||
weight: 700,
|
weight: 700,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Inter",
|
|
||||||
data: interMedium,
|
|
||||||
style: "normal",
|
|
||||||
weight: 500,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -570,21 +555,6 @@ export async function GET(
|
|||||||
console.error("Failed to load fonts for error page:", e);
|
console.error("Failed to load fonts for error page:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to load the banner image
|
|
||||||
let bannerImageData: Buffer | null = null;
|
|
||||||
try {
|
|
||||||
const bannerPath = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
"public",
|
|
||||||
"branding",
|
|
||||||
"dark-banner.png"
|
|
||||||
);
|
|
||||||
bannerImageData = fs.readFileSync(bannerPath);
|
|
||||||
} catch (e) {
|
|
||||||
// If banner image fails to load, use a solid color background
|
|
||||||
console.error("Failed to load banner image for error page:", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
(
|
(
|
||||||
<div
|
<div
|
||||||
@ -592,7 +562,6 @@ export async function GET(
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
fontSize: 60,
|
fontSize: 60,
|
||||||
color: "white",
|
color: "white",
|
||||||
background: bannerImageData ? undefined : "#121212",
|
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
padding: "50px 50px",
|
padding: "50px 50px",
|
||||||
@ -600,11 +569,7 @@ export async function GET(
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
...(bannerImageData && {
|
backgroundColor: "white"
|
||||||
backgroundImage: `url(data:image/png;base64,${bannerImageData.toString("base64")})`,
|
|
||||||
backgroundSize: "cover",
|
|
||||||
backgroundPosition: "center",
|
|
||||||
}),
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
|
|||||||
import { miniMessage } from "minimessage-js";
|
import { miniMessage } from "minimessage-js";
|
||||||
import { loadFonts } from "../../fonts";
|
import { loadFonts } from "../../fonts";
|
||||||
|
|
||||||
// export const runtime = "edge";
|
export const runtime = "edge";
|
||||||
|
|
||||||
// Function to parse MiniMessage and create JSX elements with styling
|
// Function to parse MiniMessage and create JSX elements with styling
|
||||||
function parseMotdToJsx(text: string) {
|
function parseMotdToJsx(text: string) {
|
||||||
@ -128,15 +128,11 @@ export async function GET(
|
|||||||
{ params }: { params: Promise<{ id: string }> }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
// Load banner image
|
|
||||||
const bannerImageData = await fetch(
|
|
||||||
new URL("/branding/bg-banner.png", request.url)
|
|
||||||
).then((res) => res.arrayBuffer());
|
|
||||||
|
|
||||||
const id = (await params).id;
|
const id = (await params).id;
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
const [interRegular, interMedium, interBold] = await loadFonts();
|
const [interRegular, interBold] = await loadFonts();
|
||||||
|
|
||||||
// Fetch server data
|
// Fetch server data
|
||||||
const response = await fetch(`https://api.minehut.com/server/${id}`);
|
const response = await fetch(`https://api.minehut.com/server/${id}`);
|
||||||
@ -158,7 +154,6 @@ export async function GET(
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
backgroundImage: `url(data:image/png;base64,${Buffer.from(bannerImageData).toString("base64")})`,
|
|
||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
backgroundPosition: "center",
|
backgroundPosition: "center",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
@ -226,7 +221,7 @@ export async function GET(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
backgroundImage: `url(data:image/png;base64,${Buffer.from(bannerImageData).toString("base64")})`,
|
backgroundColor: "white",
|
||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
backgroundPosition: "center",
|
backgroundPosition: "center",
|
||||||
}}
|
}}
|
||||||
@ -417,30 +412,15 @@ export async function GET(
|
|||||||
data: interBold,
|
data: interBold,
|
||||||
style: "normal",
|
style: "normal",
|
||||||
weight: 700,
|
weight: 700,
|
||||||
},
|
}
|
||||||
{
|
|
||||||
name: "Inter",
|
|
||||||
data: interMedium,
|
|
||||||
style: "normal",
|
|
||||||
weight: 500,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const [interRegular, interMedium, interBold] = await loadFonts();
|
const [interRegular, interBold] = await loadFonts();
|
||||||
console.error("Error generating OG image:", error);
|
console.error("Error generating OG image:", error);
|
||||||
|
|
||||||
// Try to load the banner image again in case it failed earlier
|
|
||||||
let bannerImageData: ArrayBuffer | undefined;
|
|
||||||
try {
|
|
||||||
bannerImageData = await fetch(
|
|
||||||
new URL("/branding/dark-banner.png", request.url)
|
|
||||||
).then((res) => res.arrayBuffer());
|
|
||||||
} catch (e) {
|
|
||||||
// If banner image fails to load, use a solid color background
|
|
||||||
console.error("Failed to load banner image for error page:", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
(
|
(
|
||||||
@ -449,7 +429,7 @@ export async function GET(
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
fontSize: 60,
|
fontSize: 60,
|
||||||
color: "white",
|
color: "white",
|
||||||
background: bannerImageData ? undefined : "#121212",
|
background: "#121212",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
padding: "50px 50px",
|
padding: "50px 50px",
|
||||||
@ -457,11 +437,7 @@ export async function GET(
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
fontFamily: "Inter",
|
fontFamily: "Inter",
|
||||||
...(bannerImageData && {
|
backgroundColor: "white",
|
||||||
backgroundImage: `url(data:image/png;base64,${Buffer.from(bannerImageData).toString("base64")})`,
|
|
||||||
backgroundSize: "cover",
|
|
||||||
backgroundPosition: "center",
|
|
||||||
}),
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ display: "flex" }}>
|
<div style={{ display: "flex" }}>
|
||||||
|
|||||||
@ -103,6 +103,7 @@ export function ServerList() {
|
|||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent
|
<TooltipContent
|
||||||
side="bottom"
|
side="bottom"
|
||||||
|
className="backdrop-blur bg-transparent text-black dark:text-white "
|
||||||
>
|
>
|
||||||
{filterCount} modification(s) enabled
|
{filterCount} modification(s) enabled
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
|
|||||||
@ -61,7 +61,6 @@ export function useFilters(data: OnlineServer[]) {
|
|||||||
const { user, isSignedIn } = useUser();
|
const { user, isSignedIn } = useUser();
|
||||||
|
|
||||||
const updateServers = async (newFilters: EmbeddedFilter[]) => {
|
const updateServers = async (newFilters: EmbeddedFilter[]) => {
|
||||||
if (newFilters.length === 0) setFilteredData(data);
|
|
||||||
const modificationMap = await Promise.all(data.map((v) =>
|
const modificationMap = await Promise.all(data.map((v) =>
|
||||||
Promise.all(newFilters.map(async (c) => c.functionFilter(v))),
|
Promise.all(newFilters.map(async (c) => c.functionFilter(v))),
|
||||||
));
|
));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user