- Add script tags to demo-site HTML files for manual development - Disable CLI inline script injection to prevent duplicate scripts - Add library serving endpoints to servedev command - Update build process to auto-copy library to demo-site - Add CDN URL helpers for future production deployment - Update .gitignore for generated demo-site files Fixes .insertr-gate authentication for manual npm run serve workflow while maintaining clean separation between CLI and manual setups.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package content
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
)
|
|
|
|
// Embedded library assets
|
|
//
|
|
//go:embed assets/insertr.min.js
|
|
var libraryMinJS string
|
|
|
|
//go:embed assets/insertr.js
|
|
var libraryJS string
|
|
|
|
// GetLibraryScript returns the appropriate library version
|
|
func GetLibraryScript(minified bool) string {
|
|
if minified {
|
|
return libraryMinJS
|
|
}
|
|
return libraryJS
|
|
}
|
|
|
|
// GetLibraryVersion returns the current embedded library version
|
|
func GetLibraryVersion() string {
|
|
return "1.0.0"
|
|
}
|
|
|
|
// GetLibraryURL returns the appropriate library URL for script injection
|
|
func GetLibraryURL(minified bool, isDevelopment bool) string {
|
|
if isDevelopment {
|
|
// Local development URLs - relative to served content
|
|
if minified {
|
|
return "/insertr/insertr.min.js"
|
|
}
|
|
return "/insertr/insertr.js"
|
|
}
|
|
|
|
// Production URLs - use CDN
|
|
return GetLibraryCDNURL(minified)
|
|
}
|
|
|
|
// GetLibraryCDNURL returns the CDN URL for production use
|
|
func GetLibraryCDNURL(minified bool) string {
|
|
version := GetLibraryVersion()
|
|
if minified {
|
|
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/@insertr/lib@%s/dist/insertr.min.js", version)
|
|
}
|
|
return fmt.Sprintf("https://cdn.jsdelivr.net/npm/@insertr/lib@%s/dist/insertr.js", version)
|
|
}
|