Fix broken wiki links in subdirectories (#193)

pull/195/head
Mickaël Menu 2 years ago committed by GitHub
parent 0bfab74eac
commit c237b4d57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
* [#126](https://github.com/mickael-menu/zk/issues/126) Embedded image links shown as not found.
* [#152](https://github.com/mickael-menu/zk/issues/152) Incorrect timezone for natural dates.
* [#170](https://github.com/mickael-menu/zk/issues/170) Broken wiki links in subdirectories.
## 0.9.0

@ -80,7 +80,7 @@ func (n *Notebook) ParseNoteWithContent(absPath string, content []byte) (*Note,
}
for _, link := range contentParts.Links {
if !strutil.IsURL(link.Href) {
if !strutil.IsURL(link.Href) && link.Type == LinkTypeMarkdown {
// Make the href relative to the notebook root.
href := filepath.Join(filepath.Dir(absPath), link.Href)
link.Href, err = n.RelPath(href)

@ -0,0 +1,2 @@
[note]
filename = "{{slug title}}"

@ -0,0 +1,22 @@
# Wiki links in subdirectories are broken
# https://github.com/mickael-menu/zk/issues/170
$ cd blank-slug
$ touch one.md
$ echo "[[one]]" > two.md
$ mkdir my_dir
$ echo "[[one]]" > my_dir/three.md
$ zk list -qfpath
>my_dir/three.md
>one.md
>two.md
$ zk list --link-to one.md -qfpath
>my_dir/three.md
>two.md
$ zk list --linked-by my_dir/three.md -qfpath
>one.md
Loading…
Cancel
Save