Improve wiki linking

This commit is contained in:
2026-06-09 18:36:40 +02:00
parent 5525a03179
commit 204e89dbce
3 changed files with 160 additions and 78 deletions
+5 -4
View File
@@ -115,13 +115,14 @@ func wikiTargetHref(target string) string {
return b.String()
}
// wikiTargetExists reports whether the on-disk folder backing the target
// exists under root.
// wikiTargetExists reports whether the on-disk path backing the target exists
// under root. Any existing path — file or folder — counts as resolved; only a
// missing path is treated as broken.
func wikiTargetExists(root, target string) bool {
target = normalizeWikiTarget(target)
fsPath := filepath.Join(root, filepath.FromSlash(strings.TrimPrefix(target, "/")))
info, err := os.Stat(fsPath)
return err == nil && info.IsDir()
_, err := os.Stat(fsPath)
return err == nil
}
// wikiDefaultDisplay returns the last segment of a target, or "/" for the root.