Skip to content

Open-source status page, incident response and uptime monitoring

feat: web cmdk (#1671)

Maximilian Kaske95f490e9583b
diff --git a/apps/web/package.json b/apps/web/package.json
index 90e99c1fe..e737da8dd 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -81,8 +81,10 @@
"reading-time": "1.5.0",
"recharts": "2.15.0",
"resend": "6.6.0",
+ "sanitize-html": "2.17.0",
"schema-dts": "1.1.5",
"shiki": "0.14.4",
+ "slugify": "1.6.6",
"sonner": "2.0.5",
"stripe": "13.8.0",
"sugar-high": "0.9.5",
@@ -97,6 +99,7 @@
"@types/node": "24.0.8",
"@types/react": "19.2.2",
"@types/react-dom": "19.2.2",
+ "@types/sanitize-html": "2.16.0",
"postcss": "8.4.38",
"rehype-autolink-headings": "7.1.0",
"rehype-slug": "5.1.0",
diff --git a/apps/web/src/app/(landing)/content-list.tsx b/apps/web/src/app/(landing)/content-list.tsx
index 33ae5656b..251e5e597 100644
--- a/apps/web/src/app/(landing)/content-list.tsx
+++ b/apps/web/src/app/(landing)/content-list.tsx
@@ -30,7 +30,7 @@ export function ContentList({
</ContentListItemDate>
<ContentListItemTitle>{post.metadata.title}</ContentListItemTitle>
{withCategory ? (
- <span className="text-muted-foreground">
+ <span className="text-muted-foreground md:ml-auto">
[{post.metadata.category}]
</span>
) : null}
diff --git a/apps/web/src/app/api/search/route.ts b/apps/web/src/app/api/search/route.ts
new file mode 100644
index 000000000..9a6209112
--- /dev/null
+++ b/apps/web/src/app/api/search/route.ts
@@ -0,0 +1,248 @@
+import { slugify } from "@/content/mdx";
+import {
+ type MDXData,
+ getBlogPosts,
+ getChangelogPosts,
+ getComparePages,
+ getHomePage,
+ getProductPages,
+ getToolsPages,
+} from "@/content/utils";
+import sanitizeHtml from "sanitize-html";
+import { z } from "zod";
+
+const SearchSchema = z.object({
+ p: z
+ .enum(["blog", "changelog", "tools", "compare", "product", "all"])
+ .nullish(),
+ q: z.string().nullish(),
+});
+
+export type SearchParams = z.infer<typeof SearchSchema>;
+
+export async function GET(request: Request) {
+ const { searchParams } = new URL(request.url);
+ const query = searchParams.get("q");
+ const page = searchParams.get("p");
+
+ const params = SearchSchema.safeParse({
+ p: page,
+ q: query,
+ });
+
+ if (!params.success) {
+ console.error(params.error);
+ return new Response(JSON.stringify({ error: params.error.message }), {
+ status: 400,
+ });
+ }
+
+ if (!params.data.p) {
+ return new Response(JSON.stringify([]), {
+ status: 200,
+ });
+ }
+
+ const results = search(params.data).sort((a, b) => {
+ return b.metadata.publishedAt.getTime() - a.metadata.publishedAt.getTime();
+ });
+
+ return new Response(JSON.stringify(results), {
+ status: 200,
+ });
+}
+
+function search(params: SearchParams) {
+ const { p, q } = params;
+ let results: MDXData[] = [];
+
+ if (p === "blog") {
+ results = getBlogPosts();
+ } else if (p === "changelog") {
+ results = getChangelogPosts();
+ } else if (p === "tools") {
+ results = getToolsPages().filter((tool) => tool.slug !== "checker-slug");
+ } else if (p === "compare") {
+ results = getComparePages();
+ } else if (p === "product") {
+ const home = getHomePage();
+ // NOTE: we override /home with / for the home.mdx file
+ home.href = "/";
+ home.metadata.title = "Homepage";
+ results = [home, ...getProductPages()];
+ } else if (p === "all") {
+ const home = getHomePage();
+ // NOTE: we override /home with / for the home.mdx file
+ home.href = "/";
+ home.metadata.title = "Homepage";
+ results = [
+ ...getBlogPosts(),
+ ...getChangelogPosts(),
+ ...getToolsPages().filter((tool) => tool.slug !== "checker-slug"),
+ ...getComparePages(),
+ ...getProductPages(),
+ home,
+ ];
+ }
+
+ const searchMap = new Map<
+ string,
+ {
+ title: boolean;
+ content: boolean;
+ }
+ >();
+
+ results = results
+ .filter((result) => {
+ if (!q) return true;
+
+ const hasSearchTitle = result.metadata.title
+ .toLowerCase()
+ .includes(q.toLowerCase());
+ const hasSearchContent = result.content
+ .toLowerCase()
+ .includes(q.toLowerCase());
+
+ searchMap.set(result.slug, {
+ title: hasSearchTitle,
+ content: hasSearchContent,
+ });
+
+ return hasSearchTitle || hasSearchContent;
+ })
+ .map((result) => {
+ const search = searchMap.get(result.slug);
+
+ // Find the closest heading to the search match and add it as an anchor
+ let href = result.href;
+
+ // Add query parameter for highlighting
+ if (q) {
+ href = `${href}?q=${encodeURIComponent(q)}`;
+ }
+
+ if (q && search?.content) {
+ const headingSlug = findClosestHeading(result.content, q);
+ if (headingSlug) {
+ href = `${href}#${headingSlug}`;
+ }
+ }
+
+ const content =
+ search?.content || !search?.title
+ ? getContentSnippet(result.content, q)
+ : "";
+
+ return {
+ ...result,
+ content,
+ href,
+ };
+ });
+
+ return results;
+}
+
+const WORKDS_BEFORE = 2;
+const WORKDS_AFTER = 20;
+
+function getContentSnippet(
+ mdxContent: string,
+ searchQuery: string | null | undefined,
+): string {
+ if (!searchQuery) {
+ return `${mdxContent.slice(0, 100)}...`;
+ }
+
+ const content = sanitizeContent(mdxContent.toLowerCase());
+ const searchLower = searchQuery.toLowerCase();
+ const matchIndex = content.indexOf(searchLower);
+
+ if (matchIndex === -1) {
+ // No match found, return first 100 chars
+ return `${content.slice(0, 100)}...`;
+ }
+
+ // Find start of snippet (go back N words)
+ let start = matchIndex;
+ for (let i = 0; i < WORKDS_BEFORE && start > 0; i++) {
+ const prevSpace = content.lastIndexOf(" ", start - 2);
+ if (prevSpace === -1) break;
+ start = prevSpace + 1;
+ }
+
+ // Find end of snippet (go forward N words)
+ let end = matchIndex + searchQuery.length;
+ for (let i = 0; i < WORKDS_AFTER && end < content.length; i++) {
+ const nextSpace = content.indexOf(" ", end + 1);
+ if (nextSpace === -1) {
+ end = content.length;
+ break;
+ }
+ end = nextSpace;
+ }
+
+ // Extract snippet
+ let snippet = content.slice(start, end).trim();
+
+ if (!snippet) return snippet;
+
+ if (start > 0) snippet = `...${snippet}`;
+ if (end < content.length) snippet = `${snippet}...`;
+
+ return snippet;
+}
+
+export function sanitizeContent(input: string) {
+ return sanitizeHtml(input)
+ .replace(/<[^>]+>/g, "") // strip JSX tags
+ .replace(/^#{1,6}\s+/gm, "") // strip markdown heading symbols, keep text
+ .replace(/!\[.*?\]\(.*?\)/g, "") // strip images
+ .replace(/\[([^\]]+)\]\([^\)]+\)/g, "$1") // keep link text
+ .replace(/\*\*(.*?)\*\*/g, "$1") // strip bold
+ .replace(/__(.*?)__/g, "$1") // strip italic
+ .replace(/_(.*?)_/g, "$1") // strip underline
+ .replace(/[`*>~]/g, "") // strip most formatting
+ .replace(/\s+/g, " ") // collapse whitespace
+ .replace(/[<>]/g, (c) => (c === "<" ? "&lt;" : "&gt;")) // escape any remaining angle brackets
+ .trim();
+}
+
+/**
+ * Find the closest heading before the search match and return its slug
+ */
+function findClosestHeading(
+ mdxContent: string,
+ searchQuery: string | null | undefined,
+): string | null {
+ if (!searchQuery) return null;
+
+ const searchLower = searchQuery.toLowerCase();
+ const contentLower = mdxContent.toLowerCase();
+ const matchIndex = contentLower.indexOf(searchLower);
+
+ if (matchIndex === -1) return null;
+
+ // Look for headings before the match (## Heading, ### Heading, etc.)
+ const contentBeforeMatch = mdxContent.slice(0, matchIndex);
+ const headingRegex = /^#{1,6}\s+(.+)$/gm;
+ const headings: { text: string; index: number }[] = [];
+
+ let match = headingRegex.exec(contentBeforeMatch);
+ while (match !== null) {
+ headings.push({
+ text: match[1].trim(),
+ index: match.index,
+ });
+ match = headingRegex.exec(contentBeforeMatch);
+ }
+
+ // Return the closest heading (last one before the match)
+ if (headings.length > 0) {
+ const closestHeading = headings[headings.length - 1];
+ return slugify(closestHeading.text);
+ }
+
+ return null;
+}
diff --git a/apps/web/src/content/cmdk.tsx b/apps/web/src/content/cmdk.tsx
new file mode 100644
index 000000000..f271e87bb
--- /dev/null
+++ b/apps/web/src/content/cmdk.tsx
@@ -0,0 +1,452 @@
+"use client";
+
+import type { MDXData } from "@/content/utils";
+import { useDebounce } from "@/hooks/use-debounce";
+import { cn } from "@/lib/utils";
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandItem,
+ CommandList,
+ CommandLoading,
+ CommandSeparator,
+ CommandShortcut,
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from "@openstatus/ui";
+import { useQuery } from "@tanstack/react-query";
+import { Command as CommandPrimitive } from "cmdk";
+import { Loader2, Search } from "lucide-react";
+import { useTheme } from "next-themes";
+import { useRouter } from "next/navigation";
+import * as React from "react";
+
+type ConfigItem = {
+ type: "item";
+ label: string;
+ href: string;
+ shortcut?: string;
+};
+
+type ConfigGroup = {
+ type: "group";
+ label: string;
+ heading: string;
+ page: string;
+};
+
+type ConfigSection = {
+ type: "group";
+ heading: string;
+ items: (ConfigItem | ConfigGroup)[];
+};
+
+// TODO: missing shortcuts
+const CONFIG: ConfigSection[] = [
+ {
+ type: "group",
+ heading: "Resources",
+ items: [
+ {
+ type: "group",
+ label: "Search in all pages...",
+ heading: "All pages",
+ page: "all",
+ },
+ {
+ type: "item",
+ label: "Go to Pricing",
+ href: "/pricing",
+ },
+ {
+ type: "item",
+ label: "Go to Docs",
+ href: "https://docs.openstatus.dev",
+ },
+ {
+ type: "item",
+ label: "Go to Global Speed Checker",
+ href: "/play/checker",
+ shortcut: "⌘G",
+ },
+ {
+ type: "group",
+ label: "Search in Products...",
+ heading: "Products",
+ page: "product",
+ },
+ {
+ type: "group",
+ label: "Search in Blog...",
+ heading: "Blog",
+ page: "blog",
+ },
+ {
+ type: "group",
+ label: "Search in Changelog...",
+ heading: "Changelog",
+ page: "changelog",
+ },
+ {
+ type: "group",
+ label: "Search in Tools...",
+ heading: "Tools",
+ page: "tools",
+ },
+ {
+ type: "group",
+ label: "Search in Compare...",
+ heading: "Compare",
+ page: "compare",
+ },
+ {
+ type: "item",
+ label: "Go to About",
+ href: "/about",
+ },
+ {
+ type: "item",
+ label: "Book a call",
+ href: "/cal",
+ },
+ ],
+ },
+
+ {
+ type: "group",
+ heading: "Community",
+ items: [
+ {
+ type: "item",
+ label: "Discord",
+ href: "/discord",
+ },
+ {
+ type: "item",
+ label: "GitHub",
+ href: "/github",
+ },
+ {
+ type: "item",
+ label: "X",
+ href: "/x",
+ },
+ {
+ type: "item",
+ label: "BlueSky",
+ href: "/bluesky",
+ },
+ {
+ type: "item",
+ label: "YouTube",
+ href: "/youtube",
+ },
+ {
+ type: "item",
+ label: "LinkedIn",
+ href: "/linkedin",
+ },
+ ],
+ },
+];
+
+export function CmdK() {
+ const [open, setOpen] = React.useState(false);
+ const inputRef = React.useRef<HTMLInputElement | null>(null);
+ const listRef = React.useRef<HTMLDivElement | null>(null);
+ const resetTimerRef = React.useRef<NodeJS.Timeout | undefined>(undefined);
+ const [search, setSearch] = React.useState("");
+ const [pages, setPages] = React.useState<string[]>([]);
+ const debouncedSearch = useDebounce(search, 300);
+ const router = useRouter();
+
+ const page = pages.length > 0 ? pages[pages.length - 1] : null;
+
+ const {
+ data: items = [],
+ isLoading: loading,
+ isFetching: fetching,
+ } = useQuery({
+ queryKey: ["search", page, debouncedSearch],
+ queryFn: async () => {
+ if (!page) return [];
+ const searchParams = new URLSearchParams();
+ searchParams.set("p", page);
+ if (debouncedSearch) searchParams.set("q", debouncedSearch);
+ const promise = fetch(`/api/search?${searchParams.toString()}`);
+ // NOTE: artificial delay to avoid flickering
+ const delay = new Promise((r) => setTimeout(r, 300));
+ const [res, _] = await Promise.all([promise, delay]);
+ return res.json();
+ },
+ placeholderData: (previousData) => previousData,
+ });
+
+ const resetSearch = React.useCallback(() => setSearch(""), []);
+
+ React.useEffect(() => {
+ const down = (e: KeyboardEvent) => {
+ if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ setOpen((open) => !open);
+ }
+
+ // Handle shortcuts when dialog is open
+ if (open && (e.metaKey || e.ctrlKey)) {
+ const key = e.key.toLowerCase();
+
+ // Find matching shortcut in CONFIG
+ for (const section of CONFIG) {
+ for (const item of section.items) {
+ if (item.type === "item" && item.shortcut) {
+ const shortcutKey = item.shortcut.replace("⌘", "").toLowerCase();
+ if (key === shortcutKey) {
+ e.preventDefault();
+ router.push(item.href);
+ setOpen(false);
+ return;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ document.addEventListener("keydown", down);
+ return () => document.removeEventListener("keydown", down);
+ }, [open, router]);
+
+ React.useEffect(() => {
+ inputRef.current?.focus();
+ }, []);
+
+ // NOTE: Reset search and pages after dialog closes (with delay for animation)
+ // - if within 1 second of closing, the dialog will not reset
+ React.useEffect(() => {
+ const DELAY = 1000;
+
+ if (!open && items.length > 0) {
+ if (resetTimerRef.current) {
+ clearTimeout(resetTimerRef.current);
+ }
+ resetTimerRef.current = setTimeout(() => {
+ setSearch("");
+ setPages([]);
+ }, DELAY);
+ }
+
+ if (open && resetTimerRef.current) {
+ clearTimeout(resetTimerRef.current);
+ resetTimerRef.current = undefined;
+ }
+
+ return () => {
+ if (resetTimerRef.current) {
+ clearTimeout(resetTimerRef.current);
+ }
+ };
+ }, [open, items.length]);
+
+ return (
+ <>
+ <button
+ type="button"
+ className={cn(
+ "flex w-full items-center text-left hover:bg-muted",
+ open && "bg-muted!",
+ )}
+ onClick={() => setOpen(true)}
+ >
+ <span>
+ Search<span className="text-muted-foreground text-xs">...</span>
+ </span>
+ <kbd className="ml-auto bg-muted text-muted-foreground pointer-events-none inline-flex h-5 items-center gap-1 border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none">
+ <span className="text-xs">⌘</span>K
+ </kbd>
+ </button>
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogContent className="overflow-hidden rounded-none p-0 font-mono shadow-2xl">
+ <DialogTitle className="sr-only">Search</DialogTitle>
+ <Command
+ onKeyDown={(e) => {
+ // e.key === "Escape" ||
+ if (e.key === "Backspace" && !search) {
+ e.preventDefault();
+ setPages((pages) => pages.slice(0, -1));
+ }
+ }}
+ shouldFilter={!page}
+ className="rounded-none"
+ >
+ <div
+ className="flex items-center border-b px-3"
+ cmdk-input-wrapper=""
+ >
+ {loading || fetching ? (
+ <Loader2 className="mr-2 h-4 w-4 shrink-0 animate-spin opacity-50" />
+ ) : (
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ )}
+ <CommandPrimitive.Input
+ className="flex h-11 w-full rounded-none bg-transparent py-3 text-sm outline-hidden placeholder:text-foreground-muted disabled:cursor-not-allowed disabled:opacity-50"
+ placeholder="Type to search…"
+ value={search}
+ onValueChange={setSearch}
+ />
+ </div>
+ <CommandList ref={listRef} className="[&_[cmdk-item]]:rounded-none">
+ <CommandEmpty>No results found.</CommandEmpty>
+ {loading && !items.length ? (
+ <CommandLoading>Searching...</CommandLoading>
+ ) : null}
+ {!page ? (
+ <Home
+ setPages={setPages}
+ resetSearch={resetSearch}
+ setOpen={setOpen}
+ />
+ ) : null}
+ {items.length > 0 ? (
+ <SearchResults
+ items={items}
+ search={search}
+ setOpen={setOpen}
+ page={page}
+ />
+ ) : null}
+ </CommandList>
+ </Command>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+}
+
+function Home({
+ setPages,
+ resetSearch,
+ setOpen,
+}: {
+ setPages: React.Dispatch<React.SetStateAction<string[]>>;
+ resetSearch: () => void;
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
+}) {
+ const router = useRouter();
+ const { resolvedTheme, setTheme } = useTheme();
+
+ return (
+ <>
+ {CONFIG.map((group, groupIndex) => (
+ <React.Fragment key={group.heading}>
+ {groupIndex > 0 && <CommandSeparator />}
+ <CommandGroup heading={group.heading}>
+ {group.items.map((item) => {
+ if (item.type === "item") {
+ return (
+ <CommandItem
+ key={item.label}
+ onSelect={() => {
+ router.push(item.href);
+ setOpen(false);
+ }}
+ >
+ <span>{item.label}</span>
+ {item.shortcut && (
+ <CommandShortcut>{item.shortcut}</CommandShortcut>
+ )}
+ </CommandItem>
+ );
+ }
+ if (item.type === "group") {
+ return (
+ <CommandItem
+ key={item.page}
+ onSelect={() => {
+ setPages((pages) => [...pages, item.page]);
+ resetSearch();
+ }}
+ >
+ <span>{item.label}</span>
+ </CommandItem>
+ );
+ }
+ return null;
+ })}
+ </CommandGroup>
+ </React.Fragment>
+ ))}
+ <CommandSeparator />
+ <CommandGroup heading="Settings">
+ <CommandItem
+ onSelect={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
+ >
+ <span>
+ Switch to {resolvedTheme === "dark" ? "light" : "dark"} theme
+ </span>
+ </CommandItem>
+ </CommandGroup>
+ </>
+ );
+}
+
+function SearchResults({
+ items,
+ search,
+ setOpen,
+ page,
+}: {
+ items: MDXData[];
+ search: string;
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
+ page: string | null;
+}) {
+ const router = useRouter();
+
+ const _page = CONFIG[0].items.find(
+ (item) => item.type === "group" && item.page === page,
+ ) as ConfigGroup | undefined;
+
+ return (
+ <CommandGroup heading={_page?.heading ?? "Search Results"}>
+ {items.map((item) => {
+ // Highlight search term match in the title, case-insensitive
+ const title = item.metadata.title.replace(
+ new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i"),
+ (match) => `<mark>${match}</mark>`,
+ );
+ const html = item.content.replace(
+ new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i"),
+ (match) => `<mark>${match}</mark>`,
+ );
+
+ return (
+ <CommandItem
+ key={item.slug}
+ keywords={[item.metadata.title, item.content, search]}
+ onSelect={() => {
+ router.push(item.href);
+ setOpen(false);
+ }}
+ >
+ <div className="grid min-w-0">
+ <span
+ className="block truncate"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
+ dangerouslySetInnerHTML={{ __html: title }}
+ />
+ {item.content && search ? (
+ <span
+ className="block truncate text-muted-foreground text-xs"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
+ dangerouslySetInnerHTML={{ __html: html }}
+ />
+ ) : null}
+ </div>
+ </CommandItem>
+ );
+ })}
+ </CommandGroup>
+ );
+}
diff --git a/apps/web/src/content/footer.tsx b/apps/web/src/content/footer.tsx
index 1a0d6954f..066b5bd36 100644
--- a/apps/web/src/content/footer.tsx
+++ b/apps/web/src/content/footer.tsx
@@ -26,14 +26,12 @@ export function Footer() {
))}
</div>
<div className="grid gap-px border border-border border-t-0 bg-border sm:grid-cols-2 md:grid-cols-3 [&>*]:bg-background">
- <div>
- <Link
- href="/cal"
- className="flex w-full items-center gap-2 p-4 hover:bg-muted"
- >
- Talk to the founders
- </Link>
- </div>
+ <Link
+ href="/cal"
+ className="flex w-full items-center gap-2 p-4 hover:bg-muted"
+ >
+ Talk to the founders
+ </Link>
<div>
<FooterStatus />
</div>
diff --git a/apps/web/src/content/header.tsx b/apps/web/src/content/header.tsx
index 1ad83be94..b1a0e1c67 100644
--- a/apps/web/src/content/header.tsx
+++ b/apps/web/src/content/header.tsx
@@ -12,6 +12,7 @@ import {
ContextMenuTrigger,
} from "@openstatus/ui";
import Link from "next/link";
+import { CmdK } from "./cmdk";
export function Header() {
return (
@@ -86,9 +87,7 @@ export function Header() {
<Link href="/pricing" className="truncate">
Pricing
</Link>
- <Link href="https://docs.openstatus.dev" className="truncate">
- Docs
- </Link>
+ <CmdK />
<Link
href="https://app.openstatus.dev/login"
className="truncate text-info"
diff --git a/apps/web/src/content/highlight-text.tsx b/apps/web/src/content/highlight-text.tsx
new file mode 100644
index 000000000..02324dbfc
--- /dev/null
+++ b/apps/web/src/content/highlight-text.tsx
@@ -0,0 +1,45 @@
+"use client";
+
+import { useSearchParams } from "next/navigation";
+import { useEffect, useRef } from "react";
+
+function highlight(root: HTMLElement, query: string) {
+ if (!query) return;
+
+ const regex = new RegExp(`(${query})`, "gi");
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null);
+
+ const textNodes: Text[] = [];
+ let node = walker.nextNode();
+
+ while (node) {
+ if (node instanceof Text) {
+ textNodes.push(node);
+ }
+ node = walker.nextNode();
+ }
+
+ for (const textNode of textNodes) {
+ const nodeValue = textNode.nodeValue;
+ if (!nodeValue || !regex.test(nodeValue)) continue;
+
+ const span = document.createElement("span");
+ span.innerHTML = nodeValue.replace(regex, "<mark>$1</mark>");
+
+ textNode.parentNode?.replaceChild(span, textNode);
+ }
+}
+
+export function HighlightText({ children }: { children: React.ReactNode }) {
+ const ref = useRef<HTMLDivElement>(null);
+ const searchParams = useSearchParams();
+ const q = searchParams.get("q");
+
+ useEffect(() => {
+ if (ref.current && q) {
+ highlight(ref.current, q);
+ }
+ }, [q]);
+
+ return <div ref={ref}>{children}</div>;
+}
diff --git a/apps/web/src/content/mdx.tsx b/apps/web/src/content/mdx.tsx
index 6f373a969..7bb2f79dc 100644
--- a/apps/web/src/content/mdx.tsx
+++ b/apps/web/src/content/mdx.tsx
@@ -9,6 +9,7 @@ import React from "react";
import { Tweet, type TweetProps } from "react-tweet";
import { highlight } from "sugar-high";
import { CopyButton } from "./copy-button";
+import { HighlightText } from "./highlight-text";
import { ImageZoom } from "./image-zoom";
import { LatencyChartTable } from "./latency-chart-table";
@@ -183,7 +184,7 @@ function Pre({ children, ...props }: React.ComponentProps<"pre">) {
);
}
-function slugify(str: string) {
+export function slugify(str: string) {
return str
.toString()
.toLowerCase()
@@ -360,14 +361,18 @@ export const components = {
export function CustomMDX(props: MDXRemoteProps) {
return (
- <MDXRemote
- {...props}
- components={
- {
- ...components,
- ...(props.components || {}),
- } as MDXRemoteProps["components"]
- }
- />
+ <React.Suspense>
+ <HighlightText>
+ <MDXRemote
+ {...props}
+ components={
+ {
+ ...components,
+ ...(props.components || {}),
+ } as MDXRemoteProps["components"]
+ }
+ />
+ </HighlightText>
+ </React.Suspense>
);
}
diff --git a/apps/web/src/content/utils.ts b/apps/web/src/content/utils.ts
index 6f3a63762..f77803c29 100644
--- a/apps/web/src/content/utils.ts
+++ b/apps/web/src/content/utils.ts
@@ -1,5 +1,6 @@
import fs from "node:fs";
import path from "node:path";
+import slugify from "slugify";
import { z } from "zod";
const metadataSchema = z.object({
@@ -47,20 +48,23 @@ function readMDXFile(filePath: string) {
return parseFrontmatter(rawContent);
}
-function getMDXDataFromDir(dir: string) {
+function getMDXDataFromDir(dir: string, prefix = "") {
const mdxFiles = getMDXFiles(dir);
return mdxFiles.map((file) => {
- return getMDXDataFromFile(path.join(dir, file));
+ return getMDXDataFromFile(path.join(dir, file), prefix);
});
}
-function getMDXDataFromFile(filePath: string) {
+function getMDXDataFromFile(filePath: string, prefix = "") {
const { metadata, content } = readMDXFile(filePath);
- const slug = path.basename(filePath, path.extname(filePath));
+ const slugRaw = path.basename(filePath, path.extname(filePath));
+ const slug = slugify(slugRaw, { lower: true, strict: true });
+ const href = prefix ? `${prefix}/${slug}` : `/${slug}`;
return {
metadata,
slug,
content,
+ href,
};
}
@@ -69,24 +73,28 @@ export type MDXData = ReturnType<typeof getMDXDataFromFile>;
export function getBlogPosts(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "blog"),
+ "/blog",
);
}
export function getChangelogPosts(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "changelog"),
+ "/changelog",
);
}
export function getProductPages(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "product"),
+ "",
);
}
export function getUnrelatedPages(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "unrelated"),
+ "",
);
}
@@ -100,6 +108,7 @@ export function getUnrelatedPage(slug: string): MDXData {
"unrelated",
`${slug}.mdx`,
),
+ "",
);
}
@@ -110,27 +119,44 @@ export function getMainPages(): MDXData[] {
export function getComparePages(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "compare"),
+ "/compare",
);
}
export function getHomePage(): MDXData {
return getMDXDataFromFile(
path.join(process.cwd(), "src", "content", "pages", "home.mdx"),
+ "",
);
}
export function getToolsPages(): MDXData[] {
return getMDXDataFromDir(
path.join(process.cwd(), "src", "content", "pages", "tools"),
+ "/play",
);
}
export function getToolsPage(slug: string): MDXData {
return getMDXDataFromFile(
path.join(process.cwd(), "src", "content", "pages", "tools", `${slug}.mdx`),
+ "/play",
);
}
+export function getCategories() {
+ return [
+ ...new Set([
+ ...getBlogPosts().map((post) => post.metadata.category),
+ ...getChangelogPosts().map((post) => post.metadata.category),
+ ...getProductPages().map((post) => post.metadata.category),
+ ...getUnrelatedPages().map((post) => post.metadata.category),
+ ...getComparePages().map((post) => post.metadata.category),
+ ...getToolsPages().map((post) => post.metadata.category),
+ ]),
+ ] as const;
+}
+
export function formatDate(targetDate: Date, includeRelative = false) {
const currentDate = new Date();
diff --git a/apps/web/src/data/content.ts b/apps/web/src/data/content.ts
index 56a5fdf9d..c4ddd73ca 100644
--- a/apps/web/src/data/content.ts
+++ b/apps/web/src/data/content.ts
@@ -48,6 +48,10 @@ const resourcesFooterSection = {
const resourcesHeaderSection = {
label: "Resources",
items: [
+ {
+ label: "Docs",
+ href: "https://docs.openstatus.dev",
+ },
{
label: "Blog",
href: "/blog",
@@ -64,10 +68,6 @@ const resourcesHeaderSection = {
label: "Compare",
href: "/compare",
},
- {
- label: "Playground (Tools)",
- href: "/play",
- },
],
};
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 425d34c8b..9991a09fd 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -47,7 +47,7 @@
"@radix-ui/react-tooltip": "1.1.6",
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
- "cmdk": "1.0.4",
+ "cmdk": "1.1.1",
"date-fns": "2.30.0",
"lucide-react": "0.525.0",
"luxon": "3.5.0",
diff --git a/packages/ui/src/components/command.tsx b/packages/ui/src/components/command.tsx
index 7ea0314c2..ed119d428 100644
--- a/packages/ui/src/components/command.tsx
+++ b/packages/ui/src/components/command.tsx
@@ -142,11 +142,24 @@ const CommandShortcut = ({
};
CommandShortcut.displayName = "CommandShortcut";
+const CommandLoading = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Loading>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Loading>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Loading
+ ref={ref}
+ className={cn("px-2 py-1.5 text-sm", className)}
+ {...props}
+ />
+));
+CommandLoading.displayName = CommandPrimitive.Loading.displayName;
+
export {
Command,
CommandDialog,
CommandInput,
CommandList,
+ CommandLoading,
CommandEmpty,
CommandGroup,
CommandItem,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5bf31412e..13a0752bc 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -991,12 +991,18 @@ importers:
resend:
specifier: 6.6.0
+ sanitize-html:
+ specifier: 2.17.0
+ version: 2.17.0
schema-dts:
specifier: 1.1.5
version: 1.1.5
shiki:
specifier: 0.14.4
version: 0.14.4
+ slugify:
+ specifier: 1.6.6
+ version: 1.6.6
sonner:
specifier: 2.0.5
@@ -1034,6 +1040,9 @@ importers:
'@types/react-dom':
specifier: 19.2.2
version: 19.2.2(@types/[email protected])
+ '@types/sanitize-html':
+ specifier: 2.16.0
+ version: 2.16.0
postcss:
specifier: 8.4.38
version: 8.4.38
@@ -1126,7 +1135,7 @@ importers:
version: 2.6.2
drizzle-orm:
specifier: 0.44.4
- version: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
+ version: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
effect:
specifier: 3.19.12
version: 3.19.12
@@ -1145,7 +1154,7 @@ importers:
version: link:../../packages/tsconfig
'@types/bun':
specifier: latest
- version: 1.3.4
+ version: 1.3.5
typescript:
specifier: 5.9.3
version: 5.9.3
@@ -1301,10 +1310,10 @@ importers:
drizzle-orm:
specifier: 0.44.4
- version: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
+ version: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
drizzle-zod:
specifier: 0.5.1
zod:
specifier: 3.25.76
version: 3.25.76
@@ -1933,8 +1942,8 @@ importers:
specifier: 2.1.1
version: 2.1.1
cmdk:
- specifier: 1.0.4
+ specifier: 1.1.1
date-fns:
specifier: 2.30.0
version: 2.30.0
@@ -6224,8 +6233,8 @@ packages:
resolution: {integrity: sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w==}
- '@types/[email protected]':
- resolution: {integrity: sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w==}
resolution: {integrity: sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==}
@@ -6377,6 +6386,9 @@ packages:
resolution: {integrity: sha512-FGJ6udDNUCjd19pp0Q3iTiDkwhYup7J8hpMW9c4k53NrccQFFWKRho6hvtPPEhnXWKvukfwAlB6DbDz4yhH5Gg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-l6rX1MUXje5ztPT0cAFtUayXF06DqPhRyfVXareEN5gGCFaP/iwsxIyKODr9XDhfxPpN6vXUFNfo5kZMXCxBtw==}
+
resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==}
@@ -6423,6 +6435,7 @@ packages:
'@upstash/[email protected]':
resolution: {integrity: sha512-CIr657FZuK+IMuwcxkj3oCB6xKO+LMlHd4BL4J/Lwbpj6+5YHO+5ZcpdMIQhbcemthJcRtE0gDUfZEnrfb3Rjg==}
engines: {node: '>=10'}
+ deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
'@upstash/[email protected]':
resolution: {integrity: sha512-aB/1yqMJTRyOt7Go2Db1ZIVnmTPpsc2KGY5jpLVcegNtjksaPTJF6fmITxos5HVvsQhS8IB3gvF/+gQfRQlPLQ==}
@@ -6799,8 +6812,8 @@ packages:
peerDependencies:
'@types/react': ^19
- resolution: {integrity: sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ==}
+ resolution: {integrity: sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw==}
resolution: {integrity: sha512-7Q/6vkyYAwOmQNRw75x+4yRtZCZJXUDmHHlFdkiV0wgv/reNjtJwpu1jPJ0w2kbEpIM0uoKI3S4/f39dU7AjSA==}
@@ -6958,12 +6971,6 @@ packages:
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
engines: {node: '>=6'}
- resolution: {integrity: sha512-AnsjfHyHpQ/EFeAnG216WY7A5LiYCoZzCSygiLvfXC3H3LFGCprErteUcszaVluGOhuOTbJS3jWHrSDYPBBygg==}
- peerDependencies:
- react: ^18 || ^19 || ^19.0.0-rc
- react-dom: ^18 || ^19 || ^19.0.0-rc
-
resolution: {integrity: sha512-Vsv7kFaXm+ptHDMZ7izaRsP70GgrW9NBNGswt9OZaVBLlE0SNpDq8eu/VGXyF9r7M0azK3Wy7OlYXsuyYLFzHg==}
peerDependencies:
@@ -8266,6 +8273,10 @@ packages:
resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}
@@ -9250,6 +9261,9 @@ packages:
resolution: {integrity: sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==}
+ resolution: {integrity: sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==}
+
resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}
@@ -9869,6 +9883,9 @@ packages:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
+ resolution: {integrity: sha512-dLAADUSS8rBwhaevT12yCezvioCA+bmUTPH/u57xKPT8d++voeYE6HeluA/bPbQ15TwDBG2ii+QZIEmYx8VdxA==}
+
resolution: {integrity: sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==}
@@ -9975,6 +9992,10 @@ packages:
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==}
+ engines: {node: '>=8.0.0'}
+
resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
@@ -15807,9 +15828,9 @@ snapshots:
'@types/[email protected]': {}
- '@types/[email protected]':
+ '@types/[email protected]':
dependencies:
- bun-types: 1.3.4
+ bun-types: 1.3.5
'@types/[email protected]': {}
@@ -15976,6 +15997,10 @@ snapshots:
'@types/tough-cookie': 4.0.5
form-data: 2.5.5
+ '@types/[email protected]':
+ dependencies:
+ htmlparser2: 8.0.2
+
dependencies:
'@types/node': 24.0.8
@@ -16560,7 +16585,7 @@ snapshots:
'@types/node': 24.0.8
'@types/react': 19.2.2
dependencies:
'@types/node': 24.0.8
@@ -16715,18 +16740,6 @@ snapshots:
- dependencies:
- '@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])
- react: 19.2.2
- react-dom: 19.2.2([email protected])
- use-sync-external-store: 1.6.0([email protected])
- transitivePeerDependencies:
- - '@types/react'
- - '@types/react-dom'
-
dependencies:
'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
@@ -17078,16 +17091,16 @@ snapshots:
transitivePeerDependencies:
- supports-color
optionalDependencies:
'@libsql/client': 0.15.15
'@opentelemetry/api': 1.9.0
'@types/pg': 8.15.6
- bun-types: 1.3.4
+ bun-types: 1.3.5
dependencies:
- drizzle-orm: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
+ drizzle-orm: 0.44.4(@libsql/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
zod: 3.25.76
@@ -18233,6 +18246,8 @@ snapshots:
+
@@ -19489,6 +19504,8 @@ snapshots:
unist-util-visit-children: 3.0.0
vfile: 6.0.3
+
dependencies:
entities: 6.0.1
@@ -20255,6 +20272,15 @@ snapshots:
+ dependencies:
+ deepmerge: 4.3.1
+ escape-string-regexp: 4.0.0
+ htmlparser2: 8.0.2
+ is-plain-object: 5.0.0
+ parse-srcset: 1.0.2
+ postcss: 8.4.38
+
@@ -20474,6 +20500,8 @@ snapshots:
+