Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
better path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Jul 18, 2021
1 parent 64cef14 commit 5ea362d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ func hugoPathTrim(source string) string {
return strings.TrimSuffix(strings.TrimSuffix(source, "/index"), "_index")
}

func processTarget(source string) string {
if strings.HasPrefix(source, "/") {
return strings.TrimSuffix(source, ".md")
}
return "/" + strings.TrimSuffix(source, ".md")
}

// parse single file for links
func parse(dir, pathPrefix string) []Link {
// read file
Expand All @@ -47,7 +54,7 @@ func parse(dir, pathPrefix string) []Link {
fmt.Printf(" %s\n", trim(target, pathPrefix, ".md"))
links = append(links, Link{
Source: hugoPathTrim(trim(dir, pathPrefix, ".md")),
Target: strings.Split(target, "#")[0],
Target: strings.Split(processTarget(target), "#")[0],
Text: text,
})
}
Expand Down
2 changes: 1 addition & 1 deletion partials/graph_partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

const color = (d) => {
if (d.id === curPage) {
if (d.id === curPage || (d.id === "/" && curPage === "")) {
return "var(--g-node-active)"
}

Expand Down

0 comments on commit 5ea362d

Please sign in to comment.