Skip to content

Commit c9b59ea

Browse files
Gankraliv
authored andcommitted
WIP: load oranda.toml as well
1 parent 3e2a347 commit c9b59ea

File tree

5 files changed

+51
-49
lines changed

5 files changed

+51
-49
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ members = ["generate-css"]
1616

1717
[dependencies]
1818
ammonia = "3"
19-
axoasset = { version = "0.4.0", features = ["json-serde", "toml-edit"] }
19+
axoasset = { version = "0.4.0", features = ["json-serde", "toml-serde", "toml-edit"] }
2020
axocli = "0.1.0"
2121
axoproject = { version = "0.4.6", default-features = false, features = ["cargo-projects", "npm-projects"] }
2222
axum = "0.6.18"

oranda.json

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +0,0 @@
1-
{
2-
"build": {
3-
"path_prefix": "oranda"
4-
},
5-
"styles": {
6-
"theme": "axodark",
7-
"favicon": "https://www.axo.dev/favicon.ico"
8-
},
9-
"marketing": {
10-
"social": {
11-
"image": "https://www.axo.dev/meta_small.jpeg",
12-
"image_alt": "axo",
13-
"twitter_account": "@axodotdev"
14-
},
15-
"analytics": {
16-
"plausible": {
17-
"domain": "opensource.axo.dev"
18-
}
19-
}
20-
},
21-
"components": {
22-
"changelog": true,
23-
"artifacts": {
24-
"package_managers": {
25-
"preferred": {
26-
"npm": "npm install @axodotdev/oranda --save-dev"
27-
},
28-
"additional": {
29-
"cargo": "cargo install oranda --locked --profile=dist",
30-
"npx": "npx @axodotdev/oranda",
31-
"binstall": "cargo binstall oranda",
32-
"nix-env": "nix-env -i oranda",
33-
"nix flake": "nix profile install github:axodotdev/oranda"
34-
}
35-
}
36-
}
37-
}
38-
}

oranda.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build]
2+
path_prefix = "oranda"
3+
4+
[styles]
5+
theme = "axodark"
6+
favicon = "https://www.axo.dev/favicon.ico"
7+
8+
[marketing]
9+
analytics = { plausible = { domain = "opensource.axo.dev" }}
10+
11+
[marketing.social]
12+
image = "https://www.axo.dev/meta_small.jpeg"
13+
image_alt = "axo"
14+
twitter_account = "@axodotdev"
15+
16+
17+
18+
[components]
19+
changelog = true
20+
21+
[components.artifacts.package_managers.preferred]
22+
npm = "npm install @axodotdev/oranda --save-dev"
23+
cargo = "cargo install oranda --locked --profile=dist"
24+
25+
[components.artifacts.package_managers.additional]
26+
npx = "npx @axodotdev/oranda"
27+
binstall = "cargo binstall oranda"
28+
nix-env = "nix-env -i oranda"
29+
"nix flake" = "nix profile install github:axodotdev/oranda"

src/config/oranda_config.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,27 @@ pub struct OrandaLayer {
3535

3636
impl OrandaLayer {
3737
pub fn load(config_path: &Utf8PathBuf) -> Result<Option<OrandaLayer>> {
38-
let config_result = SourceFile::load_local(config_path.as_path());
39-
40-
match config_result {
41-
Ok(config) => {
42-
let data: OrandaLayer = config.deserialize_json()?;
43-
Ok(Some(data))
44-
}
45-
Err(_) => {
46-
tracing::debug!("No config found, using default values");
47-
Ok(None)
38+
let mut config_path = config_path.to_owned();
39+
if config_path.extension() == Some("json") {
40+
if config_path.exists() {
41+
let config = SourceFile::load_local(config_path.as_path())?;
42+
return Ok(Some(config.deserialize_json()?));
43+
} else {
44+
// Temporary hack
45+
config_path.set_extension("toml");
4846
}
4947
}
48+
if !config_path.exists() {
49+
tracing::debug!("No config found, using default values");
50+
return Ok(None);
51+
}
52+
if config_path.extension() == Some("toml") {
53+
tracing::warn!("!!!Using toml config!!!!");
54+
let config = SourceFile::load_local(config_path.as_path())?;
55+
return Ok(Some(config.deserialize_toml()?));
56+
}
57+
58+
tracing::debug!("No config found, using default values");
59+
Ok(None)
5060
}
5161
}

0 commit comments

Comments
 (0)