diff --git a/.changeset/good-beers-worry.md b/.changeset/good-beers-worry.md new file mode 100644 index 0000000000..d81a24a0f5 --- /dev/null +++ b/.changeset/good-beers-worry.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdown-support': patch +--- + +Expose `html` to `Astro.fetchContent` (#571) diff --git a/docs/reference/api-reference.md b/docs/reference/api-reference.md index e7f6059012..0f04682bfa 100644 --- a/docs/reference/api-reference.md +++ b/docs/reference/api-reference.md @@ -41,8 +41,9 @@ const data = Astro.fetchContent('../pages/post/*.md'); // returns an array of po description: '', **/ astro: { - headers: [], // TODO: document what this means - source: '' // raw source of the markdown file + headers: [], // an array of h1...h6 elements in the markdown file + source: '' // raw source of the markdown file + html: '' // rendered HTML of the markdown file }, url: '' // the rendered path }[] diff --git a/packages/markdown-support/src/index.ts b/packages/markdown-support/src/index.ts index f311efa7c3..f3ceda1a11 100644 --- a/packages/markdown-support/src/index.ts +++ b/packages/markdown-support/src/index.ts @@ -68,7 +68,7 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp } return { - astro: { headers, source: content }, + astro: { headers, source: content, html: result.toString() }, content: result.toString(), }; }