use the server preview from the api in the server route for embeds
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 3m25s
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 3m25s
This commit is contained in:
parent
4ffd10e9c3
commit
52fea3da68
@ -33,7 +33,7 @@
|
||||
"cmdk": "^1.0.0",
|
||||
"fuse.js": "^7.0.0",
|
||||
"lucide-react": "^0.372.0",
|
||||
"mcutils-library": "^1.2.6",
|
||||
"mcutils-library": "^1.3.1",
|
||||
"moment": "^2.30.1",
|
||||
"next": "14.2.2",
|
||||
"next-build-id": "^3.0.0",
|
||||
|
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@ -81,7 +81,7 @@ dependencies:
|
||||
specifier: ^0.372.0
|
||||
version: 0.372.0(react@18.2.0)
|
||||
mcutils-library:
|
||||
specifier: ^1.2.6
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.1(@babel/core@7.24.4)(@types/node@20.12.7)
|
||||
moment:
|
||||
specifier: ^2.30.1
|
||||
|
@ -82,18 +82,14 @@ export async function generateMetadata({ params: { platform, hostname } }: Param
|
||||
|
||||
try {
|
||||
const server = await getServer(platform, hostname);
|
||||
const { hostname: serverHostname, players } = server;
|
||||
|
||||
const favicon = getFavicon(platform, server);
|
||||
|
||||
let description = `There is ${formatNumber(players.online)}/${formatNumber(players.max)} players connected!\n\n`;
|
||||
description += "Click to view more information about the server.";
|
||||
const { hostname: serverHostname } = server;
|
||||
|
||||
return generateEmbed({
|
||||
title: `${serverHostname} ${capitalizeFirstLetter(platform)} Server`,
|
||||
embedTitle: `${capitalizeFirstLetter(platform)} Server: ${serverHostname}`,
|
||||
description: description,
|
||||
image: favicon,
|
||||
description: "Click to view more information about the server.",
|
||||
image: `${config.apiEndpoint}/server/${platform}/preview/${serverHostname}`,
|
||||
cardType: "summary_large_image",
|
||||
});
|
||||
} catch (err) {
|
||||
// An error occurred
|
||||
|
@ -20,6 +20,11 @@ type Embed = {
|
||||
* The image to show as the thumbmail.
|
||||
*/
|
||||
image?: string;
|
||||
|
||||
/**
|
||||
* The type of the card.
|
||||
*/
|
||||
cardType?: "summary" | "summary_large_image";
|
||||
};
|
||||
|
||||
/**
|
||||
@ -29,13 +34,17 @@ type Embed = {
|
||||
* @param embedTitle the title of the embed
|
||||
* @param description the description of the embed
|
||||
* @param image the image to show as the thumbmail
|
||||
* @param cardType the type of the card
|
||||
* @returns the metadata for the embed
|
||||
*/
|
||||
export function generateEmbed({ title, embedTitle, description, image }: Embed): Metadata {
|
||||
export function generateEmbed({ title, embedTitle, description, image, cardType }: Embed): Metadata {
|
||||
// Fall back to the title
|
||||
if (!embedTitle) {
|
||||
embedTitle = title;
|
||||
}
|
||||
if (!cardType) {
|
||||
cardType = "summary";
|
||||
}
|
||||
|
||||
const metadata: Metadata = {
|
||||
title: `${title}`,
|
||||
@ -44,7 +53,7 @@ export function generateEmbed({ title, embedTitle, description, image }: Embed):
|
||||
description: description,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary",
|
||||
card: cardType,
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user