fix(docs+ui): add MDX frontmatter to Codex CLI guide, fix setState-in-effect lint

- docs/guides/CODEX-CLI-CONFIGURATION.md was missing the YAML frontmatter
  block required by fumadocs (title/version/lastUpdated), causing the
  production build to fail with "invalid frontmatter" MDX error.
- CodexCliGuideModal.tsx called setLoading/setError synchronously in a
  useEffect body, triggering the react-hooks/set-state-in-effect lint error.
  Refactored to an internal async function with an `cancelled` guard to
  prevent state updates on unmounted components.
This commit is contained in:
diegosouzapw
2026-06-08 08:37:51 -03:00
parent 67d79f6c44
commit e328e257d1
2 changed files with 25 additions and 10 deletions

View File

@@ -1,3 +1,9 @@
---
title: "Codex CLI — Configuration with OmniRoute"
version: 3.8.16
lastUpdated: 2026-06-08
---
# Codex CLI — Configuration with OmniRoute
Complete guide for using the Codex CLI pointed at OmniRoute as an OpenAI-compatible backend.

View File

@@ -125,17 +125,26 @@ export default function CodexCliGuideModal({ isOpen, onClose }: CodexCliGuideMod
useEffect(() => {
if (!isOpen || content) return;
setLoading(true);
setError(false);
fetch("/api/docs/codex-cli")
.then((res) => {
let cancelled = false;
const load = async () => {
setLoading(true);
setError(false);
try {
const res = await fetch("/api/docs/codex-cli");
if (!res.ok) throw new Error(`${res.status}`);
return res.json() as Promise<{ content: string }>;
})
.then((data) => setContent(data.content))
.catch(() => setError(true))
.finally(() => setLoading(false));
const data = (await res.json()) as { content: string };
if (!cancelled) setContent(data.content);
} catch {
if (!cancelled) setError(true);
} finally {
if (!cancelled) setLoading(false);
}
};
void load();
return () => {
cancelled = true;
};
}, [isOpen, content]);
return (