diff --git a/goBuild/build.go b/goBuild/build.go index 66276ef7..f10ffe05 100644 --- a/goBuild/build.go +++ b/goBuild/build.go @@ -116,8 +116,7 @@ func replaceDjWithHtml(publicDir string, rMap RecipeMap) filepath.WalkFunc { template := func() templ.Component { return recipePage(toTitleName(path)+" : Recipe", section) } - newPath := strings.TrimSuffix(path, filepath.Ext(path)) + ".html" - writeTemplate(newPath, template) + writeTemplate(withHtmlExt(path), template) } if err := os.Remove(path); err != nil { diff --git a/goBuild/build_test.go b/goBuild/build_test.go index 7bffe663..316619d1 100644 --- a/goBuild/build_test.go +++ b/goBuild/build_test.go @@ -28,7 +28,7 @@ func initTestDir() (string, error) { os.RemoveAll(publicTestDir) - cmd := exec.Command("cp", "-R", contentTestDir, publicTestDir) + cmd := exec.Command("cp", "-R", contentTestDir+"/", publicTestDir+"/") _, err = cmd.Output() if err != nil { return "", err diff --git a/goBuild/helpers.go b/goBuild/helpers.go index 1635012f..ff96c091 100644 --- a/goBuild/helpers.go +++ b/goBuild/helpers.go @@ -23,6 +23,10 @@ func toTitleName(path string) string { return toTitleCase(basename) } +func withHtmlExt(path string) string { + return strings.TrimSuffix(path, filepath.Ext(path)) + ".html" +} + func ExitOnError(err error) { if err != nil { log.Fatal(err) diff --git a/goBuild/schemas.go b/goBuild/schemas.go index 37a79d27..726c7f83 100644 --- a/goBuild/schemas.go +++ b/goBuild/schemas.go @@ -23,7 +23,7 @@ func NewRecipe(dirUrl string, path string, imagePath string) Recipe { dirUrl: dirUrl, imagePath: imagePath, name: toTitleName(path), - url: filepath.Join(dirUrl, filepath.Base(path)), + url: "/" + filepath.Join(dirUrl, withHtmlExt(filepath.Base(path))), } } diff --git a/goBuild/test_expected/test/index.html b/goBuild/test_expected/test/index.html index ef889ae7..e1d3ce3e 100644 --- a/goBuild/test_expected/test/index.html +++ b/goBuild/test_expected/test/index.html @@ -1 +1 @@ -Test

Test

Image of Test
Test
\ No newline at end of file +Test

Test

Image of Test
Test
\ No newline at end of file