add routers themes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package theme // Declare the package at the top
|
||||
package themes // Declare the package at the top
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
@@ -52,3 +52,6 @@ func (tm *ThemeManager) LoadTheme(themeName string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
func NewManager() *ThemeManager {
|
||||
return &ThemeManager{}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package parser // Declare the package at the top
|
||||
package themes // Declare the package at the top
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
config "go_blog/config" // Adjust import path as needed
|
||||
"net/http"
|
||||
"your_project_path/config" // Adjust import path as needed
|
||||
"your_project_path/themes" // Adjust import path as needed
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -24,7 +23,7 @@ func RenderTemplate(c *gin.Context, tmpl string, data gin.H) {
|
||||
// SwitchTheme handles POST requests to switch the current theme
|
||||
func SwitchTheme(c *gin.Context) {
|
||||
newTheme := c.PostForm("theme")
|
||||
manager := themes.GetManager()
|
||||
manager := &ThemeManager{} //themes.GetManager()
|
||||
|
||||
if err := manager.LoadTheme(newTheme); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
|
||||
Reference in New Issue
Block a user