diff --git a/main.go b/main.go index 75a6fda..2027a57 100644 --- a/main.go +++ b/main.go @@ -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 @@ -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, }) } diff --git a/partials/graph_partial.html b/partials/graph_partial.html index ea9cf1a..17910b8 100644 --- a/partials/graph_partial.html +++ b/partials/graph_partial.html @@ -23,7 +23,7 @@ } const color = (d) => { - if (d.id === curPage) { + if (d.id === curPage || (d.id === "/" && curPage === "")) { return "var(--g-node-active)" }