JSPM

sanity-plugin-created-by

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q32475F
  • License ISC

Stores the user ID of the current user in. Nothing is displayed

Package Exports

  • sanity-plugin-created-by

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sanity-plugin-created-by) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

'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' })
  ),
...