Skip to content

Commit d2822df

Browse files
committed
Use toml instead of json for config file
1 parent c85f0f7 commit d2822df

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

examples/website-directory/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Configuration file used by genja to generate this website.
2+
# See https://github.com/wigging/genja for more info about genja.
3+
4+
base_url = "https://example.com/testsite"
5+
markdown_dir = "_mdcontent"
6+
template_dir = "_templates"
7+
output_dir = "website"

examples/website-toplevel/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Configuration file used by genja to generate this website.
2+
# See https://github.com/wigging/genja for more info about genja.
3+
4+
base_url = "https://example.com/mywebsite"
5+
markdown_dir = "_notes"
6+
template_dir = "_templates"
7+
output_dir = "."

src/genja/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import argparse
44
import markdown
5-
import json
5+
import tomllib
66
from importlib.metadata import version
77
from jinja2 import Environment, FileSystemLoader
88
from pathlib import Path
@@ -87,9 +87,9 @@ def main():
8787
parser.add_argument("-v", "--version", action="version", version=version("genja"))
8888
args = parser.parse_args()
8989

90-
# Get configuration from JSON file
91-
with open("config.json") as json_file:
92-
config = json.load(json_file)
90+
# Get configuration from TOML file, requires Python 3.11 or higher
91+
with open("config.toml", "rb") as f:
92+
config = tomllib.load(f)
9393

9494
print(f'\n{"Genja command ":.<30} {args.command}')
9595
print(f'{"Base URL ":.<30} {config["base_url"]}')

0 commit comments

Comments
 (0)