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

feat: allow integrations to refresh content layer data #11878

Merged
merged 18 commits into from
Sep 3, 2024
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Aug 29, 2024

Changes

Adds a new refreshContent helper to the 'astro:server:setup' hook context. This allows an integration to trigger a refresh of the content layer. Uses for this could be to enable a webhook endpoint during dev, or to connect to a CMS and watch for updates.

It can optionally make this a selective sync by passing a loaders array, which means it will only sync collections that use the loader with that name. It can also pass an optional context object, which is made available to the loader. This can be used to do things such as pass an incoming webhook body.

Includes some cherry-picked commits from #11902

Testing

Added an example webhook endpoint to the content layer fixture, and a test that uses this.

Docs

This will need an update to the integration API docs. It includes a changeset with usage examples.

Copy link

changeset-bot bot commented Aug 29, 2024

🦋 Changeset detected

Latest commit: 27f3654

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Aug 29, 2024
@ematipico
Copy link
Member

@ascorbic can you link to us the chapter of the RFC that talks about about this new feature? If there isn't, we should add it before merging the PR

packages/astro/src/integrations/hooks.ts Outdated Show resolved Hide resolved
.changeset/curvy-walls-kneel.md Outdated Show resolved Hide resolved
@ascorbic
Copy link
Contributor Author

ascorbic commented Aug 30, 2024

@ematipico I proposed it here, though haven't added the final API to the PR yet

@ematipico
Copy link
Member

It should be added to the document, yes

@ascorbic
Copy link
Contributor Author

On it. Also need to work out why the test is failing here but not locally!

@ascorbic
Copy link
Contributor Author

RFC updated with a new section

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice addition here @ascorbic ! Just had some suggestions for your consideration to maybe tighten up with more direct instructions, and I always prefer to front load the name of the new thing being added so that if people stop reading after a few words, they know which property to look up or search for! 😄

.changeset/curvy-walls-kneel.md Outdated Show resolved Hide resolved
.changeset/curvy-walls-kneel.md Outdated Show resolved Hide resolved
.changeset/curvy-walls-kneel.md Outdated Show resolved Hide resolved
ascorbic and others added 2 commits September 2, 2024 16:43
@ascorbic ascorbic merged commit 334948c into next Sep 3, 2024
14 checks passed
@ascorbic ascorbic deleted the integration-sync branch September 3, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants