From d6a8b960d9e2abe6505b4a335cf158371bfd4b4d Mon Sep 17 00:00:00 2001 From: Brandon Lucas Date: Wed, 18 Feb 2026 14:58:18 -0500 Subject: [PATCH] refactor: replace inline path utilities with path package basename, dirname, and slugFromFilename now delegate to the path package. Co-Authored-By: Claude Opus 4.6 --- lux.lock | 5 +++++ lux.toml | 1 + main.lux | 15 ++++----------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lux.lock b/lux.lock index ae25a6b..d165f26 100644 --- a/lux.lock +++ b/lux.lock @@ -10,3 +10,8 @@ name = "markdown" version = "0.1.0" source = "path:../../packages/markdown" +[[package]] +name = "path" +version = "0.1.0" +source = "path:../../packages/path" + diff --git a/lux.toml b/lux.toml index 97adc25..ba4c330 100644 --- a/lux.toml +++ b/lux.toml @@ -6,3 +6,4 @@ description = "A Lux project" [dependencies] markdown = { version = "0.1.0", path = "../../packages/markdown" } frontmatter = { version = "0.1.0", path = "../../packages/frontmatter" } +path = { version = "0.1.0", path = "../../packages/path" } diff --git a/main.lux b/main.lux index 679b937..e1af522 100644 --- a/main.lux +++ b/main.lux @@ -1,5 +1,6 @@ import markdown import frontmatter +import path type SiteConfig = | SiteConfig(String, String, String, String, String, String, String) @@ -145,7 +146,7 @@ fn teSection(e: TagEntry): String = TagEntry(_, _, _, _, s) => s, } -fn slugFromFilename(filename: String): String = if String.endsWith(filename, ".md") then String.substring(filename, 0, String.length(filename) - 3) else filename +fn slugFromFilename(filename: String): String = path.stripExtension(filename) fn formatDate(isoDate: String): String = { if String.length(isoDate) < 10 then isoDate else { @@ -157,17 +158,9 @@ fn formatDate(isoDate: String): String = { } } -fn basename(path: String): String = - match String.lastIndexOf(path, "/") { - Some(idx) => String.substring(path, idx + 1, String.length(path)), - None => path, -} +fn basename(p: String): String = path.basename(p) -fn dirname(path: String): String = - match String.lastIndexOf(path, "/") { - Some(idx) => String.substring(path, 0, idx), - None => ".", -} +fn dirname(p: String): String = path.dirname(p) fn sortInsert(sorted: List, item: Page): List = insertByDate(sorted, item)