fix: update docs and change template name

This commit is contained in:
Zane Schaffer 2022-08-24 13:52:50 -07:00
parent fbbe537771
commit 80eb910b51
7 changed files with 19 additions and 15 deletions

View File

@ -1,12 +1,11 @@
<img align="right" width="250px" src="https://github.com/zschaffer/jenga/blob/a8cbfd372c352d78b7ac91d7b6e439d379d995cb/jenga.png">
# Jenga
[![Go Reference](https://pkg.go.dev/badge/github.com/zschaffer/jenga.svg)](https://pkg.go.dev/github.com/zschaffer/jenga)
![build](https://github.com/zschaffer/jenga/actions/workflows/go.yml/badge.svg)
![build](https://github.com/zschaffer/jenga/actions/workflows/go.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/zschaffer/jenga)](https://goreportcard.com/report/github.com/zschaffer/jenga)
A tool for building static single page blogs in [Go](https://golang.org/).
## Details
@ -37,13 +36,13 @@ go install
Jenga has some basic setting up in order to get going; sort of like the real game!
### Set up your own `template.html` or copy it from the releases tab
### Set up your own `jenga.tmpl` or copy it from the releases tab
Jenga uses Go's [`html/template`](https://pkg.go.dev/html/template) library for template construction. Read their [doc's](https://pkg.go.dev/html/template) for more information on how to manipulate your data. The basic thing required in your `template.html` is a `{{.}}` block to render the data converted from your `.md` files.
Jenga uses Go's [`html/template`](https://pkg.go.dev/html/template) library for template construction. Read their [doc's](https://pkg.go.dev/html/template) for more information on how to manipulate your data. The basic thing required in your `jenga.tmpl` is a `{{.}}` block to render the data converted from your `.md` files.
The included template.html file looks something like this:
The included `jenga.tmpl` file looks something like this:
```html
```tmpl
<body>
<!-- Wrap everything in a div -->
<div>

9
cli.go
View File

@ -1,5 +1,6 @@
package main
// TODO: add documentation to all functions
import (
"errors"
"flag"
@ -16,9 +17,9 @@ import (
// config represents a toml file used to configure jenga
type config struct {
InputDirPath string
OutputDirPath string
TemplatePath string
InputDirPath string // path to a directory of markdown files to be consumed by jenga
OutputDirPath string // path to output directory of html files
TemplatePath string // path to go-styled template.html
}
const AppVersion = "v0.1.1"
@ -45,6 +46,7 @@ func run() error {
if err != nil {
return fmt.Errorf("failed to get config (%q) %w", *configPath, err)
}
inputFilePaths, err := getInputFilePaths(cfg.InputDirPath)
if err != nil {
return fmt.Errorf("failed to get input file paths (%q) %w", cfg.InputDirPath, err)
@ -61,6 +63,7 @@ func run() error {
template: template,
}
// Print out Jenga status
fmt.Printf("\033[0;34mconfig\033[0m = %q\n", *configPath)
fmt.Printf("\033[0;34mtemplate\033[0m = %q\n", cfg.TemplatePath)
fmt.Printf("\033[0;34minput\033[0m = %q\n", cfg.InputDirPath)

View File

@ -7,18 +7,20 @@ import (
)
func TestRun(t *testing.T) {
// TODO
}
func TestParseInput(t *testing.T) {
// TODO
}
func TestGetTemplate(t *testing.T) {
got, err := getTemplate("./testdata/template.html")
got, err := getTemplate("./testdata/jenga.tmpl")
if err != nil {
t.Errorf("failed to get template: %v", err)
}
want, _ := template.ParseFiles("./testdata/template.html")
want, _ := template.ParseFiles("./testdata/jenga.tmpl")
if !reflect.DeepEqual(got, want) {
t.Errorf("got %v, want %v", got, want)
@ -70,7 +72,7 @@ func TestGetConfig(t *testing.T) {
want := &config{
InputDirPath: "./src",
OutputDirPath: "./build",
TemplatePath: "./template.html",
TemplatePath: "./jenga.tmpl",
}
if !reflect.DeepEqual(got, want) {

View File

@ -2,4 +2,4 @@ InputDirPath = "../blog/src"
OutputDirPath = "../blog/build"
TemplatePath = "../blog/template.html"
TemplatePath = "../blog/jenga.tmpl"

2
testdata/jenga.toml vendored
View File

@ -2,4 +2,4 @@ inputDirPath = "./src"
outputDirPath = "./build"
templatePath = "./template.html"
templatePath = "./jenga.tmpl"