diff options
| author | delta <darkussdelta@gmail.com> | 2026-01-27 04:18:15 +0100 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2026-01-27 04:18:15 +0100 |
| commit | 3026a05a2a2be91aa160de230a838acd5c2b3536 (patch) | |
| tree | 141ea424f7c4149c27e6749a73fec7dd4fd354ab /.zs/components/nav | |
| parent | ce0a6c0388b4684d8f15a7ff1049e42e2d8cc63c (diff) | |
Diffstat (limited to '.zs/components/nav')
| -rwxr-xr-x | .zs/components/nav | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/.zs/components/nav b/.zs/components/nav new file mode 100755 index 0000000..9ec3453 --- /dev/null +++ b/.zs/components/nav @@ -0,0 +1,63 @@ +#!/usr/bin/lua + +package.path = ".zs/?.lua;" .. package.path +local html = require "components.html" + +---@class Link +---@field url string +---@field title string +---@field index boolean? + +---@type Link[] +local links = { + { + url = "/", + title = "home", + }, + { + url = "/projects.html", + title = "projects" + }, + { + url = "/posts.html", + title = "ramblings" + }, + { + url = "/rss.xml", + title = "rss" + } +} + +local function get_file_stem(path) + return path + :gsub(".[^.]*$", "") -- get rid of ext + :gsub(".*/", "") -- get rid of prefix +end + +local current_file = get_file_stem(os.getenv("ZS_FILE")) + +local acc = {} + +for _, link in ipairs(links) do + local title = link.title + if current_file == get_file_stem(link.url) or current_file == "index" and link.url == "/" then + title = "[" .. title .. "]" + end + + table.insert(acc, { + tag = "li", + { + tag = "a", + href = link.url, + title + } + }) +end + +print(html { + tag = "nav", + { + tag = "ul", + acc + } +}) |
