mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
new: Complete modules related to home page, archive page and article page
This commit is contained in:
37
config/mConfig.go
Normal file
37
config/mConfig.go
Normal 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)
|
||||
}
|
||||
}
|
||||
9
config/mInfo.go
Normal file
9
config/mInfo.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
type mInfo struct {
|
||||
Logo string `yaml:"logo"`
|
||||
Title string `yaml:"title"`
|
||||
Author string `yaml:"author"`
|
||||
Language string `yaml:"language"`
|
||||
Copyright string `yaml:"copyright"`
|
||||
}
|
||||
11
config/mMenu.go
Normal file
11
config/mMenu.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package config
|
||||
|
||||
type mMenu struct {
|
||||
Items []mItem `yaml:"items"`
|
||||
}
|
||||
|
||||
type mItem struct {
|
||||
Name string `yaml:"name"`
|
||||
Icon string `yaml:"icon"`
|
||||
Url string `yaml:"url"`
|
||||
}
|
||||
17
config/mPost.go
Normal file
17
config/mPost.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package config
|
||||
|
||||
type mPost struct {
|
||||
TocTitle string `yaml:"toc_title"`
|
||||
RecentPost mRecentPost `yaml:"recent_post"`
|
||||
Archive mArchive `yaml:"archive"`
|
||||
}
|
||||
|
||||
type mRecentPost struct {
|
||||
Title string `yaml:"title"`
|
||||
Number int `yaml:"number"`
|
||||
}
|
||||
|
||||
type mArchive struct {
|
||||
Title string `yaml:"title"`
|
||||
Number int `yaml:"number"`
|
||||
}
|
||||
7
config/mSite.go
Normal file
7
config/mSite.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package config
|
||||
|
||||
type mSite struct {
|
||||
Info mInfo `yaml:"info"`
|
||||
Menu mMenu `yaml:"menu"`
|
||||
Post mPost `yaml:"post"`
|
||||
}
|
||||
Reference in New Issue
Block a user