hexo-server-live
Advanced tools
+4
-0
@@ -0,1 +1,5 @@ | ||
| ## v0.2.8 (2024-01-16) | ||
| - Improvement: replace all stylesheets when the path does not match. | ||
| ## v0.2.7 (2024-01-16) | ||
@@ -2,0 +6,0 @@ |
+15
-10
@@ -19,13 +19,18 @@ module.exports = function({ | ||
| if (data.type === "style") { | ||
| const links = document.querySelectorAll("link"); | ||
| for (const link of links) { | ||
| const url = new URL(link.href); | ||
| if (url.host === location.host && url.pathname === data.path) { | ||
| const next = link.cloneNode(); | ||
| next.href = data.path + "?" + Math.random().toString(36).slice(2); | ||
| next.onload = () => link.remove(); | ||
| link.parentNode.insertBefore(next, link.nextSibling); | ||
| return; | ||
| const links = document.querySelectorAll("link[rel=stylesheet]"); | ||
| let fallback = false; | ||
| do { | ||
| for (const link of links) { | ||
| const url = new URL(link.href); | ||
| if (url.host === location.host && (fallback || url.pathname === data.path)) { | ||
| const next = link.cloneNode(); | ||
| next.href = url.pathname + "?" + Math.random().toString(36).slice(2); | ||
| next.onload = () => link.remove(); | ||
| link.parentNode.insertBefore(next, link.nextSibling); | ||
| if (!fallback) return; | ||
| } | ||
| } | ||
| } | ||
| if (fallback) return; | ||
| } while (fallback = true); | ||
| } | ||
@@ -32,0 +37,0 @@ |
+1
-1
| { | ||
| "name": "hexo-server-live", | ||
| "version": "0.2.7", | ||
| "version": "0.2.8", | ||
| "description": "Live reload while source file changed for Hexo.", | ||
@@ -5,0 +5,0 @@ "main": "index", |
7332
4.67%113
3.67%