Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

refactor: drop project_path param from config loaders, use cwd instead

author: pi66
date: 2026-07-03 19:41
hash: a38ba3a2b1ce6df795f77153f547c5f070071a45

Diffstat:

M

src/config.py
22 +++++++++++++++---------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff --git a/src/config.py b/src/config.py
index 86816a8..5bdebf4 100644
--- a/src/config.py
+++ b/src/config.py
@@ -62,14 +62,14 @@ def find_project_from_path(project_path: str):
     if not path.exists(path.join(project_path, "config.toml")):
         raise Exception(f"cannot find `config.toml` in: {GRAY(project_path)}")

-def load_tree_config(project_path) -> Tree:
-    config_raw_content = read_file(path.join(project_path, "config.toml"))
+def load_tree_config() -> Tree:
+    config_raw_content = read_file("config.toml")
     config = loads(config_raw_content)
-    markdown  = path.join(project_path, config["tree"].get("markdown",  "src/md"))
-    static    = path.join(project_path, config["tree"].get("static",    "src/static"))
-    templates = path.join(project_path, config["tree"].get("templates", "src/templates"))
-    dest      = path.join(project_path, config["tree"].get("dest",      "src/dest"))
-    plugins   = path.join(project_path, config["tree"].get("plugins",   "src/plugins.py"))
+    markdown  = config["tree"].get("markdown",  "src/md")
+    static    = config["tree"].get("static",    "src/static")
+    templates = config["tree"].get("templates", "src/templates")
+    dest      = config["tree"].get("dest",      "src/dest")
+    plugins   = config["tree"].get("plugins",   "src/plugins.py")

     if not exists(markdown):
         raise FileNotFoundError(f"markdown directory does not exist: {markdown}")
@@ -90,8 +90,8 @@ def load_tree_config(project_path) -> Tree:
         plugins   = plugins,
     )

-def load_webview_config(project_path:str) -> Webview:
-    config_raw_content = read_file(path.join(project_path, "config.toml"))
+def load_webview_config() -> Webview:
+    config_raw_content = read_file("config.toml")
     config = loads(config_raw_content)
     return Webview(
         host        = config["webview"].get("host",        "localhost"),
@@ -101,8 +101,8 @@ def load_webview_config(project_path:str) -> Webview:
         static_path = config["webview"].get("static_path", "/static"),
     )

-def load_extras_config(project_path:str) -> Extras:
-    config_raw_content = read_file(path.join(project_path, "config.toml"))
+def load_extras_config() -> Extras:
+    config_raw_content = read_file("config.toml")
     config = loads(config_raw_content)
     return Extras(
         highlight = config["extras"].get("highlight", "monokai"),