I'm using the glob import functionality of Vite to bring in multiple markdown files to a SvelteKit page:
<script context="module">
export async function load() {
const employmentsMeta =
import.meta.globEager('./employments/*.md');
return {
props: {
employmentsMeta: employmentsMeta
}
};
}
</script>
<script>
export let employmentsMeta;
</script>
This works well for me to access the metadata via employmentsMeta[Object.keys(employmentsMeta)[0]]['metadata']. I'm having difficulty accessing the actual contents of the markdown file, however - no matter how I attempt to access it, it seems to be coming back as undefined.
For example, console.log(employmentsMeta[Object.keys(employmentsMeta)[0]['default']]) returns undefined, despite my understanding that there's a default export object in there, and the metadata access working as intended.
How do I access the payload / body of the imported markdown?