Repos / s4g / d312bff379
commit d312bff3790b3d6a3b08c1c2c4b80aefbcbdb9e5
Author: Nhân <hi@imnhan.com>
Date:   Thu Aug 24 12:04:39 2023 +0700

    more friendly defaults; abort on failure

diff --git a/main.go b/main.go
index 1cb1428..7d42b67 100644
--- a/main.go
+++ b/main.go
@@ -80,14 +80,23 @@ func handleNewCmd(folder string) {
 }
 
 func handleServeCmd(folder, addr string) {
-	djot.StartService()
-	fmt.Println("Started djot.js service")
-
 	absolutePath, err := filepath.Abs(folder)
 	if err != nil {
 		panic(err)
 	}
 
+	finfo, err := os.Stat(filepath.Join(absolutePath, S4gDir))
+	if err != nil || !finfo.IsDir() {
+		fmt.Printf(
+			"Error: %s doesn't have an %s folder\n",
+			absolutePath, S4gDir,
+		)
+		os.Exit(1)
+	}
+
+	djot.StartService()
+	fmt.Println("Started djot.js service")
+
 	fsys := writablefs.WriteDirFS(absolutePath)
 	site, err := ReadSiteMetadata(fsys)
 	if err != nil {
@@ -165,7 +174,10 @@ func runServer(fsys writablefs.FS, webRoot, addr string) *http.Server {
 	}
 
 	go func() {
-		srv.ListenAndServe()
+		err := srv.ListenAndServe()
+		if err != nil {
+			panic(err)
+		}
 	}()
 
 	return srv
diff --git a/metadata.go b/metadata.go
index fb90aee..15e4b16 100644
--- a/metadata.go
+++ b/metadata.go
@@ -83,10 +83,19 @@ type ArticleMetadata struct {
 
 func NewSiteMetadata() SiteMetadata {
 	return SiteMetadata{
-		Root:        "/",
-		ShowFooter:  true,
-		FooterText:  `Made with <a href="https://github.com/nhanb/s4g">s4g</a>`,
-		NavbarLinks: []string{"index.dj"},
+		Address:      "http://example.com",
+		Name:         "This is my website",
+		Tagline:      "and it's fine",
+		Root:         "/",
+		ShowFooter:   true,
+		FooterText:   `Made with <a href="https://github.com/nhanb/s4g">s4g</a>`,
+		NavbarLinks:  []string{"index.dj", "#s4g#https://github.com/nhanb/s4g"},
+		DefaultThumb: "",
+
+		AuthorName:    "Scoop Newsman",
+		AuthorURI:     "https://example.com/scoop",
+		AuthorEmail:   "scoopidoo@example.com",
+		AuthorTwitter: "",
 	}
 }