Creating a custom input component to search for documents with the same language as the current workspace.

2 replies
Last updated: Apr 9, 2024
Hi all.
I'm looking to make a custom input component and trying to see if something like this is possible.

On my site, I'm currently using the
document localisation plugin in order to create a "multisite". Aka, one admin dashboard, three websites. The schema and structure is the same throughout all three sites.
What I'm wanting to create is a replica of the reference search component. However, I'd like to be able to only search for documents with the same language as the current workspace (the workspace and the language ID's are the same for each unique site).

It's a bit of a pain trying to link to say, the homepage, but having three distinct homepages popup every time you search.

Is there any way of doing this?
Apr 8, 2024, 7:58 AM
You’ll want to use a dynamic filter on your reference. If you’re using that plugin, you most likely have the
lang
set on the document, which will show up in the context that’s passed into your filter function.
Apr 8, 2024, 4:43 PM
Amazing thank you!!
Apr 9, 2024, 7:05 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?