From c5de0dc321b611fb95cc364a6bddb0bf5678d340 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Mon, 2 Sep 2024 16:47:13 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Sarah Rainsberger --- .changeset/curvy-walls-kneel.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.changeset/curvy-walls-kneel.md b/.changeset/curvy-walls-kneel.md index a977507099a66..dc04cb0af4aa0 100644 --- a/.changeset/curvy-walls-kneel.md +++ b/.changeset/curvy-walls-kneel.md @@ -2,13 +2,11 @@ 'astro': patch --- -Adds support for allowing integrations to refresh the content layer +Adds a new function `refreshContent` to the `astro:server:setup` hook that allows integrations to refresh the content layer. This can be used, for example, to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes. -This adds a new object to the `astro:server:setup` hook that allows integrations to refresh the content layer. This can be used for example to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes. +By default, `refreshContent` will refresh all collections. You can optionally pass a `loaders` property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. For example, A CMS integration could use this property to only refresh its own collections. -The hook is passed a function called `refreshContent` that can be called to refresh the content layer. It can optionally be passed a `loaders` property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. If not provided, all loaders will be refreshed. A CMS integration could use this to only refresh its own collections. - -It can also pass a `context` object, which will be passed to the loaders. This can be used to pass arbitrary data, such as the webhook body or an event from the websocket. +You can also pass a `context` object to the loaders. This can be used to pass arbitrary data, such as the webhook body, or an event from the websocket. ```ts {