开源项目 Xe/site 使用教程
siteThe new frontend/backend code for https://xeiaso.net项目地址:https://gitcode.com/gh_mirrors/sit/site
1. 项目的目录结构及介绍
site/
├── assets/
│ ├── css/
│ ├── fonts/
│ ├── img/
│ └── js/
├── content/
│ ├── about.md
│ ├── contact.md
│ └── index.md
├── layouts/
│ ├── default.html
│ └── partials/
├── static/
│ └── favicon.ico
├── config.toml
└── main.go
assets/
:存放项目的静态资源,如CSS、字体、图片和JavaScript文件。content/
:存放Markdown格式的内容文件,如about.md
、contact.md
和index.md
。layouts/
:存放HTML模板文件,default.html
是默认模板,partials/
目录下存放部分模板。static/
:存放静态文件,如favicon图标。config.toml
:项目的配置文件。main.go
:项目的启动文件。
2. 项目的启动文件介绍
main.go
是项目的启动文件,负责初始化和启动Web服务器。以下是main.go
的主要内容:
package main
import (
"log"
"net/http"
"github.com/Xe/site"
)
func main() {
// 初始化路由
router := site.NewRouter()
// 启动服务器
log.Println("Starting server on :8080")
log.Fatal(http.ListenAndServe(":8080", router))
}
main
函数是程序的入口点。site.NewRouter()
初始化路由。http.ListenAndServe(":8080", router)
启动HTTP服务器,监听8080端口。
3. 项目的配置文件介绍
config.toml
是项目的配置文件,用于配置项目的各种参数。以下是config.toml
的一个示例:
title = "Xe's Site"
baseURL = "http://example.com/"
languageCode = "en-us"
[params]
description = "A personal website"
author = "Xe"
title
:网站的标题。baseURL
:网站的基本URL。languageCode
:网站的语言代码。params
:其他参数,如description
和author
。
通过修改config.toml
文件,可以调整网站的标题、URL、语言等信息。
siteThe new frontend/backend code for https://xeiaso.net项目地址:https://gitcode.com/gh_mirrors/sit/site