Build a complete static site generator in Lux that faithfully clones blu.cx (elmstatic). Generates 14 post pages, section indexes, tag pages, and a home page with snippets grid from markdown content. ISSUES.md documents 15 Lux language limitations found during the project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
61 lines
2.2 KiB
Plaintext
61 lines
2.2 KiB
Plaintext
// Site configuration loaded from config.json
|
|
|
|
pub type SiteConfig =
|
|
| SiteConfig(String, String, String, String, String, String, String)
|
|
// title url author desc contentDir outputDir staticDir
|
|
|
|
pub fn loadConfig(path: String): SiteConfig with {File} = {
|
|
let raw = File.read(path);
|
|
let json = match Json.parse(raw) { Ok(j) => j, Err(_) => match Json.parse("\{\}") { Ok(j2) => j2 } };
|
|
let title = match Json.get(json, "siteTitle") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "Site" },
|
|
None => "Site"
|
|
};
|
|
let url = match Json.get(json, "siteUrl") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "" },
|
|
None => ""
|
|
};
|
|
let author = match Json.get(json, "author") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "" },
|
|
None => ""
|
|
};
|
|
let desc = match Json.get(json, "description") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "" },
|
|
None => ""
|
|
};
|
|
let contentDir = match Json.get(json, "contentDir") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "content" },
|
|
None => "content"
|
|
};
|
|
let outputDir = match Json.get(json, "outputDir") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "_site" },
|
|
None => "_site"
|
|
};
|
|
let staticDir = match Json.get(json, "staticDir") {
|
|
Some(v) => match Json.asString(v) { Some(s) => s, None => "static" },
|
|
None => "static"
|
|
};
|
|
SiteConfig(title, url, author, desc, contentDir, outputDir, staticDir)
|
|
}
|
|
|
|
pub fn getTitle(c: SiteConfig): String =
|
|
match c { SiteConfig(t, _, _, _, _, _, _) => t }
|
|
|
|
pub fn getUrl(c: SiteConfig): String =
|
|
match c { SiteConfig(_, u, _, _, _, _, _) => u }
|
|
|
|
pub fn getAuthor(c: SiteConfig): String =
|
|
match c { SiteConfig(_, _, a, _, _, _, _) => a }
|
|
|
|
pub fn getDescription(c: SiteConfig): String =
|
|
match c { SiteConfig(_, _, _, d, _, _, _) => d }
|
|
|
|
pub fn getContentDir(c: SiteConfig): String =
|
|
match c { SiteConfig(_, _, _, _, cd, _, _) => cd }
|
|
|
|
pub fn getOutputDir(c: SiteConfig): String =
|
|
match c { SiteConfig(_, _, _, _, _, od, _) => od }
|
|
|
|
pub fn getStaticDir(c: SiteConfig): String =
|
|
match c { SiteConfig(_, _, _, _, _, _, sd) => sd }
|