-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeta.yml
46 lines (31 loc) · 1.4 KB
/
meta.yml
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
language: Rust
sort_order: 2
---
Parser of my blog post Org mode based format. It takes Org mode format as the input and gives JSON with fields =title=, =excerpt= and =body= as the output. It will also surface any top-level properties.
My raw blog posts are available [[https://github.com/jakub-stastny/data.blog][here]], they can serve as an example of expected input.
For =DATE=, see https://orgmode.org/manual/Export-Settings.html. We use the ISO 8601 standard for formatting it.
** Format
#+BEGIN_SRC org
#+DATE: 2021-06-11T18:37:05+05:00
* Blog post title
This is the excerpt of the blog post.
** First heading
Content
#+END_SRC
#+BEGIN_SRC javascript
// TODO: Make it a Rust example once I know how the smeg to program in it.
import { postToJSON, bodyToHTML } from "jakub-stastny/blog.parser.org"
const post = postToJSON(org_string, timezone)
console.log(JSON.stringify(post))
#+END_SRC
#+BEGIN_SRC json
{
"title": "Blog post title",
"excerpt": "This is the excerpt of the blog post.",
"body": "** First heading\n\nContent",
"published_timestamp": 1623454660
}
#+END_SRC
Notice that the =body= is still Org mode formatted.
Nothing is being exported to HTML, since we parse Org mode on the front-end as well. That's what the =bodyToHTML= function is for: just compile this package as a WebAssembly module and use it on both your back-end and your front-end!
Published timestamp is unix epoch timestamp.