@matthiesenxyz/astro-mcserverstatus v0.1.0
Astro-MCServerStatus
Astro components and helper functions to get your minecraft server displayed on your astro SSR website!
Usage
Prerequisites
- Astro SSR project with an Adapter Setup* (This will be changed later once non SSR components are added)
Installation
Install the integration automatically using the Astro CLI:
pnpm astro add @matthiesenxyz/astro-mcserverstatusnpx astro add @matthiesenxyz/astro-mcserverstatusyarn astro add @matthiesenxyz/astro-mcserverstatusOr install it manually:
- Install the required dependencies
pnpm add @matthiesenxyz/astro-mcserverstatusnpm install @matthiesenxyz/astro-mcserverstatusyarn add @matthiesenxyz/astro-mcserverstatus- Add the integration to your astro config
+import mcServerStatus from "@matthiesenxyz/astro-mcserverstatus";
export default defineConfig({
integrations: [
+ mcServerStatus({
+ serverAddress: "your.serverip.here",
+ serverPort: 25565 //OPTIONAL - Default is: `25565`
+ }),
],
});Basic Usage
This integration has multiple ways to use it. Currently this integration is only supported while output: "server" is enabled in your astro config* (Until Static compatible components are released)
Once you have the server details configured in your astro project you can now use the components from the virtual module!
Example usage:
// src/pages/index.astro (without a Layout defined)
---
import { ServerIcon, ServerBanner, OnlinePlayerList } from "astro-mcserverstatus:components/ssr"
import { getServerIcon } from "astro-mcserverstatus:components/api"
const favicon = await getServerIcon()
---
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<link rel="icon" type="image/x-icon" href={favicon}>
</head>
<body>
<h1>Example</h1>
<div>
<h2>Server Icon without Banner</h2>
<ServerIcon />
</div>
<div>
<h2>Server Banner</h2>
<ServerBanner/>
</div>
<div>
<h3>Online Player List</h3>
<OnlinePlayerList />
</div>
</html>Contributing
This package is structured as a monorepo:
playgroundcontains code for testing the packagepackagecontains the actual package
Install dependencies using pnpm:
pnpm i --frozen-lockfileStart the playground and package watcher:
pnpm devYou can now edit files in package. Please note that making changes to those files may require restarting the playground dev server.
Licensing
MIT Licensed. Made with ❤️ by Adam Matthiesen.
1 year ago