@@ -100,12 +100,23 @@ redef class WikiEntry
100
100
# Relative path to `self` from the target root_url
101
101
fun href : String do return breadcrumbs .join ("/ " )
102
102
103
+ # Relative path to the directory `self` from the target root_url
104
+ fun dir_href : String do return href .dirname
105
+
106
+ # Relative path to the root url from `self`
107
+ fun root_href : String do
108
+ var root_dir = dir_href .relpath ("" )
109
+ # Avoid issues if used as a macro just followed by a `/` (as with url prefix)
110
+ if root_dir == "" then root_dir = ". "
111
+ return root_dir
112
+ end
113
+
103
114
# A relative `href` to `self` from the page `context`.
104
115
#
105
116
# Should be used to navigate between documents.
106
117
fun href_from (context : WikiEntry ): String
107
118
do
108
- var res = context .href . dirname .relpath (href )
119
+ var res = context .dir_href .relpath (href )
109
120
return res
110
121
end
111
122
@@ -174,6 +185,8 @@ redef class WikiSection
174
185
end
175
186
return new WikiSectionIndex (wiki , "index " , self )
176
187
end
188
+
189
+ redef fun dir_href do return href
177
190
end
178
191
179
192
redef class WikiArticle
@@ -212,6 +225,8 @@ class WikiSectionIndex
212
225
redef fun title do return section .title
213
226
214
227
redef fun href do return section .href
228
+
229
+ redef fun dir_href do return section .dir_href
215
230
end
216
231
217
232
# A MarkdownProcessor able to parse wiki links.
0 commit comments