How to change the title of a document in Sanity's structure builder and how to make a schema type a singleton.
import S from "@sanity/desk-tool/structure-builder";
export default () =>
// Make a new list item
S.list()
.title("Content")
.items([
S.listItem()
.title("KM Posts")
// This automatically gives it properties from the project type
.schemaType("twentyTwentyKmPost")
// When you open this list item, list out the documents
// of the type "project"
.child(S.documentTypeList("twentyTwentyKmPost").title("2020-2021")),
S.listItem()
.title("KT Posts")
// This automatically gives it properties from the project type
.schemaType("twentyTwentyKtPost")
// When you open this list item, list out the documents
// of the type "project"
.child(S.documentTypeList("twentyTwentyKtPost").title("2020-2021")),
S.listItem()
.title("Slide Deck")
// This automatically gives it properties from the project type
.schemaType("slideDeck")
// When you open this list item, list out the documents
// of the type "project"
.child(S.documentTypeList("slideDeck").title("Cards")),
S.listItem()
.title("Curriculum")
// This automatically gives it properties from the project type
.schemaType("curriculumPost")
// When you open this list item, list out the documents
// of the type "project"
.child(S.documentTypeList("curriculumPost").title("Content")),
S.listItem()
// Give it a title
.title("Archives")
.child(
// Make a list in the second pane called Portfolio
S.list()
.title("2010-2017")
.items([
// Add the first list item
S.listItem()
.title("2010 - 2011")
// This automatically gives it properties from the project type
.schemaType("twentyTenPost")
// When you open this list item, list out the documents
// of the type "project"
.child(S.documentTypeList("twentyTenPost").title("Posts")),
// Add a second list item
S.listItem()
.title("2011 - 2012")
.schemaType("twentyElevenPost")
// When you open this list item, list out the documents
// of the type category"
.child(S.documentTypeList("twentyElevenPost").title("Posts")),
S.listItem()
.title("2012 - 2013")
.schemaType("twentyThirteenPost")
// When you open this list item, list out the documents
// of the type category"
.child(S.documentTypeList("twentyThirteenPost").title("Posts")),
S.listItem()
.title("2014 - 2015")
.schemaType("twentyFourteenPost")
// When you open this list item, list out the documents
// of the type category"
.child(S.documentTypeList("twentyFourteenPost").title("Posts")),
S.listItem()
.title("2015 - 2016")
.schemaType("twentyFifteenPost")
// When you open this list item, list out the documents
// of the type category"
.child(S.documentTypeList("twentyFifteenPost").title("Posts")),
S.listItem()
.title("2016 - 2017")
.schemaType("twentySixteenPost")
// When you open this list item, list out the documents
// of the type category"
.child(S.documentTypeList("twentySixteenPost").title("Posts")),
S.listItem()
.title("2018 - 2019 KT")
.schemaType("twentyEighteenKtPost")
// When you open this list item, list out the documents
// of the type category"
.child(
S.documentTypeList("twentyEighteenKtPost").title("Posts")
),
S.listItem()
.title("2018 - 2019 KM")
.schemaType("twentyEighteenKmPost")
// When you open this list item, list out the documents
// of the type category"
.child(
S.documentTypeList("twentyEighteenKmPost").title("Posts")
),
S.listItem()
.title("2019 - 2020 KT")
.schemaType("twentyNineteenKtPost")
// When you open this list item, list out the documents
// of the type category"
.child(
S.documentTypeList("twentyNineteenKtPost").title("Posts")
),
S.listItem()
.title("2019 - 2020 KM")
.schemaType("twentyNineteenKmPost")
// When you open this list item, list out the documents
// of the type category"
.child(
S.documentTypeList("twentyNineteenKmPost").title("Posts")
),
])
),
]); S.listItem()
.title("Curriculum Content")
.child(
S.document().schemaType("curriculumPost").documentId("curriculumPost")
),...S.documentTypeListItems().filter(
(listItem) =>
![
"curriculumPost",
"slideDeck",
"twentyEighteenKtPost",
"twentyEighteenKmPost",
"twentyTenPost",
"twentyElevenPost",
"twentyTwelvePost",
"twentyThirteenPost",
"twentyFourteenPost",
"twentyFifteenPost",
"twentySixteenPost",
"twentySeventeenKtPost",
"twentySeventeenKmPost",
"twentyNineteenKmPost",
"twentyNineteenKtPost",
"twentyTwentyKmPost",
"twentyTwentyKtPost",
].includes(listItem.getId())
), S.listItem()
.title("Curriculum Content")
.child(
S.document().schemaType("curriculumPost").documentId("curriculumPost")
),...S.documentTypeListItems().filter(
(listItem) =>
![
"curriculumPost",
"slideDeck",
"twentyEighteenKtPost",
"twentyEighteenKmPost",
"twentyTenPost",
"twentyElevenPost",
"twentyTwelvePost",
"twentyThirteenPost",
"twentyFourteenPost",
"twentyFifteenPost",
"twentySixteenPost",
"twentySeventeenKtPost",
"twentySeventeenKmPost",
"twentyNineteenKmPost",
"twentyNineteenKtPost",
"twentyTwentyKmPost",
"twentyTwentyKtPost",
].includes(listItem.getId())
),S.listItem()
.title('Curriculum Content')
.child(
S.editor()
.title('Curriculum Content')
.schemaType('curriculumPost')
.documentId('curriculumPost')
),_idof
curriculumPost? And not some random string?
Was this answer helpful?
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.