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 <noreply@anthropic.com>
This commit is contained in:
5
lux.lock
5
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"
|
||||
|
||||
|
||||
1
lux.toml
1
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" }
|
||||
|
||||
15
main.lux
15
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<Page>, item: Page): List<Page> = insertByDate(sorted, item)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user