diff --git a/src/pages/en/reference/directives-reference.md b/src/pages/en/reference/directives-reference.md index b33e46ff102fac..1b45696222b795 100644 --- a/src/pages/en/reference/directives-reference.md +++ b/src/pages/en/reference/directives-reference.md @@ -67,6 +67,25 @@ const cmsContent = await fetchHTMLFromMyCMS(); ``` +`set:html={Promise}` injects an HTML string into an element that is wrapped in a Promise. + +This can be used to inject HTML stored externally, such as in a database. + +```astro +--- +import api from '../db/api.js'; +--- +
+``` + +`set:html={Promise}` injects a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) into an element. + +This is most helpful when using `fetch()`. For example, fetching old posts from a previous static-site generator. + +```astro +
+``` + ### `set:text` `set:text={string}` injects a text string into an element, similar to setting `el.innerText`. Unlike `set:html`, the `string` value that is passed is automatically escaped by Astro.