diff --git a/app/(app)/lish/[did]/[publication]/edit/[[...route]]/PublicationPagesEditNav.tsx b/app/(app)/lish/[did]/[publication]/edit/[[...route]]/PublicationPagesEditNav.tsx index 666526a2..1b4981f3 100644 --- a/app/(app)/lish/[did]/[publication]/edit/[[...route]]/PublicationPagesEditNav.tsx +++ b/app/(app)/lish/[did]/[publication]/edit/[[...route]]/PublicationPagesEditNav.tsx @@ -48,6 +48,7 @@ import { PublicationNavSubscribe } from "../../PublicationNavSubscribe"; import { useNavBackgroundFade } from "../../useNavBackgroundFade"; import { DotLoader } from "components/utils/DotLoader"; import { useToaster } from "components/Toast"; +import { Checkbox } from "components/Checkbox"; // Turn arbitrary user input into a slug that is safe to use as the path // segment of a URL: lowercase, ascii letters/numbers/dashes only, no spaces @@ -268,6 +269,10 @@ function AddPageButton(props: { // While the path is "linked" it tracks cleanPath(name); editing the path // field directly breaks the link so it stays whatever the user typed. let [pathLinked, setPathLinked] = useState(true); + // When set, this page is an external link rather than a hosted page; the + // path input is disabled and we collect a URL instead. + let [isExternal, setIsExternal] = useState(false); + let [externalLink, setExternalLink] = useState(""); function handleNameChange(newName: string) { setName(newName); @@ -285,6 +290,8 @@ function AddPageButton(props: { setName(""); setPath(""); setPathLinked(true); + setIsExternal(false); + setExternalLink(""); } } @@ -343,19 +350,47 @@ function AddPageButton(props: { onChange={(e) => handleNameChange(e.currentTarget.value)} autoFocus /> - handlePathChange(e.currentTarget.value)} - /> -
- {props.publicationUrl?.replace(/^https?:\/\//, "")} - {cleanPath(path)} -
+ {isExternal ? ( + <> + setExternalLink(e.currentTarget.value)} + />{" "} +
+ + ) : ( + <> + handlePathChange(e.currentTarget.value)} + /> +
+ {props.publicationUrl?.replace(/^https?:\/\//, "")} + {cleanPath(path)} +
+ + )} +
+ setIsExternal(e.currentTarget.checked)} + small + > + Make this tab a link + + +
setPath(e.currentTarget.value)} placeholder="/about" - />{" "} + />
Full page link
{props.publicationUrl?.replace(/^https?:\/\//, "")} {cleanPath(path)}
+ {saving ? "Saving..." : "Save"} diff --git a/components/Input.tsx b/components/Input.tsx index 796dd7b9..a6bc5b97 100644 --- a/components/Input.tsx +++ b/components/Input.tsx @@ -76,7 +76,7 @@ export const InputWithLabel = ( ${props.className}`; return (