From e2d5b2575ace15e5be8c09f781c8fa9a322ac247 Mon Sep 17 00:00:00 2001 From: robin Date: Sat, 09 May 2026 15:12:15 +0000 Subject: [PATCH] refactor: add lua static site gen --- .envrc | 1 + .gitignore | 4 ++++ .luaurc | 6 ++++++ .nvim.lua | 3 +++ build.zig | 35 ++++++++++++++++++++++++++++++++++- build.zig.zon | 4 ++++ data/_index.md | 21 +++++++++++++++++++++ data/about.md | 31 +++++++++++++++++++++++++++++++ data/badges.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/blog/_index.md | 9 +++++++++ data/blog/building-this-site.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/blog/creating-a-colorscheme.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/blog/neovim-artio-picker.md | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/blog/neovim-native-configuration.md | 422 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/notes/_index.md | 10 ++++++++++ data/notes/artio-live-mode-toggle.md | 12 ++++++++++++ data/notes/artio-released.md | 14 ++++++++++++++ data/notes/aspen-released.md | 13 +++++++++++++ data/notes/ebil-released.md | 14 ++++++++++++++ data/notes/evergarden-npm-release.md | 31 +++++++++++++++++++++++++++++++ data/notes/evergarden-site-release.md | 15 +++++++++++++++ data/notes/evergarden-sublime-text-release.md | 10 ++++++++++ data/notes/evergarden-userstyles-release.md | 20 ++++++++++++++++++++ data/notes/lylla-sections.md | 18 ++++++++++++++++++ data/notes/mimi-released.md | 14 ++++++++++++++ data/notes/site-zig-minimal.md | 13 +++++++++++++ data/redirect/discord.md | 7 +++++++ data/test.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ data/tools/ivy.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ data/tools/lynn.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ justfile | 7 +++---- lua/maivi/components/postpageitem.luau | 22 ++++++++++++++++++++++ lua/maivi/core.luau | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/display.luau | 36 ++++++++++++++++++++++++++++++++++++ lua/maivi/h.luau | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/init.luau | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/iter.luau | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/layouts/base.luau | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/layouts/post.luau | 29 +++++++++++++++++++++++++++++ lua/maivi/pages/404.luau | 17 +++++++++++++++++ lua/maivi/pages/badges.luau | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/pages/blog.luau | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/pages/index.luau | 47 +++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/pages/start.luau | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/partials/bloglist.luau | 39 +++++++++++++++++++++++++++++++++++++++ lua/maivi/partials/breadcrumbs.luau | 12 ++++++++++++ lua/maivi/partials/footer.luau | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/partials/nav.luau | 25 +++++++++++++++++++++++++ lua/maivi/partials/note.luau | 25 +++++++++++++++++++++++++ lua/maivi/partials/search.luau | 23 +++++++++++++++++++++++ lua/maivi/partials/sitename.luau | 11 +++++++++++ lua/maivi/partials/taglist.luau | 22 ++++++++++++++++++++++ lua/maivi/router.luau | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/maivi/types.d.luau | 15 +++++++++++++++ lua/maivi/utils.luau | 18 ++++++++++++++++++ main.luau | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ nix/shell.nix | 11 +++++++++++ selene.toml | 5 +++++ src/config.zig | 2 +- src/handler.zig | 35 +++++++++++++++++------------------ src/helpers.zig | 4 ++-- src/lua.zig | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.zig | 5 ++++- src/root.zig | 10 ++++++++-- src/vfs.zig | 1 - stylua.toml | 9 +++++++++ test.luau | 19 +++++++++++++++++++ 67 file(s) changed, 2907 insertion(s)(+), 30 deletion(s)(-) diff --git a/.envrc b/.envrc new file mode 100644 --- /dev/null +++ b/.envrc @@ -0,0 +1,1 @@ +use flake diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ +# zig .zig-cache zig-out zig-pkg + +# dev +.direnv/ *.tar diff --git a/.luaurc b/.luaurc new file mode 100644 --- /dev/null +++ b/.luaurc @@ -0,0 +1,6 @@ +{ + "aliases": { + "maivi": "./lua/maivi", + "lune": "~/.lune/.typedefs/0.10.4/" + } +} diff --git a/.nvim.lua b/.nvim.lua new file mode 100644 --- /dev/null +++ b/.nvim.lua @@ -0,0 +1,3 @@ +vim.lsp.enable("lua_ls", false) +-- vim.lsp.enable("emmylua_ls") +vim.lsp.enable("luau_lsp") diff --git a/build.zig b/build.zig --- a/build.zig +++ b/build.zig @@ -6,7 +6,7 @@ // executed by an external runner. The functions in `std.Build` implement a DSL // for defining build steps and express dependencies between them, allowing the // build runner to parallelize the build automatically (and the cache system to // know when a step doesn't need to be re-run). -pub fn build(b: *std.Build) void { +pub fn build(b: *std.Build) !void { // Standard target options allow the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options @@ -41,6 +41,30 @@ // which requires us to specify a target. .target = target, }); + const exe_options = b.addOptions(); + mod.addOptions("opts", exe_options); + + const opt_version_string = b.option([]const u8, "version-string", "Override version string. Default is to find out with git."); + const version_slice = if (opt_version_string) |version| version else v: { + if (!std.process.can_spawn) { + std.debug.print("error: version info cannot be retrieved from git. version must be provided using -Dversion-string\n", .{}); + std.process.exit(1); + } + + var code: u8 = undefined; + const git_rev_untrimmed = try b.runAllowFail(&[_][]const u8{ + "git", + "-C", b.build_root.path orelse ".", // affects the --git-dir argument + "--git-dir", ".git", // affected by the -C argument + "rev-parse", "HEAD", + }, &code, .ignore); + const git_rev = std.mem.trim(u8, git_rev_untrimmed, " \n\r"); + + break :v git_rev; + }; + const version = try b.allocator.dupeZ(u8, version_slice); + exe_options.addOption([:0]const u8, "version", version); + // Here we define an executable. An executable needs to have a root module // which needs to expose a `main` function. While we could add a main function // to the module defined above, it's sometimes preferable to split business @@ -82,6 +106,15 @@ .{ .name = "maivi", .module = mod }, }, }), }); + + const zlua = b.dependency("zlua", .{ + .target = target, + .optimize = optimize, + .lang = .luau, + }); + + mod.addImport("zlua", zlua.module("zlua")); + exe.root_module.addImport("zlua", zlua.module("zlua")); const logz = b.dependency("logz", .{ .target = target, diff --git a/build.zig.zon b/build.zig.zon --- a/build.zig.zon +++ b/build.zig.zon @@ -35,6 +35,10 @@ .logz = .{ .url = "git+https://github.com/karlseguin/log.zig?ref=master#7fa8de39ad4d4adc54fce4d9bb0b6bc6c0076592", .hash = "logz-0.0.0-O9YWXsllAgBq-S0z6q8AInWjei8h7polkVVRzJIGE-jW", }, + .zlua = .{ + .url = "git+https://github.com/natecraddock/ziglua?ref=main#b23143c54b2fc5207825336fb7e61220756dc0a6", + .hash = "zlua-0.1.0-hGRpC4t-BQDQJLgY32R_bGhGNHNNULWAh5ltxho4_pQw", + }, }, .paths = .{ "build.zig", diff --git a/data/_index.md b/data/_index.md new file mode 100644 --- /dev/null +++ b/data/_index.md @@ -0,0 +1,21 @@ +## 🪴 garden + +welcome to my internet garden, a cozy corner of the internet for storing my ideas and sharing what i'm working on. + +```bash +curl -L robinwobin.dev +``` + +in my garden you can find my [blog posts](/blog) and more frequently some small [notes](/notes). + +this is where i keep the tools i've built - small creations designed to make +development smoother, workflows simpler, and ideas easier to bring to life. + +- evergarden - a soft, nature-inspired colorscheme +- ivy - a nix-based neovim setup +- lynn.nvim - a lightweight neovim plugin manager _(you can read more about it [here](/blog/neovim-native-configuration))_ +- artio.nvim - a minimal, nature-infused file picker for neovim using the new extui window + +more tools are always growing here - check back later! 🌿 + +you can find links to some cool people on the [badges](/badges) page. diff --git a/data/about.md b/data/about.md new file mode 100644 --- /dev/null +++ b/data/about.md @@ -0,0 +1,31 @@ ++++ +title = "about me :)" ++++ + +###### ✨ i'm passionate about: + + + +###### 🌱 in my projects, i blend these passions together: + + + +> _"Among the roses, beneath the twilight."_ 🌙🌿 + +## how this site was build + +this site is build using the following tools: + +- zola, for static site generation +- nix, for reproducible builds everywhere + +you can read more about it [here](@/blog/building-this-site.md). diff --git a/data/badges.md b/data/badges.md new file mode 100644 --- /dev/null +++ b/data/badges.md @@ -0,0 +1,74 @@ ++++ +title = "badges" +description = "collection of cool badges" ++++ + +{{ badge( + name="robin", + url="https://robinwobin.dev", + img="/badges/me.gif") }} + +```html +robin's 88x31 +``` + +## frends :) + +some awesome people with pretty sites + +{{ badge( + name="june", + url="https://koi.rip", + img="/badges/mimi-the-car.gif") }} +{{ badge( + name="april", + url="https://aprl.pet", + img="/badges/april.gif") }} +{{ badge( + name="kaya", + url="https://tired.moe", + img="/badges/tired.moe.gif") }} +{{ badge( + name="diza", + url="https://dbw.neocities.org", + img="/badges/dbw.png") }} +{{ badge( + name="tasky", + url="https://uwu.network/~tasky", + img="/badges/tasky.webp") }} +{{ badge( + name="elissa", + url="https://elissa.moe", + img="/badges/elissa.png") }} +{{ badge( + name="chloe", + url="https://sapphic.moe", + img="/badges/sapphic.png") }} + +## coil sites + +{{ badge( + name="dinpixels", + url="https://dinpixels.neocities.org", + img="https://dinpixels.neocities.org/src/img/buttons/dinbtn0.gif") }} +{{ badge( + name="oyaswmi", + url="https://oyaswmi.net", + img="https://oyaswmi.net/legacy/stamps/OyaButton.gif" ) }} +{{ badge( + name="appledust", + url="https://www.lejlart.com", + img="https://www.lejlart.com/flist/ad_skullsprinkles.gif" ) }} +{{ badge( + name="lilithdev", + url="https://lilithdev.neocities.org", + img="https://lilithdev.neocities.org/buttons/lilithdevbtn.gif" ) }} +{{ badge( + name="espy", + url="https://espy.world", + img="https://espy.world/img/button.gif" ) }} diff --git a/data/blog/_index.md b/data/blog/_index.md new file mode 100644 --- /dev/null +++ b/data/blog/_index.md @@ -0,0 +1,9 @@ ++++ +title = "blog" +description = "questionable ideas put to paper" +sort_by = "date" +template = "pages/blog.html" +page_template = "pages/post.html" +insert_anchor_links = "left" ++++ + diff --git a/data/blog/building-this-site.md b/data/blog/building-this-site.md new file mode 100644 --- /dev/null +++ b/data/blog/building-this-site.md @@ -0,0 +1,104 @@ ++++ +title = "building this site" +date = 2025-01-22 +updated = 2026-01-07 +description = "my tiny adventure in static site generation" +[taxonomies] +tags = ["site"] ++++ + +## static site generation + +while looking for a static site generator for my site i tried a few interesting +tools, like hugo and astro. i even tried building my own ssg (which failed +miserably). in the end i discovered zola, simple static site generator +written in rust. zola uses tera templates to build sites with minimal effort. + +zola separates content from templates. where markdown files can specify which +templates to use. + +### templates + +here is my blog page. it specifies a template to use for the section. in this +template i can use zola's section variables to create a dynamic posts page +(which i'll get into in a bit). + +```markdown ++++ +title = "blog" +description = "questionable ideas put to paper" +sort_by = "date" +template = "pages/blog.html" +page_template = "pages/post.html" ++++ +``` + +the blog page also specifies a `page_template`. this is the template that will +be used for all child pages (my blogposts). + +in my `pages/blog.html` template i can use zola's section variables to iterate +over all my blogposts and generate a list at build time. + +```tera +{% block content %} + {{ section.content | safe }} + +{% endblock content %} +``` + +## build and deploy + +to ease building and deploying the site i use nix to setup my tools and build. +because the site is static i simply can use github pages to deploy. + +the nix builder simply takes zola as a buildinput and runs the build. i then +copy the static content to the `$out` directory. + +```nix +stdenvNoCC.mkDerivation { + src = ./.; + + nativeBuildInputs = [ + zola + ]; + + buildPhase = '' + runHook preBuild + zola build + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r public/* $out + + runHook postInstall + ''; +} +``` + +deployment is done using a single github +action you can find +[here](https://codeberg.org/comfysage/site/src/commit/0b94d7338c1d7c50c09635b4d20fbeab552d58fd/.github/workflows/deploy.yml). + +{% callout(class="note", title="update: codeberg ci") %} +deployment is now done with codeberg ci +using woodpecker using the config you can +find +[here](https://codeberg.org/comfysage/site/src/commit/0b94d7338c1d7c50c09635b4d20fbeab552d58fd/.woodpecker/deploy.yaml) +{% end %} + +## resources + +