diff options
Diffstat (limited to 'scripts/metadata.lua')
| -rw-r--r-- | scripts/metadata.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/metadata.lua b/scripts/metadata.lua index 49a9c55..9c8a964 100644 --- a/scripts/metadata.lua +++ b/scripts/metadata.lua | |||
| @@ -130,6 +130,7 @@ end | |||
| 130 | 130 | ||
| 131 | function process_base(build, meta) | 131 | function process_base(build, meta) |
| 132 | meta.namespace = prep_namespace(meta.namespace) | 132 | meta.namespace = prep_namespace(meta.namespace) |
| 133 | meta.id = meta.namespace.full:gsub("^.*/(.-)$", "%1") | ||
| 133 | meta.file_out = utils.stringify(meta.file_out) | 134 | meta.file_out = utils.stringify(meta.file_out) |
| 134 | meta.unlisted = meta.unlisted or (meta.draft and build.mode ~= "dev") | 135 | meta.unlisted = meta.unlisted or (meta.draft and build.mode ~= "dev") |
| 135 | meta.redirect = meta.url and true | 136 | meta.redirect = meta.url and true |
| @@ -164,6 +165,24 @@ function process(global, build, meta) | |||
| 164 | resolve_dates(meta) | 165 | resolve_dates(meta) |
| 165 | end | 166 | end |
| 166 | 167 | ||
| 168 | function find_pos(meta) | ||
| 169 | for _, p in pairs(meta.pages.by_id) do | ||
| 170 | p.parent = meta | ||
| 171 | find_pos(p) | ||
| 172 | p.parent = nil | ||
| 173 | end | ||
| 174 | |||
| 175 | if not meta.parent then return end | ||
| 176 | |||
| 177 | local pages = meta.parent.list_order == "date_desc" and meta.parent.pages.date_desc or meta.parent.pages.all | ||
| 178 | local _, index = pages:find(meta.id) | ||
| 179 | |||
| 180 | if index == nil then return end | ||
| 181 | |||
| 182 | meta.prev = index >= 2 and pages[index - 1] or nil | ||
| 183 | meta.next = index <= #pages - 1 and pages[index + 1] or nil | ||
| 184 | end | ||
| 185 | |||
| 167 | function Meta(meta) | 186 | function Meta(meta) |
| 168 | local build = {} | 187 | local build = {} |
| 169 | 188 | ||
| @@ -180,6 +199,7 @@ function Meta(meta) | |||
| 180 | 199 | ||
| 181 | find_depth(meta) | 200 | find_depth(meta) |
| 182 | process(meta, build, meta) | 201 | process(meta, build, meta) |
| 202 | find_pos(meta) | ||
| 183 | 203 | ||
| 184 | return meta | 204 | return meta |
| 185 | end | 205 | end |
