Brix.Store behaviour (Brix v0.1.1)

Copy Markdown View Source

Behaviour for Brix content store backends.

Implement all callbacks to provide a content store. See Brix.Store.Filesystem for the built-in flat-file implementation.

Summary

Callbacks

Looks up a redirect target for a legacy slug. Returns the new slug or :error.

Fetches an author by slug.

Fetches a collection by slug.

Fetches a layout by name.

Fetches a media asset by slug.

Fetches a page by slug.

Fetches a section template by name.

Fetches a shared section by name.

Returns the site configuration.

Fetches a tag by slug.

Lists all authors.

Lists child collections whose parent matches the given slug.

Lists pages belonging to a collection, applying its filters and sort order.

Lists all collections.

Lists all media assets.

Lists pages.

Lists all section templates.

Lists all shared sections.

Lists all tags.

Reloads all content from the filesystem (or other backing store).

Callbacks

find_redirect(old_slug)

@callback find_redirect(old_slug :: String.t()) :: {:ok, String.t()} | :error

Looks up a redirect target for a legacy slug. Returns the new slug or :error.

get_author(slug)

@callback get_author(slug :: String.t()) :: {:ok, Brix.Author.t()} | :error

Fetches an author by slug.

get_collection(slug)

@callback get_collection(slug :: String.t()) :: {:ok, Brix.Collection.t()} | :error

Fetches a collection by slug.

get_layout(name)

@callback get_layout(name :: String.t()) :: {:ok, Brix.Layout.t()} | :error

Fetches a layout by name.

get_media(slug)

@callback get_media(slug :: String.t()) :: {:ok, Brix.Media.t()} | :error

Fetches a media asset by slug.

get_page(slug, opts)

@callback get_page(slug :: String.t(), opts :: keyword()) :: {:ok, Brix.Page.t()} | :error

Fetches a page by slug.

Options

  • :status — filter by publish status: :published, :draft, or :all (default :published)
  • :prefix — match pages whose slug starts with the given prefix

get_section_template(name)

@callback get_section_template(name :: String.t()) ::
  {:ok, Brix.SectionTemplate.t()} | :error

Fetches a section template by name.

get_shared_section(name)

@callback get_shared_section(name :: String.t()) :: {:ok, Brix.SharedSection.t()} | :error

Fetches a shared section by name.

get_site()

@callback get_site() :: Brix.Site.t()

Returns the site configuration.

get_tag(slug)

@callback get_tag(slug :: String.t()) :: {:ok, Brix.Tag.t()} | :error

Fetches a tag by slug.

list_authors()

@callback list_authors() :: [Brix.Author.t()]

Lists all authors.

list_child_collections(parent_slug)

@callback list_child_collections(parent_slug :: String.t()) :: [Brix.Collection.t()]

Lists child collections whose parent matches the given slug.

list_collection_pages(collection, opts)

@callback list_collection_pages(collection :: Brix.Collection.t(), opts :: keyword()) :: [
  Brix.Page.t()
]

Lists pages belonging to a collection, applying its filters and sort order.

Options

  • :status — filter by publish status: :published, :draft, or :all (default :published)

list_collections()

@callback list_collections() :: [Brix.Collection.t()]

Lists all collections.

list_media()

@callback list_media() :: [Brix.Media.t()]

Lists all media assets.

list_pages(opts)

@callback list_pages(opts :: keyword()) :: [Brix.Page.t()]

Lists pages.

Options

  • :status — filter by publish status: :published, :draft, or :all (default :published)
  • :prefix — match pages whose slug starts with the given prefix

list_section_templates()

@callback list_section_templates() :: [Brix.SectionTemplate.t()]

Lists all section templates.

list_shared_sections()

@callback list_shared_sections() :: [Brix.SharedSection.t()]

Lists all shared sections.

list_tags()

@callback list_tags() :: [Brix.Tag.t()]

Lists all tags.

reload()

@callback reload() :: :ok | {:error, term()}

Reloads all content from the filesystem (or other backing store).