I wanted to create a roll-up of the latest news articles on our new BIWUG community site (which still needs to be released).
When I retrieved the news collection data, I only got the front matter data and the markdown content.
Looking at the Astro documentation, I found several ways to get the HTML. The first one was to use the
marked dependency, although I found an easier and better way to utilize the
The Astro.glob() function is a way to retrieve files from a directory. It takes a glob pattern as its input, and it returns an array of the files that match the pattern.
For example, the following code would retrieve all of the news articles in the
The nice part about the
Astro.glob() function is that it returns the front matter data and the Astro Content component. This means that you can use the Astro Content component to render the HTML.
On the BIWUG website, I used it as follows:
info You can also use the
getCollection()API, but this requires you to use
entry.render()for each news article.