Files
Matt Holloway 06270c78e7 new UI changes
2026-02-02 19:15:22 +00:00

33 lines
847 B
Go

package github
import (
"embed"
)
// UIAssets embeds the built MCP App UI HTML files.
// These files are generated by running `script/build-ui` which compiles
// the React/Primer components in the ui/ directory.
//
//go:embed ui_dist/*.html
var UIAssets embed.FS
// GetUIAsset reads a UI asset from the embedded filesystem.
// The name should be just the filename (e.g., "get-me.html").
func GetUIAsset(name string) (string, error) {
data, err := UIAssets.ReadFile("ui_dist/" + name)
if err != nil {
return "", err
}
return string(data), nil
}
// MustGetUIAsset reads a UI asset and panics if it fails.
// Use this when the asset is required for server operation.
func MustGetUIAsset(name string) string {
html, err := GetUIAsset(name)
if err != nil {
panic("failed to load UI asset " + name + ": " + err.Error())
}
return html
}