diff --git a/src/cmd/root.go b/src/cmd/root.go index 247a519..774d534 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -27,8 +27,8 @@ import ( ) var ( - EmbedViews embed.FS - EmbedViewsComponent embed.FS + EmbedIndex embed.FS + EmbedViews embed.FS ) // rootCmd represents the base command when called without any subcommands @@ -61,7 +61,7 @@ func runRest(_ *cobra.Command, _ []string) { log.Fatalln(err) } - engine := html.NewFileSystem(http.FS(EmbedViews), ".html") + engine := html.NewFileSystem(http.FS(EmbedIndex), ".html") engine.AddFunc("isEnableBasicAuth", func(token any) bool { return token != nil }) @@ -71,7 +71,7 @@ func runRest(_ *cobra.Command, _ []string) { }) app.Static("/statics", "./statics") app.Use("/components", filesystem.New(filesystem.Config{ - Root: http.FS(EmbedViewsComponent), + Root: http.FS(EmbedViews), PathPrefix: "views/components", Browse: true, })) @@ -141,9 +141,9 @@ func runRest(_ *cobra.Command, _ []string) { } // Execute adds all child commands to the root command and sets flags appropriately. -func Execute(embedViews embed.FS, embedViewsComponent embed.FS) { +func Execute(embedIndex embed.FS, embedViews embed.FS) { + EmbedIndex = embedIndex EmbedViews = embedViews - EmbedViewsComponent = embedViewsComponent if err := rootCmd.Execute(); err != nil { os.Exit(1) } diff --git a/src/main.go b/src/main.go index 80deb90..2441d04 100644 --- a/src/main.go +++ b/src/main.go @@ -6,11 +6,11 @@ import ( ) //go:embed views/index.html -var embedViews embed.FS +var embedIndex embed.FS //go:embed views -var embedViewsComponent embed.FS +var embedViews embed.FS func main() { - cmd.Execute(embedViews, embedViewsComponent) + cmd.Execute(embedIndex, embedViews) } diff --git a/src/views/index.html b/src/views/index.html index 2327077..9cfcc3c 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -12,7 +12,7 @@ - +