MDX: hotfix hotreload

This commit is contained in:
Fuma Nama
2025-10-30 21:15:13 +08:00
parent fcb45d88f8
commit cd087d2790
2 changed files with 15 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-mdx': patch
---
fix hot reload
+10 -11
View File
@@ -26,21 +26,20 @@ export default function next(): Plugin {
config = v;
// always emit again when async mode enabled
shouldEmitOnChange = false;
for (const collection of config.collections.values()) {
if (
(collection.type === 'doc' && collection.async) ||
(collection.type === 'docs' && collection.docs.async)
) {
shouldEmitOnChange = true;
}
}
shouldEmitOnChange = Array.from(config.collections.values()).some(
(collection) => {
return (
(collection.type === 'doc' && collection.async) ||
(collection.type === 'docs' && collection.docs.async)
);
},
);
},
configureServer(server) {
if (!server.watcher) return;
server.watcher.on('all', async () => {
if (!shouldEmitOnChange) return;
server.watcher.on('all', async (event) => {
if (event === 'change' && !shouldEmitOnChange) return;
await this.core.emitAndWrite({
filterPlugin: (plugin) => plugin.name === 'next',