summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--cmd/main.go14
-rw-r--r--config.yaml1
-rw-r--r--internal/build/build.go11
4 files changed, 25 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index c06f65a..fbb73d6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,17 @@
all: run
run:
- go run .
+ go run ./cmd
build:
+ go run ./cmd build
+
+build-release:
echo "Building Kite release"
- go build -ldflags="-s -w" -o kite-release
+ go build -ldflags="-s -w" -o kite-release ./cmd
upx --best --lzma kite-release
echo "Successfully built release binary"
stat -c %s ./kite-release
serve:
- go run main.go serve
+ go run ./cmd serve
diff --git a/cmd/main.go b/cmd/main.go
index e60dbb7..13970cc 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -12,8 +12,6 @@ import (
internal "github.com/HimanshuSardana/kite/internal/build"
)
-var themeName = "gruvbox"
-
func copyFile(src, dst string) error {
in, err := os.Open(src)
if err != nil {
@@ -35,12 +33,14 @@ func copyFile(src, dst string) error {
return err
}
+var defaultThemeName = "modern-dark"
+
func main() {
args := os.Args
if len(args) > 1 {
switch args[1] {
case "serve":
- copyFile("./themes/"+themeName+"/style.css", "./output/style.css")
+ copyFile("./themes/"+defaultThemeName+"/style.css", "./output/style.css")
fs := http.FileServer(http.Dir("./output/"))
http.Handle("/", fs)
@@ -52,7 +52,13 @@ func main() {
log.Fatalf("Error occured %s\n", err)
}
case "build":
- internal.Build()
+ if len(os.Args) <= 2 {
+ themeName := defaultThemeName
+ internal.Build(themeName)
+ } else {
+ themeName := os.Args[2]
+ internal.Build(themeName)
+ }
case "list-themes":
themeList := internal.ListThemes()
fmt.Println(strings.Join(themeList, "\n"))
diff --git a/config.yaml b/config.yaml
index 7c0463f..98edbd2 100644
--- a/config.yaml
+++ b/config.yaml
@@ -2,3 +2,4 @@ siteTitle: "himanshu.co"
authorName: "Himanshu Sardana"
authorRole: "Linux Enthusiast"
authorBio: "i use arch btw"
+# defaultTheme: "modern-light"
diff --git a/internal/build/build.go b/internal/build/build.go
index 74dda4e..4511745 100644
--- a/internal/build/build.go
+++ b/internal/build/build.go
@@ -66,7 +66,11 @@ type Post struct {
Title string
}
-func Build() {
+func Build(themeName string) {
+ if themeName == "" {
+ themeName = "modern-light"
+ }
+
summaries := make([]PostSummary, 0)
err := filepath.WalkDir(contentDir, func(path string, d fs.DirEntry, err error) error {
@@ -137,8 +141,9 @@ func Build() {
fmt.Println("All files processed!")
fmt.Println(posts)
+ fmt.Println(themeName)
- renderHomePage(summaries, outputDir)
+ renderHomePage(themeName, summaries, outputDir)
}
func convertToHtml(path string) (Frontmatter, []byte, []TOCItem) {
@@ -194,7 +199,7 @@ func extractText(h *ast.Heading) string {
return text
}
-func renderHomePage(summaries []PostSummary, outputDir string) {
+func renderHomePage(themeName string, summaries []PostSummary, outputDir string) {
sort.Slice(summaries, func(i, j int) bool {
return summaries[i].Date > summaries[j].Date
})