mirror of
https://github.com/jackyzha0/hugo-obsidian.git
synced 2024-06-14 11:42:35 +03:00
better path handling
This commit is contained in:
parent
64cef142c7
commit
5ea362d449
9
main.go
9
main.go
@ -32,6 +32,13 @@ func hugoPathTrim(source string) string {
|
|||||||
return strings.TrimSuffix(strings.TrimSuffix(source, "/index"), "_index")
|
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
|
// parse single file for links
|
||||||
func parse(dir, pathPrefix string) []Link {
|
func parse(dir, pathPrefix string) []Link {
|
||||||
// read file
|
// read file
|
||||||
@ -47,7 +54,7 @@ func parse(dir, pathPrefix string) []Link {
|
|||||||
fmt.Printf(" %s\n", trim(target, pathPrefix, ".md"))
|
fmt.Printf(" %s\n", trim(target, pathPrefix, ".md"))
|
||||||
links = append(links, Link{
|
links = append(links, Link{
|
||||||
Source: hugoPathTrim(trim(dir, pathPrefix, ".md")),
|
Source: hugoPathTrim(trim(dir, pathPrefix, ".md")),
|
||||||
Target: strings.Split(target, "#")[0],
|
Target: strings.Split(processTarget(target), "#")[0],
|
||||||
Text: text,
|
Text: text,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const color = (d) => {
|
const color = (d) => {
|
||||||
if (d.id === curPage) {
|
if (d.id === curPage || (d.id === "/" && curPage === "")) {
|
||||||
return "var(--g-node-active)"
|
return "var(--g-node-active)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user