Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API exposing entry and collection data #3246

Closed
vai0 opened this issue Feb 12, 2020 · 2 comments
Closed

API exposing entry and collection data #3246

vai0 opened this issue Feb 12, 2020 · 2 comments

Comments

@vai0
Copy link

vai0 commented Feb 12, 2020

The problem I'm encountering ATM is an entry is not erroring when it has the same identifier field as another entry in the same collection. #2829

As a potential workaround to this problem I see there exists the ability to "hook" into prepublish events with CMS.registerEventListener.

What I'd like to try is on pre-publish, fetch for all the identifier values in the same collection and match that against the currently published entry's identifier value. If there exists a match, somehow throw an error and prevent the publish.

But to do this - I need to know:

  • the identifier value of the entry
  • the identifier values of all entries in the same collection
  1. Are there any API's that CMS exposes that can allow me to get this info?
  2. Is there an API that allows me to throw toast notification errors similar to what field validation errors throw?
@vai0 vai0 changed the title API exposing entry data and collection data API exposing entry and collection data Feb 12, 2020
@saschatu
Copy link

saschatu commented Feb 13, 2020

HI @vai0,
since netlify CMS does not has its own persistancy you can use the API of the repository where the data is stored (e.g. GitHub). OR you get the API through other tools you maybe use anyways for buildign your website - e.g. gridsome, which loads the netlfiy CMS data (by parsing the files) and exposes a GraphQL to browse the data.

EDIT: Gridsome might not be a good idea for this use case because it would have to rebuild after every push of new content in order to have up-to-date data in the graph.

BR
Sascha

@martinjagodic
Copy link
Member

Closing as stale and/or outdated.

@martinjagodic martinjagodic closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants