PardallMarkdown.Repository (PardallMarkdown v0.4.4) View Source
Provides the necessary API to retrieve and save parsed content.
Preferrably, use only the get_*
functions. The build_*
and
save_*
functions are used by other PardallMarkdown modules.
Understanding taxonomy Post archives (Link.children
):
- Posts are saved individually (to be retrieved with
PardallMarkdown.Repository.get_by_slug("/a/post/slug")
) and under their taxonomies and taxonomies' hierarchy. A taxonomy archive (all posts of a taxonomy) and its hierarchy are contained inPardallMarkdown.Content.Link.children
when the taxonomy is retrieved by:PardallMarkdown.Repository.get_by_slug("/taxonomy/inner-taxonomy")
PardallMarkdown.Repository.get_content_tree("/taxonomy/inner-taxonomy")
PardallMarkdown.Repository.get_content_tree("/")
- root, which contains all taxonomies, their posts and hierarchy.
- When retrieving a taxonomy by slug with
PardallMarkdown.Repository.get_by_slug("/taxonomy/name")
the taxonomy:children
contains all posts from all of its innermost taxonomies:children
.- For example, the post: "/blog/news/city/foo" appears inside the
:children
of 3 taxonomies:"/blog"
,"/blog/news"
and"/blog/news/city"
.
- For example, the post: "/blog/news/city/foo" appears inside the
- On the other hand, taxonomies in the content tree retrieved with
PardallMarkdown.Repository.get_content_tree/1
contains only their immediate children posts.- For example, the post: "/blog/news/city/foo" appears only inside the
:children
its definying taxonomy:"/blog/news/city"
.
- For example, the post: "/blog/news/city/foo" appears only inside the
Link to this section Summary
Functions
Gets all links, ordered by slug
type
Gets a map with all links, where the map keys are the links' slugs.
type
Gets all posts, unordered.
Gets a single post or taxonomy by slug.
Same as get_by_slug/1
but raises PardallMarkdown.Content.NotFoundError
if slug not found.
Gets content trees. The content tree contains nested taxonomies and their nested posts.
Gets the content taxonomy tree, ordered
and nested by Link.level
Rebuild indexes and then notify with a custom callback that the content has been reloaded.
Link to this section Functions
Gets all links, ordered by slug
type
:
:all
:taxonomy
: only taxonomy links:post
: only post links
Gets a map with all links, where the map keys are the links' slugs.
type
:
:all
:taxonomy
: only taxonomy links:post
: only post links
Gets all posts, unordered.
type
:
:all
: all posts:post
: posts inside taxonomies:page
: posts at the root level "/"
Gets a single post or taxonomy by slug.
Returns PardallMarkdown.Post
(single post) or PardallMarkdown.Link
(taxonomy and its :children)
Same as get_by_slug/1
but raises PardallMarkdown.Content.NotFoundError
if slug not found.
Gets content trees. The content tree contains nested taxonomies and their nested posts.
Posts are nested inside their innermost taxonomy. Posts are sorted by their outmost taxonomy sorting rules.
slug
:
"/"
: content tree for all content"/taxonomy"
: content tree for the given taxonomy slug. Any level can be provided and the tree will be returned accordingly, example: "/any/nesting/level": taxonomies and posts that start at "/any/nesting/level", including "/any/nesting/level" itself.
Gets the content taxonomy tree, ordered
and nested by Link.level
Rebuild indexes and then notify with a custom callback that the content has been reloaded.
The notification can be used, for example, to perform a Phoenix.Endpoint
broadcast, then a website which implements Phoenix.Channel
or Phoenix.LiveVew
can react accordingly.
The notification callback must be put inside the application configuration key :notify_content_reloaded
.
Example:
config :pardall_markdown, PardallMarkdown.Content,
notify_content_reloaded: &Website.notify/0