Improved initialization

This commit is contained in:
Eduard Urbach 2024-06-25 13:11:10 +02:00
parent 68e1211159
commit 29fdd9d26e
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 10 additions and 6 deletions

13
App.go
View File

@ -18,11 +18,16 @@ type App struct {
posts map[string]*Post
}
func (app *App) Init() {
app.html = loadClean("public/app.html")
func New() *App {
html := loadClean("public/app.html")
css := loadClean("public/app.css")
app.html = strings.Replace(app.html, "{head}", fmt.Sprintf("{head}<style>%s</style>", css), 1)
app.posts = loadPosts("posts")
html = strings.Replace(html, "{head}", fmt.Sprintf("{head}<style>%s</style>", css), 1)
posts := loadPosts("posts")
return &App{
html: html,
posts: posts,
}
}
func (app *App) Run() {

View File

@ -1,7 +1,6 @@
package main
func main() {
app := App{}
app.Init()
app := New()
app.Run()
}