Per-Kristian Nordnes
Fullstack developer at Sanity.io
Display a list of documents in your dashboard
Dashboard widget for the Sanity Content Studio which displays a list of documents
Assuming you already have a functional Dashboard in your Sanity Content Studio.
sanity install dashboard-widget-document-list
src/dashboardConfig.js
file by adding {name: 'document-list'}
to the widgets
arrayNote: If a document in the result (as returned by the backend) has a draft, that draft is rendered instead of the published document.
There are some options available:
title
(string)Widget title
{
name: 'document-list',
options: {
title: 'Some documents'
}
}
order
(string)Field and direction to order by when docs are rendered
{
name: 'document-list',
options: {
title: 'Last edited',
order: '_updatedAt desc'
}
}
limit
(number)Number of docs rendered
{
name: 'document-list',
options: {
title: 'Last edited',
order: '_updatedAt desc',
limit: 3
}
}
types
(array)Array of strings signifying which document (schema) types are fetched
{
name: 'document-list',
options: {
title: 'Last edited',
order: '_updatedAt desc',
types: ['book', 'author']
}
}
query
(string) and params
(object)Customized GROQ query with params for maximum control. If you use the query option, the types
, order
, and limit
options will cease to function. You're on your own.
{
name: 'document-list',
options: {
title: 'Published books by title',
query: '*[_type == "book" && published == true] | order(title asc) [0...10]'
}
}
{
name: 'document-list',
options: {
title: 'My favorite documents',
query: '*[_id in $ids]',
params: {
ids: ['ab2', 'c5z', '654']
}
}
}
createButtonText
(string)You can override the button default button text (Create new ${types[0]}
) by setting createButtonText
to a string of your choice. This doesn't support dynamic variables.
{
name: 'document-list',
options: {
title: 'Blog posts',
query: '*[_type == "post"]',
createButtonText: 'Create new blog post'
}
}
showCreateButton
(boolean)You can disable the create button altogether by passing a showCreateButton
boolean:
{
name: 'document-list',
options: {
showCreateButton: false
}
}
This plugin is available for Studio v3 and Studio v2.What are studio versions and which do I choose?
sanity install dashboard-widget-document-list
Fullstack developer at Sanity.io
Senior Engineer @ Sanity.io
Knut runs developer relations at Sanity.io
Designing with code
Open-sourceror @ Sanity.io
A tool for Sanity Studio to graph your content and see changes in real-time.
Go to Content Graph ViewBrowse and import images from your Cloudinary account to your Sanity Studio
Go to Asset source for CloudinarySearch photos on Unsplash and insert them directly inside of your Sanity Studio.
Go to Asset source for UnsplashUpload videos to Mux directly from the studio.
Go to Mux input