Repos / s4g / 3a963409b5
commit 3a963409b5b11da355773ea42873de86be11afeb
Author: Nhân <hi@imnhan.com>
Date: Tue Jul 4 23:49:04 2023 +0700
add GenerateHome option; set default site metadata
diff --git a/main.go b/main.go
index fa79a7b..542fd48 100644
--- a/main.go
+++ b/main.go
@@ -52,7 +52,9 @@ func main() {
a.WriteHtmlFile(&site, pages, startYear)
}
- WriteHomePage(fsys, site, posts, pages, startYear)
+ if site.GenerateHome {
+ WriteHomePage(fsys, site, posts, pages, startYear)
+ }
fsys.WriteFile(FEED_PATH, generateFeed(site, posts, site.HomePath+FEED_PATH))
@@ -65,26 +67,29 @@ func main() {
}
type SiteMetadata struct {
- Address string
- Name string
- Tagline string
- HomePath string
- DisableFooter bool
- Author struct {
+ Address string
+ Name string
+ Tagline string
+ HomePath string
+ ShowFooter bool
+ GenerateHome bool
+ Author struct {
Name string
URI string
Email string
}
}
-func readSiteMetadata(fsys WritableFS) (sm SiteMetadata) {
+func readSiteMetadata(fsys WritableFS) SiteMetadata {
+ sm := SiteMetadata{
+ HomePath: "/",
+ ShowFooter: true,
+ GenerateHome: true,
+ }
_, err := toml.DecodeFS(fsys, "website.toml", &sm)
if err != nil {
panic(err)
}
- if sm.HomePath == "" {
- sm.HomePath = "/"
- }
return sm
}
diff --git a/www/_theme/base.tmpl b/www/_theme/base.tmpl
index 703f97f..0cc1439 100644
--- a/www/_theme/base.tmpl
+++ b/www/_theme/base.tmpl
@@ -18,7 +18,7 @@
<body>
{{template "body" .}}
-{{if not .Site.DisableFooter}}
+{{if .Site.ShowFooter}}
<footer>
© {{if eq .StartYear .Now.Year}}{{.StartYear}}{{else}}{{.StartYear}}–{{.Now.Year}}{{end}} {{.Site.Author.Name}}<br>
Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
diff --git a/www/website.toml b/www/website.toml
index c3a7f0b..18cf5d1 100644
--- a/www/website.toml
+++ b/www/website.toml
@@ -1,8 +1,6 @@
Address = "https://coolzone.example.com"
Name = "CoolZone"
Tagline = "Cool people only."
-HomePath = "/"
-DisableFooter = false
[Author]
Name = "Coolio McCool"