mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
fix: JSON5 is now supported in frontmatter.
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
- [ ] Don't show annoying log output in tests.
|
- [ ] Don't show annoying log output in tests.
|
||||||
- [ ] improve home link customization.
|
- [ ] improve home link customization.
|
||||||
- [ ] currently an accessibility issue.
|
- [ ] currently an accessibility issue.
|
||||||
- [ ] support JSON5 in in frontmatter
|
- [x] support JSON5 in in frontmatter
|
||||||
- [ ] Create a json schema file for `thor.json`.
|
- [ ] Create a json schema file for `thor.json`.
|
||||||
- [ ] cleanup `#partial switch`es.
|
- [ ] cleanup `#partial switch`es.
|
||||||
- [ ] improve json diagnostics.
|
- [ ] improve json diagnostics.
|
||||||
|
|||||||
+3
-2
@@ -37,7 +37,7 @@ parse_frontmatter :: proc(content: string) -> (fm: Frontmatter, body: string, ok
|
|||||||
json_str := content[:end + 1]
|
json_str := content[:end + 1]
|
||||||
body = strings.trim_left(content[end + 1:], " \t\r\n")
|
body = strings.trim_left(content[end + 1:], " \t\r\n")
|
||||||
|
|
||||||
value, err := json.parse_string(json_str, spec = .JSON)
|
value, err := json.parse_string(json_str, spec = .JSON5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.errorf("failed to parse frontmatter JSON: %v", err)
|
log.errorf("failed to parse frontmatter JSON: %v", err)
|
||||||
return
|
return
|
||||||
@@ -61,7 +61,7 @@ parse_frontmatter :: proc(content: string) -> (fm: Frontmatter, body: string, ok
|
|||||||
}
|
}
|
||||||
fm.layout = json_get_string(obj, "layout")
|
fm.layout = json_get_string(obj, "layout")
|
||||||
fm.og = json_get_open_graph(obj, "og")
|
fm.og = json_get_open_graph(obj, "og")
|
||||||
if v, ok := obj["params"]; ok { fm.params = v }
|
if v, ok := obj["params"]; ok {fm.params = v}
|
||||||
|
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
@@ -117,3 +117,4 @@ json_get_open_graph :: proc(obj: json.Object, key: string) -> Open_Graph {
|
|||||||
}
|
}
|
||||||
return og
|
return og
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user