diff --git a/package-lock.json b/package-lock.json index 4044cef4..db50ac10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4677,6 +4677,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4690,6 +4691,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4703,6 +4705,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4716,6 +4719,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4729,6 +4733,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4742,6 +4747,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4755,6 +4761,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4768,6 +4775,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4781,6 +4789,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4794,6 +4803,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4807,6 +4817,7 @@ "cpu": [ "loong64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4820,6 +4831,7 @@ "cpu": [ "ppc64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4833,6 +4845,7 @@ "cpu": [ "riscv64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4846,6 +4859,7 @@ "cpu": [ "riscv64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4859,6 +4873,7 @@ "cpu": [ "s390x" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4872,6 +4887,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4885,6 +4901,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4898,6 +4915,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4911,6 +4929,7 @@ "cpu": [ "ia32" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4924,6 +4943,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ diff --git a/src/components/AddCustomProviderDialog.tsx b/src/components/AddCustomProviderDialog.tsx index 74982b25..8070e562 100644 --- a/src/components/AddCustomProviderDialog.tsx +++ b/src/components/AddCustomProviderDialog.tsx @@ -1,6 +1,7 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Check } from 'lucide-react'; +import { UrlListEditor } from '@/components/UrlListEditor'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { PasswordInput } from '@/components/ui/password-input'; @@ -63,8 +64,8 @@ export function AddCustomProviderDialog({ const [customHost, setCustomHost] = useState(''); const [customProxy, setCustomProxy] = useState(false); const [customGateway, setCustomGateway] = useState(''); - const [customRelayUrls, setCustomRelayUrls] = useState(''); - const [customBlossomServers, setCustomBlossomServers] = useState(''); + const [customRelayUrls, setCustomRelayUrls] = useState([]); + const [customBlossomServers, setCustomBlossomServers] = useState([]); const handleAdd = () => { if (!customProviderType || !customName.trim()) return; @@ -84,12 +85,8 @@ export function AddCustomProviderDialog({ type: 'nsite', name: customName.trim(), gateway: customGateway.trim() || 'nsite.lol', - relayUrls: customRelayUrls.trim() - ? customRelayUrls.split(',').map(s => s.trim()).filter(Boolean) - : ['wss://relay.ditto.pub'], - blossomServers: customBlossomServers.trim() - ? customBlossomServers.split(',').map(s => s.trim()).filter(Boolean) - : ['https://blossom.primal.net/'], + relayUrls: customRelayUrls.length > 0 ? customRelayUrls : ['wss://relay.ditto.pub'], + blossomServers: customBlossomServers.length > 0 ? customBlossomServers : ['https://blossom.primal.net/'], }; } else if (customProviderType === 'netlify') { if (!customApiKey.trim()) return; @@ -157,8 +154,8 @@ export function AddCustomProviderDialog({ setCustomHost(''); setCustomProxy(false); setCustomGateway(''); - setCustomRelayUrls(''); - setCustomBlossomServers(''); + setCustomRelayUrls([]); + setCustomBlossomServers([]); onOpenChange(false); }; @@ -198,8 +195,8 @@ export function AddCustomProviderDialog({ setCustomHost(''); setCustomProxy(false); setCustomGateway(''); - setCustomRelayUrls(''); - setCustomBlossomServers(''); + setCustomRelayUrls([]); + setCustomBlossomServers([]); }} > @@ -249,7 +246,7 @@ export function AddCustomProviderDialog({ ) : customProviderType === 'nsite' ? ( <>

- Deploy to Nostr as a static website. Uses kind 34128 events and Blossom file storage. + Deploy to Nostr as a static website. Uses a kind 15128 site manifest event and Blossom file storage.

@@ -260,24 +257,20 @@ export function AddCustomProviderDialog({ onChange={(e) => setCustomGateway(e.target.value)} />
-
- - setCustomRelayUrls(e.target.value)} - /> -
-
- - setCustomBlossomServers(e.target.value)} - /> -
+ + ) : ( <> diff --git a/src/components/ProviderConfigDialog.tsx b/src/components/ProviderConfigDialog.tsx index 70501afd..aeb312ec 100644 --- a/src/components/ProviderConfigDialog.tsx +++ b/src/components/ProviderConfigDialog.tsx @@ -17,6 +17,7 @@ import { import type { DeployProvider } from '@/contexts/DeploySettingsContext'; import type { PresetDeployProvider } from '@/lib/deploy/types'; import { ExternalFavicon } from '@/components/ExternalFavicon'; +import { UrlListEditor } from '@/components/UrlListEditor'; interface ProviderConfigDialogProps { open: boolean; @@ -138,34 +139,22 @@ export function ProviderConfigDialog({ onChange={(e) => setLocalProvider({ ...localProvider, gateway: e.target.value })} /> -
- - setLocalProvider({ - ...localProvider, - relayUrls: e.target.value.split(',').map(s => s.trim()).filter(Boolean) - })} - /> -
-
- - setLocalProvider({ - ...localProvider, - blossomServers: e.target.value.split(',').map(s => s.trim()).filter(Boolean) - })} - /> -
+ setLocalProvider({ ...localProvider, relayUrls: urls })} + protocol="wss" + placeholder="relay.ditto.pub" + required + /> + setLocalProvider({ ...localProvider, blossomServers: servers })} + protocol="https" + placeholder="blossom.primal.net" + required + /> ) : ( <> diff --git a/src/components/UrlListEditor.tsx b/src/components/UrlListEditor.tsx new file mode 100644 index 00000000..81fb07b0 --- /dev/null +++ b/src/components/UrlListEditor.tsx @@ -0,0 +1,147 @@ +import { useState, useRef, KeyboardEvent } from 'react'; +import { X, Plus } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { ExternalFavicon } from '@/components/ExternalFavicon'; +import { cn } from '@/lib/utils'; + +interface UrlListEditorProps { + /** Label shown above the list */ + label: string; + /** Current array of full URLs */ + items: string[]; + /** Called when the list changes */ + onChange: (items: string[]) => void; + /** Controls auto-prefix on bare domain entry */ + protocol: 'wss' | 'https'; + /** Placeholder shown in the add input */ + placeholder?: string; + /** Whether to show the required asterisk */ + required?: boolean; + /** Additional CSS classes for the root element */ + className?: string; +} + +/** + * Normalize a bare domain or partial URL to a fully-qualified URL. + * If the value already has any protocol it is returned as-is. + */ +function normalizeEntry(value: string, protocol: 'wss' | 'https'): string { + const trimmed = value.trim(); + if (!trimmed) return ''; + if (/^wss?:\/\//i.test(trimmed) || /^https?:\/\//i.test(trimmed)) return trimmed; + return `${protocol}://${trimmed}`; +} + +/** + * Convert a URL to an https:// form suitable for favicon lookup. + * wss:// → https://, ws:// → http:// + */ +function toHttpsUrl(url: string): string { + return url.replace(/^wss:\/\//i, 'https://').replace(/^ws:\/\//i, 'http://'); +} + +/** Strip the protocol prefix for compact display */ +function displayLabel(url: string): string { + return url.replace(/^wss?:\/\//i, '').replace(/^https?:\/\//i, ''); +} + +export function UrlListEditor({ + label, + items, + onChange, + protocol, + placeholder, + required, + className, +}: UrlListEditorProps) { + const [inputValue, setInputValue] = useState(''); + const inputRef = useRef(null); + + const handleAdd = () => { + const normalized = normalizeEntry(inputValue, protocol); + if (!normalized) return; + // Silently ignore duplicates + if (items.includes(normalized)) { + setInputValue(''); + return; + } + onChange([...items, normalized]); + setInputValue(''); + inputRef.current?.focus(); + }; + + const handleRemove = (index: number) => { + onChange(items.filter((_, i) => i !== index)); + }; + + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Enter') { + e.preventDefault(); + handleAdd(); + } + }; + + return ( +
+ + + {/* Scrollable list of existing items */} + {items.length > 0 && ( +
+ {items.map((item, index) => ( +
+ + + {displayLabel(item)} + + +
+ ))} +
+ )} + + {/* Add input */} +
+ setInputValue(e.target.value)} + onKeyDown={handleKeyDown} + placeholder={placeholder ?? (protocol === 'wss' ? 'relay.example.com' : 'server.example.com')} + className="font-mono text-sm" + /> + +
+
+ ); +} diff --git a/src/components/deploy/DeploySteps.tsx b/src/components/deploy/DeploySteps.tsx index bd5322bd..b1edf6dc 100644 --- a/src/components/deploy/DeploySteps.tsx +++ b/src/components/deploy/DeploySteps.tsx @@ -36,6 +36,9 @@ import { VercelAdapter } from '@/lib/deploy/VercelAdapter'; import { CloudflareAdapter } from '@/lib/deploy/CloudflareAdapter'; import { DenoDeployAdapter } from '@/lib/deploy/DenoDeployAdapter'; import { RailwayAdapter } from '@/lib/deploy/RailwayAdapter'; +import { readNsiteVfsConfig, writeNsiteVfsConfig } from '@/lib/nsiteConfig'; +import type { NsiteVfsConfig } from '@/lib/nsiteConfig'; +import { projectNameToDTag } from '@/lib/utils/nsite'; /** * Normalize a URL string to ensure it has a protocol @@ -85,7 +88,10 @@ interface ShakespeareFormData { } interface NsiteFormData { - nsec: string; + siteTitle: string; + siteDescription: string; + dTag: string; + siteType: 'named' | 'root'; } interface NetlifyFormData { @@ -132,12 +138,49 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp const [error, setError] = useState(null); const [isShakespeareFormValid, setIsShakespeareFormValid] = useState(true); + // .nsite/config.json state — loaded once on mount, used to skip config form on re-deploy + const [nsiteVfsConfig, setNsiteVfsConfig] = useState(null); + const [nsiteVfsConfigLoading, setNsiteVfsConfigLoading] = useState(true); + // When a .nsite/config.json already exists, hide the full form and show a summary instead. + // The user can click "Edit" to expand it. + const [nsiteShowFullForm, setNsiteShowFullForm] = useState(false); + + useEffect(() => { + if (!projectId) { + setNsiteVfsConfigLoading(false); + return; + } + const projectPath = `${projectsPath}/${projectId}`; + readNsiteVfsConfig(fs, projectPath) + .then((cfg) => { + setNsiteVfsConfig(cfg); + // If a config already exists, seed the form from it and stay in summary mode. + // If not, show the full form so the user can configure for the first time. + if (cfg) { + const derivedSiteType = cfg.id === null ? 'root' : 'named'; + setNsiteForm({ + siteTitle: cfg.title ?? '', + siteDescription: cfg.description ?? '', + dTag: (cfg.id != null && cfg.id !== '') ? cfg.id : '', + siteType: derivedSiteType, + }); + setNsiteShowFullForm(false); + } else { + setNsiteShowFullForm(true); + } + }) + .finally(() => setNsiteVfsConfigLoading(false)); + }, [fs, projectsPath, projectId]); + // Provider-specific form data const [shakespeareForm, setShakespeareForm] = useState({ subdomain: projectId, }); const [nsiteForm, setNsiteForm] = useState({ - nsec: '', + siteTitle: '', + siteDescription: '', + dTag: '', + siteType: 'named', }); const [netlifyForm, setNetlifyForm] = useState({ siteId: '', @@ -205,17 +248,22 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp } else if (selectedProvider.type === 'nsite') { const nsiteProvider = selectedProvider; - if (!nsiteForm.nsec) { - throw new Error('Site private key (nsec) is required'); + if (!user) { + throw new Error('You must be logged in to deploy to nsite.'); } adapter = new NsiteAdapter({ fs, nostr, - nsec: nsiteForm.nsec, + signer: user.signer, gateway: nsiteProvider.gateway, relayUrls: nsiteProvider.relayUrls, blossomServers: nsiteProvider.blossomServers, + siteTitle: nsiteForm.siteTitle || undefined, + siteDescription: nsiteForm.siteDescription || undefined, + siteIdentifier: nsiteForm.siteType === 'named' && nsiteForm.dTag + ? nsiteForm.dTag + : undefined, }); } else if (selectedProvider.type === 'netlify') { const netlifyProvider = selectedProvider; @@ -324,9 +372,29 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp type: 'nsite', url: result.url, data: { - nsec: nsiteForm.nsec, + siteTitle: nsiteForm.siteTitle || undefined, + siteDescription: nsiteForm.siteDescription || undefined, + dTag: nsiteForm.dTag || undefined, + siteType: nsiteForm.siteType, }, }); + + // Write .nsite/config.json for nsyte CLI interoperability. + // This file is safe to commit — it never contains the nsec. + const nsiteProvider = selectedProvider; + const newNsiteVfsConfig: NsiteVfsConfig = { + relays: nsiteProvider.relayUrls, + servers: nsiteProvider.blossomServers, + id: nsiteForm.siteType === 'root' ? null : (nsiteForm.dTag || undefined), + title: nsiteForm.siteTitle || undefined, + description: nsiteForm.siteDescription || undefined, + fallback: '/index.html', + gatewayHostnames: [nsiteProvider.gateway], + }; + await writeNsiteVfsConfig(fs, projectPath, newNsiteVfsConfig); + // Update in-memory state so summary view reflects new values immediately + setNsiteVfsConfig(newNsiteVfsConfig); + setNsiteShowFullForm(false); } else if (selectedProvider.type === 'netlify') { await updateProjectSettings(selectedProviderId, { type: 'netlify', @@ -434,12 +502,14 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp setError(null); // Reset forms setShakespeareForm({ subdomain: projectId }); - setNsiteForm({ nsec: '' }); + setNsiteForm({ siteTitle: '', siteDescription: '', dTag: '', siteType: 'named' }); setNetlifyForm({ siteId: '', siteName: '' }); setVercelForm({ projectName: projectName || projectId, teamId: '' }); setCloudflareForm({ projectName: projectName || projectId }); setDenoDeployForm({ projectName: projectName || projectId }); setRailwayForm({ workspaceId: '', projectId: '', environmentId: '', serviceId: '', projectName: projectName || projectId }); + // Return to summary mode so next open shows the compact view (if config exists) + setNsiteShowFullForm(false); onClose(); }; @@ -451,8 +521,21 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp setIsShakespeareFormValid(isValid); }, []); - const handleNsiteNsecChange = useCallback((nsec: string) => { - setNsiteForm({ nsec }); + const handleNsiteSiteTitleChange = useCallback((siteTitle: string) => { + setNsiteForm(prev => ({ ...prev, siteTitle })); + // Derive the dTag from the title so the user never has to think about it. + // Falls back to projectName when the title is blank. + projectNameToDTag(siteTitle || projectName).then(dTag => { + setNsiteForm(prev => ({ ...prev, dTag })); + }); + }, [projectName]); + + const handleNsiteSiteDescriptionChange = useCallback((siteDescription: string) => { + setNsiteForm(prev => ({ ...prev, siteDescription })); + }, []); + + const handleNsiteSiteTypeChange = useCallback((siteType: 'named' | 'root') => { + setNsiteForm(prev => ({ ...prev, siteType })); }, []); const handleNetlifySiteChange = useCallback((siteId: string, siteName: string) => { @@ -501,15 +584,87 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp } if (selectedProvider.type === 'nsite') { + // While the .nsite/config.json load is still in flight, render nothing to avoid flicker + if (nsiteVfsConfigLoading) return null; + + // Summary view: shown when .nsite/config.json already exists and user hasn't clicked Edit + if (nsiteVfsConfig && !nsiteShowFullForm) { + const isRoot = nsiteVfsConfig.id === null; + const siteLabel = isRoot + ? 'Root site' + : nsiteVfsConfig.id + ? `Named site: ${nsiteVfsConfig.id}` + : 'Named site'; + const relayCount = nsiteVfsConfig.relays?.length ?? 0; + const serverCount = nsiteVfsConfig.servers?.length ?? 0; + + return ( +
+
+ {nsiteVfsConfig.title && ( +
+ Title + {nsiteVfsConfig.title} +
+ )} +
+ Type + {siteLabel} +
+
+ Relays + {relayCount} configured +
+
+ Blossom servers + {serverCount} configured +
+
+ +
+ ); + } + + // Full config form: shown on first deploy or when user clicks "Edit site settings" const savedConfig = projectSettings.providers[selectedProviderId]; - const savedNsec = savedConfig?.type === 'nsite' ? savedConfig.data.nsec : undefined; + const legacy = savedConfig?.type === 'nsite' ? savedConfig.data : undefined; + + // .nsite/config.json wins; .git/shakespeare/deploy.json is the legacy fallback + const savedSiteTitle = nsiteVfsConfig?.title ?? legacy?.siteTitle; + const savedSiteDescription = nsiteVfsConfig?.description ?? legacy?.siteDescription; + const savedSiteType = nsiteVfsConfig + ? (nsiteVfsConfig.id === null ? 'root' : 'named') + : legacy?.siteType; return ( - +
+ + {nsiteVfsConfig && ( + + )} +
); } @@ -769,6 +924,22 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp )} + {selectedProvider?.type === 'nsite' && !user && ( + + + + You must be logged in with Nostr to deploy to nsite.{' '} + + Go to Nostr Settings + + + + )} + {error && ( @@ -783,7 +954,8 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp isDeploying || (selectedProvider.type === 'shakespeare' && !user) || (selectedProvider.type === 'shakespeare' && !isShakespeareFormValid) || - (selectedProvider.type === 'nsite' && !nsiteForm.nsec) || + (selectedProvider.type === 'nsite' && !user) || + (selectedProvider.type === 'nsite' && nsiteForm.siteType === 'named' && !nsiteForm.dTag) || (selectedProvider.type === 'netlify' && !netlifyForm.siteId && !netlifyForm.siteName) || (selectedProvider.type === 'cloudflare' && !cloudflareForm.projectName) || (selectedProvider.type === 'deno' && !denoDeployForm.projectName) || diff --git a/src/components/deploy/NsiteDeployForm.tsx b/src/components/deploy/NsiteDeployForm.tsx index ecdbb1a8..ab7e79d2 100644 --- a/src/components/deploy/NsiteDeployForm.tsx +++ b/src/components/deploy/NsiteDeployForm.tsx @@ -1,107 +1,173 @@ import { useState, useEffect, useRef } from 'react'; -import { generateSecretKey, getPublicKey } from 'nostr-tools/pure'; -import { nip19 } from 'nostr-tools'; +import { AlertCircle, Globe, Tag } from 'lucide-react'; import { Label } from '@/components/ui/label'; -import { Button } from '@/components/ui/button'; -import { PasswordInput } from '@/components/ui/password-input'; -import { RefreshCw } from 'lucide-react'; +import { Input } from '@/components/ui/input'; +import { Textarea } from '@/components/ui/textarea'; +import { Alert, AlertDescription } from '@/components/ui/alert'; +import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; interface NsiteDeployFormProps { - gateway: string; + /** Human-readable project name — used to default the title for named sites */ + projectName: string; + /** Persisted values from a previous deployment */ + savedSiteTitle?: string; + savedSiteDescription?: string; + savedSiteType?: 'named' | 'root'; + /** Present only when the project was previously deployed with a dedicated keypair (v1) */ savedNsec?: string; - onNsecChange: (nsec: string) => void; + onSiteTitleChange: (title: string) => void; + onSiteDescriptionChange: (description: string) => void; + onSiteTypeChange: (type: 'named' | 'root') => void; } export function NsiteDeployForm({ - gateway, + projectName, + savedSiteTitle, + savedSiteDescription, + savedSiteType, savedNsec, - onNsecChange, + onSiteTitleChange, + onSiteDescriptionChange, + onSiteTypeChange, }: NsiteDeployFormProps) { - const [nsec, setNsec] = useState(savedNsec || ''); - const [npub, setNpub] = useState(''); - const initialized = useRef(false); + const [siteType, setSiteType] = useState<'named' | 'root'>(savedSiteType ?? 'named'); + const [siteTitle, setSiteTitle] = useState( + savedSiteTitle ?? (savedSiteType === 'root' ? '' : projectName), + ); + const [siteDescription, setSiteDescription] = useState(savedSiteDescription ?? ''); - // Initialize nsec on mount + // On mount: sync all saved values to parent and set defaults. + // The component is keyed by selectedProviderId in DeploySteps, so this always + // runs with fresh props — no initialized guard needed. useEffect(() => { - if (!initialized.current) { - initialized.current = true; - if (savedNsec) { - // If we have a saved nsec, notify parent immediately - onNsecChange(savedNsec); - } else if (!nsec) { - // Generate a new nsec if none exists - const sk = generateSecretKey(); - const newNsec = nip19.nsecEncode(sk); - setNsec(newNsec); - onNsecChange(newNsec); - } - } - }, [savedNsec, nsec, onNsecChange]); + if (savedSiteType) onSiteTypeChange(savedSiteType); + if (savedSiteDescription) onSiteDescriptionChange(savedSiteDescription); - // Update npub when nsec changes + const initialTitle = savedSiteTitle ?? (siteType === 'named' ? projectName : ''); + if (initialTitle !== siteTitle) setSiteTitle(initialTitle); + onSiteTitleChange(initialTitle); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + // When the user switches site type, update the title default only if + // the current title still matches the previous type's auto-fill value. + const prevSiteTypeRef = useRef(siteType); useEffect(() => { - if (nsec) { - try { - const decoded = nip19.decode(nsec); - if (decoded.type === 'nsec') { - const pk = getPublicKey(decoded.data); - const npubEncoded = nip19.npubEncode(pk); - setNpub(npubEncoded); - } - } catch { - setNpub(''); - } - } - }, [nsec]); + const prev = prevSiteTypeRef.current; + prevSiteTypeRef.current = siteType; + if (prev === siteType) return; - const handleNsecChange = (value: string) => { - setNsec(value); - onNsecChange(value); + if (siteType === 'named' && siteTitle === '') { + setSiteTitle(projectName); + onSiteTitleChange(projectName); + } else if (siteType === 'root' && siteTitle === projectName) { + setSiteTitle(''); + onSiteTitleChange(''); + } + }, [siteType, siteTitle, projectName, onSiteTitleChange]); + + const handleSiteTypeChange = (value: 'named' | 'root') => { + setSiteType(value); + onSiteTypeChange(value); }; - const handleGenerateNew = () => { - const sk = generateSecretKey(); - const newNsec = nip19.nsecEncode(sk); - setNsec(newNsec); - onNsecChange(newNsec); + const handleSiteTitleChange = (value: string) => { + setSiteTitle(value); + onSiteTitleChange(value); }; - const fullDomain = npub ? `${npub}.${gateway}` : `npub1...${gateway}`; + const handleSiteDescriptionChange = (value: string) => { + setSiteDescription(value); + onSiteDescriptionChange(value); + }; return (
+ + {/* Migration notice */} + {savedNsec && ( + + + + Site identity is changing. This project was previously deployed with a + dedicated private key. Going forward, it will deploy under your Nostr identity. The old + site will remain at its original address until overwritten. + + + )} + + {/* Site type */}
- -

- {fullDomain} -

+ + +
+ + +
+
+ + +
+
+
+ + {/* Root site warning */} + {siteType === 'root' && ( + + + + You only have one root site per Nostr identity. Deploying here will replace any + existing root site published under your key. + + + )} + + {/* Site title */} +
+ + handleSiteTitleChange(e.target.value)} + placeholder="My Nostr Site" + />

- Each site has a unique Nostr keypair + Shown by nsite gateways and directories. Included as a title tag in the manifest.

+ {/* Site description */}
- -
- handleNsecChange(e.target.value)} - placeholder="nsec1..." - className="flex-1" - /> - -
+ +