Add MineGeo gameplay systems and interface
This commit is contained in:
65
components/CommunityLinks.tsx
Normal file
65
components/CommunityLinks.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import "server-only";
|
||||
import { MessageCircle, Send, ArrowUpRight } from "lucide-react";
|
||||
import { getI18n } from "@/lib/i18n";
|
||||
|
||||
function communityUrl(value: string | undefined, hosts: readonly string[]) {
|
||||
if (!value?.trim()) return null;
|
||||
try {
|
||||
const url = new URL(value.trim());
|
||||
if (
|
||||
url.protocol !== "https:" ||
|
||||
url.username ||
|
||||
url.password ||
|
||||
url.port ||
|
||||
!hosts.includes(url.hostname) ||
|
||||
url.pathname === "/"
|
||||
)
|
||||
return null;
|
||||
return url.href;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function CommunityLinks() {
|
||||
const { t } = await getI18n();
|
||||
const discord = communityUrl(process.env.MINEGEO_DISCORD_URL, [
|
||||
"discord.gg",
|
||||
"discord.com",
|
||||
"www.discord.com",
|
||||
"discordapp.com",
|
||||
]);
|
||||
const telegram = communityUrl(process.env.MINEGEO_TELEGRAM_URL, [
|
||||
"t.me",
|
||||
"telegram.me",
|
||||
]);
|
||||
if (!discord && !telegram) return null;
|
||||
return (
|
||||
<div className="community-links" role="group" aria-label={t("Community")}>
|
||||
{discord && (
|
||||
<a
|
||||
className="community-link community-discord"
|
||||
href={discord}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<MessageCircle size={18} aria-hidden="true" />
|
||||
{t("Join us on Discord")}
|
||||
<ArrowUpRight size={14} aria-hidden="true" />
|
||||
</a>
|
||||
)}
|
||||
{telegram && (
|
||||
<a
|
||||
className="community-link community-telegram"
|
||||
href={telegram}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Send size={18} aria-hidden="true" />
|
||||
{t("Follow us on Telegram")}
|
||||
<ArrowUpRight size={14} aria-hidden="true" />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user