✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Generating working links to custom document views in Sanity Studio v2

12 replies
Last updated: Aug 27, 2022
If I have a custom document view in my desk structure, what's the best way to generate a working link from the depicted markup to the actual in-Studio edit screen in v2?
I have the ID and just leave it a relative address, and it looks
just like the real address if I were to get there by browsing panes. But if I click it, it either gets there after a huge refresh of the whole Studio page's tab, or it becomes unresponsive.
I did search and read through things first before asking but perhaps I've overlooked something. I saw
user H
do something like that in his pretend cake shop at the conference but I'm not sure how that works.

Note: EDITED because I accidentally called it JSON view because the documentation example was saturated into my brain
Aug 26, 2022, 10:07 PM
By JSON view, do you mean Inspect?
Aug 26, 2022, 10:09 PM
Or do you mean in t custom document view?
Aug 26, 2022, 10:09 PM
to your URL will show the Inspect view.
Aug 26, 2022, 10:11 PM
Oh sorry, I can show you, just a sec
Aug 26, 2022, 10:13 PM
I believe I mean just document view
Aug 26, 2022, 10:14 PM
I am trying to make these color swatches clickable to their respective edit screens
Aug 26, 2022, 10:14 PM
The href winds up being something like

Which is identical to going there the natural way, but the effect is way different.
Aug 26, 2022, 10:16 PM
Got it. I think you want to use either an Intent Link or the router . I can't find the intent link docs though...
Aug 26, 2022, 10:18 PM
Oooh, schmancy. I saw something called usePaneRouter too. I'll take a look at your thing and report back. Thanks for the quick response!
Aug 26, 2022, 10:20 PM
user M
I crashed and burned trying the ways over at the NPM link, but it turns out that today you were a double-savior because Past You came in for the alley-oop assist: https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1659975590648499?thread_ts=1659949651.348759&cid=C9Z7RC3V1
It works
perfectly and so smoothly. I wasn't really thinking that it probably can't just be a straight link because of all the state being tracked, but if anyone else is curious the format that the component arrives at looks more like this:

Aug 27, 2022, 12:23 AM
Yay! Sorry I initially lead you astray with the router 😅
Aug 27, 2022, 12:47 AM
That just made it more dramatically compelling when you eventually saved me! Makes for a better story 😃
It's amazing to me that I've been around for over half a year and I keep finding new stuff in Sanity. I realize you all have been around for years, but you look at the Studio and it's practically a blank screen, yet
goodness there's so much possibility, so much that it rises to meet when you come up with a challenge for it.
In other platforms you're stuck wondering "How could I possibly make this work?
Can I make this work?" But with Sanity it's more like "99% sure this is a covered base, I just gotta see what the specific way is."
It really elevates one's confidence that the work can be only about the work, and that you can just burn through all the concepts in your brain to make cool things.

It's the near-absence of bottlenecks. It's just a weird, rounded glass cylinder bottle. I guess maybe it's a magic straw, or there's a small circular hole cut in the top that doesn't count as a neck because it's just an opening...
Aug 27, 2022, 12:53 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?