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"
|
version = "0.1.0"
|
||||||
source = "path:../../packages/markdown"
|
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]
|
[dependencies]
|
||||||
markdown = { version = "0.1.0", path = "../../packages/markdown" }
|
markdown = { version = "0.1.0", path = "../../packages/markdown" }
|
||||||
frontmatter = { version = "0.1.0", path = "../../packages/frontmatter" }
|
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 markdown
|
||||||
import frontmatter
|
import frontmatter
|
||||||
|
import path
|
||||||
|
|
||||||
type SiteConfig =
|
type SiteConfig =
|
||||||
| SiteConfig(String, String, String, String, String, String, String)
|
| SiteConfig(String, String, String, String, String, String, String)
|
||||||
@@ -145,7 +146,7 @@ fn teSection(e: TagEntry): String =
|
|||||||
TagEntry(_, _, _, _, s) => s,
|
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 = {
|
fn formatDate(isoDate: String): String = {
|
||||||
if String.length(isoDate) < 10 then isoDate else {
|
if String.length(isoDate) < 10 then isoDate else {
|
||||||
@@ -157,17 +158,9 @@ fn formatDate(isoDate: String): String = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn basename(path: String): String =
|
fn basename(p: String): String = path.basename(p)
|
||||||
match String.lastIndexOf(path, "/") {
|
|
||||||
Some(idx) => String.substring(path, idx + 1, String.length(path)),
|
|
||||||
None => path,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dirname(path: String): String =
|
fn dirname(p: String): String = path.dirname(p)
|
||||||
match String.lastIndexOf(path, "/") {
|
|
||||||
Some(idx) => String.substring(path, 0, idx),
|
|
||||||
None => ".",
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sortInsert(sorted: List<Page>, item: Page): List<Page> = insertByDate(sorted, item)
|
fn sortInsert(sorted: List<Page>, item: Page): List<Page> = insertByDate(sorted, item)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user