hexo-server-live
Advanced tools
+4
-0
@@ -0,1 +1,5 @@ | ||
| ## v0.2.9 (2024-01-17) | ||
| - Improvement: handle theme config correctly. | ||
| ## v0.2.8 (2024-01-16) | ||
@@ -2,0 +6,0 @@ |
+26
-19
@@ -39,24 +39,8 @@ hexo.extend.filter.register("server_middleware", async (app) => { | ||
| const ext = extname(event.path); | ||
| const output = hexo.extend.renderer.getOutput(event.path); | ||
| let path = "/" + event.path.replace(/^source\//, ""); | ||
| let type = "other"; | ||
| const data = transformProcessedInfo(event.path); | ||
| switch (output) { | ||
| case "css": | ||
| path = path.replace(ext, ".css"); | ||
| type = "style"; | ||
| break; | ||
| case "js": | ||
| type = "script"; | ||
| break; | ||
| } | ||
| info && log.info("Reloading due to changes..."); | ||
| message = | ||
| message = | ||
| `event: ${eventName}\n` + | ||
| `data: ${JSON.stringify({ | ||
| path, | ||
| type | ||
| })}\n\n`; | ||
| `data: ${JSON.stringify(data)}\n\n`; | ||
| } | ||
@@ -87,2 +71,25 @@ | ||
| </script>`); | ||
| function transformProcessedInfo(path) { | ||
| const base = basename(path); | ||
| const ext = extname(path); | ||
| let type = "other"; | ||
| const config_regex = /^_(multiconfig|config(\..+)?)\.yml/; | ||
| if (config_regex.test(base)) { | ||
| type = "config"; | ||
| } | ||
| else { | ||
| const output = hexo.extend.renderer.getOutput(path); | ||
| path = "/" + path.replace(/^source\//, "").replace(ext, `.${output}`); | ||
| type = { | ||
| css: "style", | ||
| js: "script" | ||
| }[output]; | ||
| } | ||
| return { | ||
| path, | ||
| type | ||
| }; | ||
| } | ||
| }); |
+1
-1
| { | ||
| "name": "hexo-server-live", | ||
| "version": "0.2.8", | ||
| "version": "0.2.9", | ||
| "description": "Live reload while source file changed for Hexo.", | ||
@@ -5,0 +5,0 @@ "main": "index", |
+1
-0
| # hexo-server-live | ||
| [](https://www.npmjs.com/package/hexo-server-live) | ||
| [](https://www.npmjs.com/package/hexo-server-live) | ||
@@ -5,0 +6,0 @@ Live reload when source files change for [Hexo]. Support PJAX and Hot-reloading CSS. |
7712
5.18%119
5.31%37
2.78%