import { useState } from "react"; import { useNavigate, useSearchParams, Link } from "react-router-dom"; import { useAuth } from "../context/AuthContext"; import Composer from "../components/Composer"; export default function New() { const { isAuthenticated, loading } = useAuth(); const navigate = useNavigate(); const [searchParams] = useSearchParams(); const initialUrl = searchParams.get("url") || ""; let initialSelector = null; const selectorParam = searchParams.get("selector"); if (selectorParam) { try { initialSelector = JSON.parse(selectorParam); } catch (e) { console.error("Failed to parse selector:", e); } } const legacyQuote = searchParams.get("quote") || ""; if (legacyQuote && !initialSelector) { initialSelector = { type: "TextQuoteSelector", exact: legacyQuote, }; } const [url, setUrl] = useState(initialUrl); if (loading) { return (
); } if (!isAuthenticated) { return (

Sign in to create annotations

You need to be logged in with your Bluesky account

Sign in with Bluesky
); } const handleSuccess = () => { navigate("/home"); }; return (

New Annotation

Write in the margins of the web

{!initialUrl && (
setUrl(e.target.value)} placeholder="https://example.com/article" className="url-input" required />
)}
navigate(-1)} />
); }