Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
Update status-widget.mdx (#920)
Frankiee1afa3cbde86
diff --git a/apps/docs/packages/status-widget.mdx b/apps/docs/packages/status-widget.mdxindex a8cdaf8b7..28550c3fc 100644--- a/apps/docs/packages/status-widget.mdx+++ b/apps/docs/packages/status-widget.mdx@@ -160,3 +160,122 @@ export async function StatusWidget({ slug }: { slug: string }) {);}```++Then, import your `StatusWidget.tsx` component to your layout as well as the slug prop to your specific monitor. Ideally, relative imports would be setup in your `tsconfig.json`.+```jsx+import StatusWidget from '../../components/StatusWidget.tsx++...++<StatusWidget slug="monitor-slug-here" />+```++### Astro Widget+```astro+---+import * as z from "zod"++const statusEnum = z.enum([+ "operational",+ "degraded_performance",+ "partial_outage",+ "major_outage",+ "under_maintenance",+ "unknown",+ "incident",+])++const statusSchema = z.object({ status: statusEnum })++const dictionary = {+ operational: {+ label: "Operational",+ color: "bg-green-500",+ },+ degraded_performance: {+ label: "Degraded Performance",+ color: "bg-yellow-500",+ },+ partial_outage: {+ label: "Partial Outage",+ color: "bg-yellow-500",+ },+ major_outage: {+ label: "Major Outage",+ color: "bg-red-500",+ },+ unknown: {+ label: "Unknown",+ color: "bg-gray-500",+ },+ incident: {+ label: "Incident",+ color: "bg-yellow-500",+ },+ under_maintenance: {+ label: "Under Maintenance",+ color: "bg-blue-500",+ },+}++const slug = Astro.props.slug++const res = await fetch(`https://api.openstatus.dev/public/status/${slug}`, {+ // @ts-ignore+ next: { revalidate: 60 },+})+const data = await res.json()+const parsed = statusSchema.safeParse(data)+if (!parsed.success) {+ return null+}+const key = parsed.data.status+const { label, color } = dictionary[key]+---++<a+ class="border-border text-foreground/70 hover:bg-muted hover:text-foreground inline-flex max-w-fit items-center gap-2 rounded-md border px-3 py-1 text-sm"+ href={`https://${slug}.openstatus.dev`}+ target="_blank"+ rel="noreferrer"+>+ {label}+ <span class="relative flex h-2 w-2">+ {+ parsed.data.status === "operational" ? (+ <span+ class:list={[+ "absolute",+ "inline-flex",+ "h-full",+ "w-full",+ "animate-ping",+ "rounded-full",+ color,+ "opacity-75",+ "duration-1000",+ ]}+ />+ ) : null+ }+ <span+ class:list={[+ "relative",+ "inline-flex",+ "h-2",+ "w-2",+ "rounded-full",+ color,+ ]}></span>+ </span>+</a>+```++Then, import your `StatusWidget.astro` component as well as the slug from your specific monitor to your layout, most likely your footer. It would be better to have relative imports setup in your tsconfig.json.+```astro+---+import StatusWidget from '../../components/StatusWidget.astro'+---++<StatusWidget slug="monitor-slug-here" />+```