Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Document list widget

Official(made by Sanity team)
v3 Ready

By Per-Kristian Nordnes & Bjørge Næss

Display a list of documents in your dashboard

dashboard-widget-document-list

This is a Sanity Studio v2 plugin. For the v3 version, please refer to the v3-branch.

Dashboard widget for the Sanity Content Studio which displays a list of documents

Usage

Assuming you already have a functional Dashboard in your Sanity Content Studio.

  1. Install this widget in your Studio folder like so:
yarn add sanity-plugin-dashboard-widget-document-list@studio-v2

Next, add "dashboard-widget-document-list" to sanity.json plugins array:

"plugins": [
  "dashboard-widget-document-list"
]
  1. Update your src/dashboardConfig.js file by adding {name: 'document-list'} to the widgets array
  2. Restart your Studio

Note: 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
  }
}

Studio Version

This plugin is available for Studio v3 and Studio v2.What are studio versions and which do I choose?

Contributors

Other plugins by authors

Content Graph View
- has 11 likes

Official(made by Sanity team)
v3 Ready

A tool for Sanity Studio to graph your content and see changes in real-time.

Go to Content Graph View

Asset source for Unsplash
- has 16 likes

Official(made by Sanity team)
v3 Ready

Search photos on Unsplash and insert them directly inside of your Sanity Studio.

Go to Asset source for Unsplash

Mux input
- has 7 likes

v3 Ready

Upload videos to Mux directly from the studio.

Go to Mux input