Skip to content

Is it possible to add some custom config in a field config? #979

Answered by Stupidism
Stupidism asked this question in Q&A
Discussion options

You must be logged in to vote

I found I can get the current collection info with hook: useDocumentInfo. It can solve this specific issue for now:

  const { collection } = useDocumentInfo();
  const collectionSlug = collection?.slug || '';

// or in non react component


const getCurrentCollectionSlug = () => {
  const match =
    /\/admin\/collections\/([a-z-]*)\/.*/.exec(window.location.pathname) || [];

  if (!match) return '';

  return match[1];
};

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Stupidism
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant