Archivist v0.3.1 Archivist.Archive View Source
The heart of Archivist is the Archive
module, which acts as a repository for
exposing query functions for articles, slugs, topics, etc. You can create an
Archive out of any Elixir module by using Archivist.Archive
like this:
defmodule MyApp.Archive
use Archivist.Archive
end
# this alias is just a nicety, not required
alias MyApp.Archive
Archive.articles()
Archive.topics() # hierarchical topics
Archive.topics_list() # flattened topics and sub-topics
Archive.tags()
Archive.slugs()
Archive.authors()
Additionally Archvist exposes helpers for reading paths for articles and image files:
Archive.article_paths()
Archive.image_paths()
Archivist 0.2.x versions expect you to create your article content directory at
priv/archive/articles
at the root of your elixir library, like this:
priv/archive/articles/journey_to_the_center_of_the_earth.ad
If you'd like to customize any of your archive's behavior, you can define any of the following options when it is used in the target archive directory. The values shown are the defaults:
defmodule MyApp.Archive
use Archivist.Archive
archive_dir: "priv/archive",
content_dir: "articles",
content_pattern: "**/*.ad",
image_dir: "images",
image_pattern: "**/*.{jpg,gif,png}",
article_parser: &Arcdown.parse_file(&1),
article_sorter: &(Map.get(&1, :published_at) >= Map.get(&2, :published_at)),
slug_warnings: true,
application: nil,
valid_tags: nil,
valid_topics: nil,
valid_authors: nil,
end
Archivist will read any files with the .ad
extension in your content directory
or in any of its subdirectories, and parse the content of those files with the
parser you've selected (Arcdown by default)
If you'd like to store your archive somewhere besides priv/archive
you can
assign a custom path to your archive like this:
defmodule MyApp.Archive
use Archivist.Archive, archive_dir: "assets/archive",
end