Adding the dashboard tool to a Sanity configuration in version 3.
10 replies
Last updated: Dec 13, 2022
A
Hello! I just migrated my personal website that i did with the sanity + gatsby starter, from version 2 to version 3 of sanity. All seems to be working fine, but not sure how should i add the dashboard tool to my config. Any thoughts? Thank you!
Dec 13, 2022, 5:53 PM
H
Can you send your config?
Dec 13, 2022, 6:40 PM
A
Yes:
},
schema: {
types: schemas,
},
document: {
newDocumentOptions: (prev, { creationContext })
return prev.filter((templateItem)
}
return prev
},
actions: (prev, { schemaType })
return prev.filter(({ action })
}
return prev
},
},
});
// sanity.config.js
import { defineConfig } from "sanity";
import { deskTool } from 'sanity/desk'
import schemas from './schemas/schema'
import { visionTool } from '@sanity/vision'
import deskStructure from './src/structure/deskStructure'
import dashboard from './src/dashboardConfig'
export default defineConfig({
title: "Testing Sanity v3",
projectId: "zfgtf7ck",
dataset: "production",
plugins: [
deskTool({
structure: deskStructure
}),
visionTool(),
],
tools: (prev) *=>* {
// 👇 Uses environment variables set by Vite in development mode
if (<http://import.meta.env.DEV|import.meta.env.DEV>) {
return prev
}
return prev.filter((tool) *=>* tool.name !== 'vision')
schema: {
types: schemas,
},
document: {
newDocumentOptions: (prev, { creationContext })
*=>* {if (creationContext.type === 'global') {
return prev.filter((templateItem)
*=>* templateItem.templateId != 'siteSettings')
return prev
},
actions: (prev, { schemaType })
*=>* {if (schemaType === 'siteSettings') {
return prev.filter(({ action })
*=>* !['unpublish', 'delete','duplicate'].includes(action))
return prev
},
},
});
Dec 13, 2022, 6:51 PM
A
sorry, this way its cleaner to read:
Dec 13, 2022, 6:52 PM
H
Shouldnt tools be inside Plugins? Currently in cellphone
Dec 13, 2022, 7:16 PM
A
Very true! , sorry just another question, how should i reference it?Thank you so much!
Dec 13, 2022, 7:22 PM
H
Reference to dashboard?
Dec 13, 2022, 7:23 PM
A
Yes. How should i write it in the code? so sorry im completely black in regards of how to include it.
Dec 13, 2022, 7:31 PM
H
You can read more about it here ! Let me know if you still stuck after reading through here
Dec 13, 2022, 7:35 PM
A
Omg, you legend. Thank you! I was able to solve it!
Dec 13, 2022, 8:42 PM
H
Congrats!
Dec 13, 2022, 8:42 PM
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.