Created
September 19, 2020 18:12
-
-
Save mornir/b5096d42a999bbae0ff2d8a360f53395 to your computer and use it in GitHub Desktop.
Simple example on how to return a structure depending on the logged in user‘s role.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import S from '@sanity/base/structure-builder' | |
import userStore from 'part:@sanity/base/user' | |
// remember to add rxjs/operators to your dependencies with npm or yarn | |
import { | |
map | |
} from 'rxjs/operators' | |
export default () => userStore.currentUser.pipe( | |
map(({user}) => { | |
const {role} = user | |
if (role === 'administrator') { | |
return S.list().title('Admin structure') | |
// add more structure | |
} | |
return S.list().title('Editor structure') | |
// add more structure | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment