Unlock seamless workflows and faster delivery with our latest releases – get the details

Creating Gatsby Pages from a Table of Contents (ToC)

9 replies
Last updated: Aug 7, 2020
I've made a ToC similar to https://www.knutmelvaer.no/blog/2020/04/a-practical-application-of-the-web-project-book/#5792a4ffe753 . But I've also added slug field to the children, so I can build Gatsby pages from the ToC instead of from other documents. But I want to be able to reference these in other objects (
toc.link
in
user Y
's example) so I can link to it, but they are objects and not documents. If I change the type of
toc.link
to
document
they still can't be found in a reference. Any ideas?
Aug 6, 2020, 1:28 PM
If I change them to a
document
and create one from the main folder in the studio it works, but if I create one as a child of
toc.section
it doesn't show up in the reference list
Aug 6, 2020, 1:33 PM
Creating documents inside other documents (e.g. adding references in place) is not possible yet, unfortunately. It’s a popular feature request and definitely something we want to add support for, but it’s not quite there yet.
At the moment, creating these from the main folder in a different browser tab might be the easiest option, unless you’re willing to venture into unknown territory and try to get this to work in a custom input component
🙂
Aug 6, 2020, 2:02 PM
custom input component it is then, gonna look into that 🙂
Aug 7, 2020, 6:25 AM
Or is there any way I could help build this for you?
Aug 7, 2020, 7:08 AM
Appreciate this! The reason we haven't done this yet, is because of the way we do drafts at the moment, which complicates things. We want to fix that first. It’s high on our list, because obviously, being able to create and edit references in place makes total sense.
Here’s part of the discovery:
https://github.com/sanity-io/sanity/pull/1420
Aug 7, 2020, 7:40 AM
Yeah, that looks like a logical first step 🙂
Aug 7, 2020, 7:42 AM
But yeah, I'm a bit hesitant to set you out on this course, because it might be a potential rabbit hole, and then suddenly we solved it anyways
Aug 7, 2020, 7:43 AM
yeah, I'll do a temporary solution for now and change it when you solved it
Aug 7, 2020, 7:44 AM
that's totally fine
Aug 7, 2020, 7:44 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?