Reputation: 173
I've noticed a bit of a weird behavior that I've narrowed down to the following:
I have a setup where I import multiple .md files via import.meta.glob
to be parsed into individual bits of content for my site
When I change a value in the frontmatter metadata it should fire off a reload, and show the new value. This only appears to work once. I make my changes in the file, save it, and it shows up. If I then change and save for the second time, it appears to trigger HMR but the old content still shows until I refresh the page manually, then it shows correctly again.
The testing process I used is basically just importing the folder contents and printing the value. Every time I change the number in the title and save the file, it runs the function and logs the supposed new title of the md file I changed:
modules = import.meta.glob("/modules/**/*.md", {eager: true});
console.log(modules["/modules/builds/5inch-beginner/1-16-5-2022-motors-emax-eco-2.md"].metadata.title)
Any subsequent changes to the file only show the title that was first saved. After I refresh the page, it loads the actual current title
I'm kinda stumped as to what could be causing this, not even sure where to begin trying to figure it out. Any ideas would be greatly appreciated ❤️
EDIT: I have a minimal reproduction repo here, it seems like it's also got something to do with the function being imported. If I define and run it in one file it works just fine
Upvotes: 1
Views: 302