Skip to content

Commit 52a3c6e

Browse files
committed
fix: set artifact page titles
1 parent 39258e3 commit 52a3c6e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

client/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
} from "../shared/config";
2727

2828
const client = createClient<typeof app>();
29+
const DEFAULT_DOCUMENT_TITLE = "Codex Artifacts";
2930
const KNOWN_EMAILS_KEY = "codex-artifacts:known-emails";
3031
const EXPIRATION_OPTIONS = [
3132
{ label: "1 hour", value: "3600" },
@@ -598,6 +599,17 @@ function ArtifactFrame({ requestedSlug }: { requestedSlug?: string }) {
598599
const accessBootstrap = useAccessBootstrap();
599600
const [accessState, setAccessState] = useState<"idle" | "accepting" | "accepted" | "denied">("idle");
600601
const [copied, setCopied] = useState(false);
602+
603+
useEffect(() => {
604+
document.title = artifact
605+
? `${artifact.title} · ${DEFAULT_DOCUMENT_TITLE}`
606+
: DEFAULT_DOCUMENT_TITLE;
607+
608+
return () => {
609+
document.title = DEFAULT_DOCUMENT_TITLE;
610+
};
611+
}, [artifact?.title]);
612+
601613
const downloadUrl = useMemo(() => {
602614
if (!artifact) return "";
603615
return URL.createObjectURL(new Blob([artifact.html], { type: "text/html;charset=utf-8" }));
@@ -734,6 +746,12 @@ function AppContent() {
734746
location.pathname.startsWith("/a/") ||
735747
(location.pathname === "/" && Boolean(requestedSlug));
736748

749+
useEffect(() => {
750+
if (!isArtifactRoute) {
751+
document.title = DEFAULT_DOCUMENT_TITLE;
752+
}
753+
}, [isArtifactRoute]);
754+
737755
return (
738756
<div className="min-h-screen bg-slate-950 text-slate-100 selection:bg-cyan-300 selection:text-slate-950">
739757
<div className="pointer-events-none fixed inset-0 bg-[radial-gradient(circle_at_top_left,rgba(34,211,238,0.08),transparent_30%),radial-gradient(circle_at_85%_10%,rgba(59,130,246,0.08),transparent_28%)]" />

0 commit comments

Comments
 (0)