From bc9b0aa58bbf87111ddb0d6ac86eb51bb0cd8e2c Mon Sep 17 00:00:00 2001 From: Naomi Roberts Date: Sat, 28 Feb 2026 03:37:59 +0000 Subject: [PATCH] docs: Rewrite to use frontmatter for navigation Signed-off-by: Naomi Roberts --- docs/home.md | 6 ----- docs/index.md | 7 ++++++ docs/itemnames.md | 7 ++++-- docs/modelapp.md | 9 +++++-- docs/pronouns.md | 7 ++++-- docs/recipes.md | 7 +++++- flake.nix | 4 ++-- site/dev/site_dev.gleam | 36 ++++++++++++++++++++++++---- site/gleam.toml | 1 + site/manifest.toml | 3 +++ site/src/site/contents.gleam | 46 ++++++++++++++++++++++++++++++++++++ site/src/site/docs.gleam | 41 ++++++++++++++++++++++++++++---- site/src/site/wrapper.gleam | 13 ++++++++++ 13 files changed, 164 insertions(+), 23 deletions(-) delete mode 100644 docs/home.md create mode 100644 docs/index.md create mode 100644 site/src/site/contents.gleam create mode 100644 site/src/site/wrapper.gleam diff --git a/docs/home.md b/docs/home.md deleted file mode 100644 index 90af66e..0000000 --- a/docs/home.md +++ /dev/null @@ -1,6 +0,0 @@ -# Documentation - -- [Name Colours and Pronouns](/pronouns) -- [Model Applier](/modelapp) -- [Custom Item Lore](/itemnames) -- [Custom Recipes & Items](/recipes) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..e9e2c4e --- /dev/null +++ b/docs/index.md @@ -0,0 +1,7 @@ +--- +title: "Home" +slug: "/" +category: "" +--- + +Explanation and shit here fukken do some shit yk diff --git a/docs/itemnames.md b/docs/itemnames.md index b56c082..048a520 100644 --- a/docs/itemnames.md +++ b/docs/itemnames.md @@ -1,4 +1,8 @@ -[\[Back\]](/) +--- +title: "Custom Item Lore" +slug: "/itemnames" +category: "Commands" +--- # Colours and Pronouns The server has a custom command to let you easily set a custom colour, prefix and suffix on your name. This is useful for setting pronouns! @@ -20,4 +24,3 @@ To set your pronouns, do `/name prefix "your/pronouns"`. Minecraft's formatting codes can be used to format your prefix, suffix or nickname. Instead of the `§` character, use `&`. Alongside Minecraft's default formatting codes, the `&#` format can be used as well. Useful tools to easily create formatted names are available [here](https://mcnick.surge.sh/) and [here](https://nickgen.netlify.app/). Usage of formatting codes in names can be disabled in the config file. - diff --git a/docs/modelapp.md b/docs/modelapp.md index b1941f1..9ac5abe 100644 --- a/docs/modelapp.md +++ b/docs/modelapp.md @@ -1,4 +1,9 @@ -[\[Back\]](/) +--- +title: "Model Applier" +slug: "/modelapp" +category: "Commands" +--- + # Model Applier @@ -17,4 +22,4 @@ Simply get in touch with Naomi or Ryan, with your idea/texture, aswell as what y - rp:forge_book ![](/resourcepack/assets/rp/textures/item/forge_book.png) - rp:gaia_book ![](/resourcepack/assets/rp/textures/item/gaia_book.png) - rp:lua_book ![](/resourcepack/assets/rp/textures/item/lua_book.png) -- rp:sol_book ![](/resourcepack/assets/rp/textures/item/sol_book.png) \ No newline at end of file +- rp:sol_book ![](/resourcepack/assets/rp/textures/item/sol_book.png) diff --git a/docs/pronouns.md b/docs/pronouns.md index b56c082..df38093 100644 --- a/docs/pronouns.md +++ b/docs/pronouns.md @@ -1,4 +1,8 @@ -[\[Back\]](/) +--- +title: "Name Colours and Pronouns" +slug: "/pronouns" +category: "Commands" +--- # Colours and Pronouns The server has a custom command to let you easily set a custom colour, prefix and suffix on your name. This is useful for setting pronouns! @@ -20,4 +24,3 @@ To set your pronouns, do `/name prefix "your/pronouns"`. Minecraft's formatting codes can be used to format your prefix, suffix or nickname. Instead of the `§` character, use `&`. Alongside Minecraft's default formatting codes, the `&#` format can be used as well. Useful tools to easily create formatted names are available [here](https://mcnick.surge.sh/) and [here](https://nickgen.netlify.app/). Usage of formatting codes in names can be disabled in the config file. - diff --git a/docs/recipes.md b/docs/recipes.md index 370e650..33154e7 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -1,4 +1,9 @@ -[\[Back\]](/) +--- +title: "Custom Recipes & Items" +slug: "/recipes" +category: "Tweaks" +--- + # Server Exclusive Items diff --git a/flake.nix b/flake.nix index 932c91c..4a11f3d 100644 --- a/flake.nix +++ b/flake.nix @@ -25,8 +25,8 @@ apps = forEachSupportedSystem ({pkgs}: let runtimeInputs = with pkgs; [ gleam - erlang_28 - beam28Packages.rebar3 + beamMinimal28Packages.erlang + beamMinimal28Packages.rebar3 bun zip gnused diff --git a/site/dev/site_dev.gleam b/site/dev/site_dev.gleam index 16386c7..56ca82f 100644 --- a/site/dev/site_dev.gleam +++ b/site/dev/site_dev.gleam @@ -3,9 +3,14 @@ import gleam/io import gleam/list import gleam/result import gleam/string +import lustre/element import lustre/ssg +import mork import simplifile +import site/contents import site/docs +import site/wrapper +import yay const doc_dir = "../docs/" @@ -29,16 +34,39 @@ pub fn main() { |> result.map(result.all) |> result.flatten // drop home from pages - |> result.map(list.filter(_, fn(f) { f.0 != "home" })) + |> result.map(list.filter(_, fn(f) { f.0 != "index" })) |> result.map(dict.from_list) + |> result.map(fn(dict) { + dict.map_values(dict, fn(_key, value) { + let #(frontmatter, doc) = mork.split_frontmatter_from_input(value) + let assert Ok(info) = docs.info_from_yaml(frontmatter) + docs.Document(info:, doc: mork.parse(doc)) + }) + }) - let assert Ok(home) = simplifile.read(doc_dir <> "/home.md") + let assert Ok(index) = simplifile.read(doc_dir <> "/index.md") + let #(index_frontmatter, index_doc) = mork.split_frontmatter_from_input(index) + let assert Ok(index_info) = docs.info_from_yaml(index_frontmatter) + let index_doc = mork.parse(index_doc) + + let all_info = [ + index_info, + ..dict.values(docs) + |> list.map(fn(doc) { doc.info }) + ] let build = ssg.new("./dist") |> ssg.add_static_dir("./assets") - |> ssg.add_static_route("/", docs.view(home)) - |> ssg.add_dynamic_route("/", docs, docs.view) + |> ssg.add_static_route( + "/", + wrapper.view(all_info, [ + docs.view(docs.Document(info: index_info, doc: index_doc)), + ]), + ) + |> ssg.add_dynamic_route("/", docs, fn(a) { + wrapper.view(all_info, [docs.view(a)]) + }) |> ssg.build case build { diff --git a/site/gleam.toml b/site/gleam.toml index 8a16273..4f89030 100644 --- a/site/gleam.toml +++ b/site/gleam.toml @@ -20,6 +20,7 @@ mork = ">= 1.11.1 and < 2.0.0" gleam_regexp = ">= 1.1.1 and < 2.0.0" tom = ">= 1.1.1 and < 2.0.0" mork_to_lustre = ">= 0.2.0 and < 1.0.0" +yay = ">= 2.0.2 and < 3.0.0" [dev-dependencies] gleeunit = ">= 1.0.0 and < 2.0.0" diff --git a/site/manifest.toml b/site/manifest.toml index ce4923f..c0aac71 100644 --- a/site/manifest.toml +++ b/site/manifest.toml @@ -23,6 +23,8 @@ packages = [ { name = "splitter", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "3DFD6B6C49E61EDAF6F7B27A42054A17CFF6CA2135FF553D0CB61C234D281DD0" }, { name = "temporary", version = "1.0.0", build_tools = ["gleam"], requirements = ["envoy", "exception", "filepath", "gleam_crypto", "gleam_stdlib", "simplifile"], otp_app = "temporary", source = "hex", outer_checksum = "51C0FEF4D72CE7CA507BD188B21C1F00695B3D5B09D7DFE38240BFD3A8E1E9B3" }, { name = "tom", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0910EE688A713994515ACAF1F486A4F05752E585B9E3209D8F35A85B234C2719" }, + { name = "yamerl", version = "0.10.0", build_tools = ["rebar3"], requirements = [], otp_app = "yamerl", source = "hex", outer_checksum = "346ADB2963F1051DC837A2364E4ACF6EB7D80097C0F53CBDC3046EC8EC4B4E6E" }, + { name = "yay", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "yamerl"], otp_app = "yay", source = "hex", outer_checksum = "B208F9A14FA2B5E306728812814B01E760BC7F3BCAC4BD6889E9CA8088ACFD48" }, ] [requirements] @@ -35,3 +37,4 @@ mork = { version = ">= 1.11.1 and < 2.0.0" } mork_to_lustre = { version = ">= 0.2.0 and < 1.0.0" } simplifile = { version = ">= 2.3.2 and < 3.0.0" } tom = { version = ">= 1.1.1 and < 2.0.0" } +yay = { version = ">= 2.0.2 and < 3.0.0" } diff --git a/site/src/site/contents.gleam b/site/src/site/contents.gleam new file mode 100644 index 0000000..2a75cb7 --- /dev/null +++ b/site/src/site/contents.gleam @@ -0,0 +1,46 @@ +import gleam/dict +import gleam/list +import gleam/option +import lustre/attribute +import lustre/element/html +import site/docs + +pub fn view(info_list: List(docs.Information)) { + let uncategoried = list.filter(info_list, fn(item) { item.category == "" }) + let categoried = + list.filter(info_list, fn(item) { item.category != "" }) + |> list.map(fn(item) { #(item.category, item) }) + |> list.fold(dict.new(), fn(acc, item) { + dict.upsert(acc, item.0, fn(a) { + case a { + option.Some(existing) -> [item.1, ..existing] + option.None -> [item.1] + } + }) + }) + |> dict.to_list + html.ol( + [], + list.append( + list.map(uncategoried, fn(page) { + html.li([], [ + html.a([attribute.href(page.slug)], [html.text(page.title)]), + ]) + }), + list.map(categoried, fn(category) { + let #(category, pages) = category + html.details([], [ + html.summary([], [html.text(category)]), + html.ol( + [], + list.map(pages, fn(page) { + html.li([], [ + html.a([attribute.href(page.slug)], [html.text(page.title)]), + ]) + }), + ), + ]) + }), + ), + ) +} diff --git a/site/src/site/docs.gleam b/site/src/site/docs.gleam index 8c910c5..9848b6a 100644 --- a/site/src/site/docs.gleam +++ b/site/src/site/docs.gleam @@ -1,14 +1,47 @@ +import gleam/list +import gleam/result import lustre/element import lustre/element/html -import mork +import mork/document import mork/to_lustre +import yay -pub fn view(doc: String) -> element.Element(a) { +pub type Information { + Information(title: String, slug: String, category: String) +} + +pub fn info_from_yaml(yaml: String) -> Result(Information, Nil) { + use yaml <- result.try( + yay.parse_string(yaml) + |> result.map(list.first) + |> result.replace_error(Nil) + |> result.flatten + |> result.map(yay.document_root), + ) + use title <- result.try( + yay.extract_string(yaml, "title") + |> result.replace_error(Nil), + ) + use slug <- result.try( + yay.extract_string(yaml, "slug") + |> result.replace_error(Nil), + ) + use category <- result.try( + yay.extract_string(yaml, "category") + |> result.replace_error(Nil), + ) + Ok(Information(title:, slug:, category:)) +} + +pub type Document { + Document(info: Information, doc: document.Document) +} + +pub fn view(doc: Document) -> element.Element(a) { html.html([], [ html.body( [], - doc - |> mork.parse + doc.doc |> to_lustre.to_lustre, ), ]) diff --git a/site/src/site/wrapper.gleam b/site/src/site/wrapper.gleam new file mode 100644 index 0000000..aef3db6 --- /dev/null +++ b/site/src/site/wrapper.gleam @@ -0,0 +1,13 @@ +import lustre/element +import lustre/element/html +import site/contents +import site/docs + +pub fn view( + info_list: List(docs.Information), + contents: List(element.Element(a)), +) { + html.html([], [ + html.body([], [contents.view(info_list), ..contents]), + ]) +} -- 2.51.2