This commit is contained in:
2023-03-09 09:13:07 +08:00
parent 2abd3eccb2
commit 7f54a3c394
7 changed files with 18 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
ARTICLE_PATH=./article
+1
View File
@@ -0,0 +1 @@
.env
+1
View File
@@ -12,6 +12,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
+2
View File
@@ -24,6 +24,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
+1 -1
View File
@@ -16,7 +16,7 @@ func Article(c *gin.Context) {
id = strings.Replace(id, "-", "/", -1)
articleBasePath := "./article"
articleBasePath := os.Getenv("ARTICLE_PATH")
articlePath := articleBasePath + "/" + id + ".md"
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func Index(c *gin.Context) {
articleBasePath := "./article"
articleBasePath := os.Getenv("ARTICLE_PATH")
list := make([]string, 0)
+11
View File
@@ -2,10 +2,21 @@ package main
import (
"flag"
"log"
"os"
"strconv"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
os.Exit(1)
}
r := Router()
r.LoadHTMLGlob("tmpl/*")
r.Static("/statics", "./statics")