Include embed.js in the binary

This commit is contained in:
Daniele Tonon
2023-11-30 11:49:03 +01:00
parent c6d2d4bf6a
commit 9b6f7f5bde
2 changed files with 5 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import (
func renderEmbedjs(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript")
http.ServeFile(w, r, "templates/embed.js")
return
fileContent, _ := static.ReadFile("static/embed.js")
w.Write(fileContent)
}

View File

@@ -12,12 +12,8 @@
var height = scriptElement.getAttribute('height') || 'auto';
var iframe = document.createElement('iframe');
iframe.src = host + '/' + eventParam + '?embed=yes';
// Basic styles
iframe.style.width = width;
iframe.style.height = height;
// iframe.style.border = '2px solid #b6b6b6';
// iframe.style.borderRadius = '10px';
// Add a class to easily permit overwriting the styles
iframe.classList.add("nostr-embedded")
@@ -29,7 +25,7 @@
}
@media (prefers-color-scheme: dark) {
.nostr-embedded {
border-color: #393939; /* Adjust the color for dark mode */
border-color: #393939;
}
}
`;
@@ -55,9 +51,9 @@
}
}
// Check if dark mode is preferred
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
if (darkModeQuery.matches) {
// Dark mode is preferred
iframe.contentWindow.postMessage({setDarkMode: true}, '*');
}
});