Update main.go
CI/CD Pipeline / Test & Lint (push) Waiting to run
CI/CD Pipeline / Build Docker Image (push) Blocked by required conditions
CI/CD Pipeline / Security Scan (push) Waiting to run

This commit is contained in:
2026-08-08 07:15:55 +00:00
parent 9f2e670824
commit 1fd8fff810
+3 -7
View File
@@ -18,13 +18,12 @@ import (
"github.com/gorilla/mux"
"github.com/gorilla/sessions"
"github.com/joho/godotenv"
markdown "github.com/markdownit/markdown-it-go"
"github.com/gomarkdown/markdown"
)
var (
db *sql.DB
sessionStore *sessions.CookieStore
markdownParser *markdown.MarkdownIt
)
// Models
@@ -71,9 +70,6 @@ func init() {
// Load environment variables
godotenv.Load()
// Initialize markdown parser
markdownParser = markdown.New()
// Initialize session store
sessionStore = sessions.NewCookieStore([]byte(getEnv("SESSION_KEY", "dev-session-key")))
}
@@ -250,7 +246,7 @@ func handleViewPost(w http.ResponseWriter, r *http.Request) {
}
// Render markdown
post.Content = markdownParser.Render(post.Content)
post.Content = string(markdown.ToHTML([]byte(post.Content), nil, nil))
// Get tags
tagRows, _ := db.Query("SELECT tag FROM tags WHERE post_id = ?", post.ID)
@@ -681,4 +677,4 @@ func loggingMiddleware(next http.Handler) http.Handler {
log.Printf("%s %s %s", r.Method, r.RequestURI, r.RemoteAddr)
next.ServeHTTP(w, r)
})
}
}