new: Complete modules related to home page, archive page and article page

This commit is contained in:
2024-12-16 14:13:58 +08:00
parent 04267841f0
commit 65e5e9eafc
49 changed files with 1547 additions and 1 deletions

37
config/mConfig.go Normal file
View File

@@ -0,0 +1,37 @@
package config
import (
"io"
"log"
"os"
"gopkg.in/yaml.v3"
)
type MConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Template string `yaml:"template"`
MSite mSite `yaml:"site"`
}
var MConfigInstance *MConfig
func init() {
configFile, err := os.OpenFile("config.yaml", os.O_RDONLY, os.ModePerm)
if err != nil {
log.Fatal(err)
}
defer configFile.Close()
configByte, err := io.ReadAll(configFile)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(configByte, &MConfigInstance)
if err != nil {
log.Fatal(err)
}
}