feat!: Use YAML instead of JSON
site-config.json is now site-config.yml. That was the only usage of JSON, so not much changes. Dep removed: org.json:json Added: org.snakeyaml:snakeyaml-engine Signed-off-by: Minecon724 <git@m724.eu>
This commit is contained in:
parent
721d8d2768
commit
d155079514
3 changed files with 10 additions and 9 deletions
6
pom.xml
6
pom.xml
|
@ -36,9 +36,9 @@
|
||||||
<version>3.2.3</version>
|
<version>3.2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.snakeyaml</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>snakeyaml-engine</artifactId>
|
||||||
<version>20250107</version>
|
<version>2.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class BlogBuilder {
|
||||||
*/
|
*/
|
||||||
public void build() throws IOException {
|
public void build() throws IOException {
|
||||||
if (site == null)
|
if (site == null)
|
||||||
this.site = Site.fromConfig(workingDirectory.resolve("site-config.json"));
|
this.site = Site.fromConfig(workingDirectory.resolve("site-config.yml"));
|
||||||
|
|
||||||
if (template == null)
|
if (template == null)
|
||||||
this.template = new TemplateRenderer(templateDirectory);
|
this.template = new TemplateRenderer(templateDirectory);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.m724.blog.data;
|
package eu.m724.blog.data;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.snakeyaml.engine.v2.api.Load;
|
||||||
|
import org.snakeyaml.engine.v2.api.LoadSettings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -30,15 +31,15 @@ public record Site(
|
||||||
* @throws IOException if an error occurs during file reading
|
* @throws IOException if an error occurs during file reading
|
||||||
*/
|
*/
|
||||||
public static Site fromConfig(Path path) throws IOException {
|
public static Site fromConfig(Path path) throws IOException {
|
||||||
var content = Files.readString(path);
|
var load = new Load(LoadSettings.builder().build());
|
||||||
var json = new JSONObject(content);
|
var yaml = (Map<String, Object>) load.loadFromInputStream(Files.newInputStream(path));
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
String baseUrl = null;
|
String baseUrl = null;
|
||||||
var custom = new HashMap<String, Object>();
|
var custom = new HashMap<String, Object>();
|
||||||
|
|
||||||
for (var key : json.keySet()) {
|
for (var key : yaml.keySet()) {
|
||||||
var value = json.get(key);
|
var value = yaml.get(key);
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "name":
|
case "name":
|
||||||
|
|
Loading…
Add table
Reference in a new issue