Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(web): correct share URLs and input sizing

Amruth Pillai70c231edf294
diff --git a/apps/web/src/features/homepage/share.test.tsx b/apps/web/src/features/homepage/share.test.tsx
new file mode 100644
index 000000000..b3d38f8c3
--- /dev/null
+++ b/apps/web/src/features/homepage/share.test.tsx
@@ -0,0 +1,52 @@
+import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+import { i18n } from "@lingui/core";
+import { I18nProvider } from "@lingui/react";
+import { createMemoryHistory, createRootRoute, createRouter, RouterContextProvider } from "@tanstack/react-router";
+import { renderToStaticMarkup } from "react-dom/server";
+import { Share } from "./share";
+
+afterEach(() => vi.unstubAllGlobals());
+
+describe("landing share address", () => {
+ it.each([
+ { origin: "https://rxresu.me", aliasUrl: "https://rx.cv", address: "rx.cv/alex-morgan" },
+ { origin: "https://resume.example.com", aliasUrl: undefined, address: "resume.example.com/alex-morgan" },
+ { origin: "http://localhost:3000", aliasUrl: undefined, address: "localhost:3000/alex-morgan" },
+ ])("shows $address", async ({ origin, aliasUrl, address }) => {
+ vi.stubGlobal("window", { location: { origin } });
+ const router = createRouter({
+ routeTree: createRootRoute({ beforeLoad: () => ({ flags: { aliasUrl } }) }),
+ history: createMemoryHistory({ initialEntries: ["/"] }),
+ });
+ await router.load();
+ i18n.loadAndActivate({ locale: "en-US", messages: {} });
+
+ const html = renderToStaticMarkup(
+ <RouterContextProvider router={router}>
+ <I18nProvider i18n={i18n}>
+ <Share />
+ </I18nProvider>
+ </RouterContextProvider>,
+ );
+
+ expect(html).toContain(`<span class="sr-only">${address}</span>`);
+ });
+
+ it("falls back to rxresu.me when prerendering without deployment configuration", () => {
+ const router = createRouter({
+ routeTree: createRootRoute(),
+ history: createMemoryHistory({ initialEntries: ["/"] }),
+ });
+ i18n.loadAndActivate({ locale: "en-US", messages: {} });
+
+ const html = renderToStaticMarkup(
+ <RouterContextProvider router={router}>
+ <I18nProvider i18n={i18n}>
+ <Share />
+ </I18nProvider>
+ </RouterContextProvider>,
+ );
+
+ expect(html).toContain('<span class="sr-only">rxresu.me/alex-morgan</span>');
+ });
+});
diff --git a/apps/web/src/features/homepage/share.tsx b/apps/web/src/features/homepage/share.tsx
index 2d53d5db4..5f23c000e 100644
--- a/apps/web/src/features/homepage/share.tsx
+++ b/apps/web/src/features/homepage/share.tsx
@@ -8,9 +8,7 @@ import { cn } from "@reactive-resume/utils/style";
import { SCENE, useLanding } from "./scroll";
import { Sheet } from "./sheet";
import { Doodle, labelClass, TypedText } from "./ui";
-
-const ADDRESS = "rxresu.me/alex-morgan";
-const SLUG_START = ADDRESS.indexOf("/") + 1;
+import { useShareOrigin } from "@/features/resume/share/use-share-origin";
/**
* Colours that switch from the day palette to the night sky's once the sky is half dark (--nts), rather than passing
@@ -51,6 +49,9 @@ const visibilityIcons: IconName[] = ["globe-hemisphere-west", "lock", "eye-slash
* and the visibility and copy controls and the export formats appear.
*/
export function Share() {
+ const origin = useShareOrigin();
+ const host = origin ? new URL(origin).host : "rxresu.me";
+ const address = `${host}/alex-morgan`;
const active = useLanding((state) => state.activeScene === SCENE.share);
const ready = useLanding((state) => state.shareReady);
const [visibility, setVisibility] = useState(0);
@@ -135,7 +136,7 @@ export function Share() {
</div>
<div className="absolute inset-x-(--gutter) top-1/2 flex -translate-y-1/2 flex-col items-center gap-[26px] text-center">
- {/* The heading reads "Your resume, live at rxresu.me/…"; this label is its visible first half. */}
+ {/* This label is the visible first half of the heading. */}
<span
aria-hidden="true"
className={cn(labelClass, "tracking-[.1em] text-(--night-label) opacity-[clamp(0,var(--tu)*20,1)]")}
@@ -158,12 +159,12 @@ export function Share() {
/>
{/* The caret rides on the last character typed. */}
<TypedText
- text={ADDRESS}
+ text={address}
progress="--tu"
rate={60}
className={cn("[overflow-wrap:anywhere] [--caret:var(--night-accent)]", isPrivate && "line-through")}
charClassName="typed-caret"
- charStyle={(index) => (index >= SLUG_START ? { color: "var(--night-accent)" } : undefined)}
+ charStyle={(index) => (index > host.length ? { color: "var(--night-accent)" } : undefined)}
/>
</h2>
diff --git a/apps/web/src/features/resume/share/custom-domain-field.tsx b/apps/web/src/features/resume/share/custom-domain-field.tsx
index a51f76140..c21ffed00 100644
--- a/apps/web/src/features/resume/share/custom-domain-field.tsx
+++ b/apps/web/src/features/resume/share/custom-domain-field.tsx
@@ -79,7 +79,7 @@ export function CustomDomainField({ suggest }: CustomDomainFieldProps) {
spellCheck={false}
autoCapitalize="none"
onChange={(event) => setHostname(event.target.value)}
- className="h-[38px] font-mono text-[13px]"
+ className="h-[38px] font-mono text-[13px] pointer-coarse:h-[38px]"
/>
<Button
type="submit"
diff --git a/apps/web/src/features/resume/share/use-share-origin.ts b/apps/web/src/features/resume/share/use-share-origin.ts
index 285982ca3..45fcddcae 100644
--- a/apps/web/src/features/resume/share/use-share-origin.ts
+++ b/apps/web/src/features/resume/share/use-share-origin.ts
@@ -1,7 +1,10 @@
-import { useRouteContext } from "@tanstack/react-router";
+import { useRouterState } from "@tanstack/react-router";
/** Where shared links point: the app's alias (`APP_ALIAS_URL`) when set, since every public page works there too. */
export function useShareOrigin() {
- const { flags } = useRouteContext({ strict: false });
- return flags?.aliasUrl ?? window.location.origin;
+ const aliasUrl = useRouterState({
+ select: (state): string | undefined => state.matches.at(-1)?.context.flags?.aliasUrl,
+ });
+ // Build-time marketing renders have neither route matches nor a deployment origin.
+ return aliasUrl ?? (typeof window === "undefined" ? "" : window.location.origin);
}