feat: OS Share Target for recipe URLs (v0.67.0)

Declares share_target in manifest.ts (action /recipes, GET,
title/text/url params). recipes/page.tsx extracts the shared link --
preferring the url param, falling back to the first http(s) URL
found inside text since senders vary on where they put it -- and
passes it to RecipesHeader as sharedUrl. UrlImportDialog gained
initialUrl/autoImport props so the existing import-from-URL flow
opens pre-filled and fires immediately instead of requiring the user
to paste the link back in.

Chromium/Android only -- Safari has no Share Target API at all,
same restriction already documented for the install-prompt banner.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-21 23:36:53 +02:00
parent 4c3880e07f
commit c8ee743458
9 changed files with 77 additions and 10 deletions
@@ -87,6 +87,7 @@ export function RecipesHeader({
initialTag = "",
initialBatchCook = "",
initialRecipeType = "",
sharedUrl,
}: {
count: number;
initialQuery?: string;
@@ -96,13 +97,19 @@ export function RecipesHeader({
initialTag?: string;
initialBatchCook?: string;
initialRecipeType?: string;
/** A link shared into the installed PWA via the OS share sheet (Web Share
* Target, Chromium/Android only) — see manifest.ts's share_target and
* page.tsx's read of the `url`/`text` params it's redirected here with.
* Auto-opens the import dialog pre-filled instead of requiring the user
* to paste the link again. */
sharedUrl?: string;
}) {
const router = useRouter();
const pathname = usePathname();
const t = useTranslations("recipes");
const tRecipe = useTranslations("recipe");
const [aiOpen, setAiOpen] = useState(false);
const [urlOpen, setUrlOpen] = useState(false);
const [urlOpen, setUrlOpen] = useState(!!sharedUrl);
const [query, setQuery] = useState(initialQuery);
const [, startTransition] = useTransition();
@@ -314,7 +321,7 @@ export function RecipesHeader({
</div>
<AiGenerateDialog open={aiOpen} onOpenChange={setAiOpen} />
<UrlImportDialog open={urlOpen} onOpenChange={setUrlOpen} />
<UrlImportDialog open={urlOpen} onOpenChange={setUrlOpen} initialUrl={sharedUrl} autoImport={!!sharedUrl} />
</>
);
}