Skip to content

Commit

Permalink
fix: correct links from index
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Jan 11, 2025
1 parent 134aeca commit 7cbe8bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions goBuild/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion goBuild/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions goBuild/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion goBuild/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
}
}

Expand Down
2 changes: 1 addition & 1 deletion goBuild/test_expected/test/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"><link rel="stylesheet" href="/styles.css"><title>Test</title><meta name="description" content="Kyle and Alex&#39;s Personal Recipes"></head><body><nav><div><a href="/"><i><strong>Home</strong></i></a> &nbsp; <a href="/search.html"><i><strong>Search</strong></i></a></div></nav><main data-pagefind-body><h1>Test</h1><div class="wrapped-images-container"><a href="test/test.dj"><article><img src="/test/test.image" alt="Image of Test"><figcaption>Test</figcaption></article></a></div></main></body></html>
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"><link rel="stylesheet" href="/styles.css"><title>Test</title><meta name="description" content="Kyle and Alex&#39;s Personal Recipes"></head><body><nav><div><a href="/"><i><strong>Home</strong></i></a> &nbsp; <a href="/search.html"><i><strong>Search</strong></i></a></div></nav><main data-pagefind-body><h1>Test</h1><div class="wrapped-images-container"><a href="/test/test.html"><article><img src="/test/test.image" alt="Image of Test"><figcaption>Test</figcaption></article></a></div></main></body></html>

0 comments on commit 7cbe8bd

Please sign in to comment.