Nabo v0.0.3 Nabo.Post View Source
A struct that represents a post.
This struct represents a post with its metadata, excerpt and post body, returned by
Nabo.Repo
.
Format
Post should be in this format:
metadata (JSON, mandatory)
---
post excerpt (Markdown, optional)
---
post body (Markdown, mandatory)
For example:
{
"title": "Hello World",
"slug": "hello-world",
"date": "2017-01-01"
}
---
Welcome to my blog!
---
### Hello there!
This is the first post in my blog.
Post excerpt is optional, so if you prefer not to have any excerpt, leave it blank or exclude it from your post.
{
"title": "Hello World",
"slug": "hello-world",
"date": "2017-01-01"
}
---
### Hello there!
This is the first post in my blog.
Link to this section Summary
Functions
Builds struct from markdown content
Puts parsed body content into struct
Puts parsed excerpt content into struct
Link to this section Types
Link to this section Functions
Link to this function
from_string(string)
View Source
from_string(string :: String.t) :: {:ok, Nabo.Post.t} | {:error, any}
Builds struct from markdown content.
Example
string = ~s(
{
"title": "Hello World",
"slug": "hello-world",
"date": "2017-01-01"
}
---
Welcome to my blog!
---
### Hello there!
This is the first post in my blog.
)
{:ok, post} = Nabo.Post.from(string)
Link to this function
put_body_html(post, body_html)
View Source
put_body_html(post :: Nabo.Post.t, body_html :: String.t) :: Nabo.Post.t
Puts parsed body content into struct.
Link to this function
put_excerpt_html(post, excerpt_html)
View Source
put_excerpt_html(post :: Nabo.Post.t, excerpt_html :: String.t) :: Nabo.Post.t
Puts parsed excerpt content into struct.