| 1 |
1 |
| 2 --@module plugin.breadcrumb |
2 --@module plugin.breadcrumb |
| 3 |
3 |
| 4 local plugin_breadcrumb={} |
4 local plugin_breadcrumb={} |
| 5 |
5 |
| 6 local path=require("mypath") |
6 function plugin_breadcrumb.trail(env, separator, final_separator) |
| |
7 local f = env.source_file; |
| |
8 local res = "" |
| |
9 local next_separator = final_separator |
| |
10 local path = "../" |
| 7 |
11 |
| 8 function plugin_breadcrumb.trail(env) |
12 function do_page(f) |
| 9 return "(TODO)" |
13 local title = env.pages[f].meta.h1_title or |
| |
14 env.pages[f].meta.title or |
| |
15 "???" |
| |
16 |
| |
17 if env.pages[f] then |
| |
18 res = next_separator .. res |
| |
19 next_separator = separator |
| |
20 res = string.format("<a href=\"%s\">%s</a>", path, title) .. res |
| |
21 path = "../" .. path |
| |
22 end |
| |
23 end |
| |
24 |
| |
25 while true do |
| |
26 print(f) |
| |
27 local p, ext = f:match("(.*/)[^/]+/[^/.]+%.([^/]+)") |
| |
28 if p then |
| |
29 f = p .. "index." .. ext |
| |
30 do_page(f) |
| |
31 else |
| |
32 break |
| |
33 end |
| |
34 end |
| |
35 |
| |
36 local ext = f:match("[^/]+/[^/.]+%.([^/]+)") |
| |
37 if ext then |
| |
38 do_page("index." .. ext) |
| |
39 end |
| |
40 |
| |
41 return res |
| 10 end |
42 end |
| 11 |
43 |
| 12 return plugin_breadcrumb |
44 return plugin_breadcrumb |