0.1.2 • Published 4 years ago

sanity-plugin-created-by v0.1.2

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

'Created By' Plugin

This plugin stores the user ID of the currently logged in user against a document.

NOTE: If adding to existing document, the user of the first person who accesses the document will be stored against it as the creator

This plugin has no visual display, it goes on behind the scenes.

To install, in the root of the Sanity Studio in the terminal:

sanity install created-by

Schema example:

fields: [
  {
    name: 'createdBy',
    type: 'createdBy',
    title: 'Created By'
  }
]

You can then use it in the deskStructure using a GROQ query $identity:

...
S.listItem()
  .title('My Content')
  .child(
    S.documentList()
      .title('Content')
      .menuItems(S.documentTypeList('content').getMenuItems())
      .filter('_type == $type && createdBy == $identity')
      .params({ type: 'content' })
  ),
...