Behaviour for defining content types.
Content types describe how a category of content is organized: which directory it lives in, its URL prefix, default layout, and which front matter fields are required.
Examples
defmodule MyApp.ContentTypes.Recipe do
@behaviour Sayfa.Behaviours.ContentType
@impl true
def name, do: :recipe
@impl true
def directory, do: "recipes"
@impl true
def url_prefix, do: "recipes"
@impl true
def default_layout, do: "page"
@impl true
def required_fields, do: [:title]
end
Summary
Callbacks
Default layout template name (without extension).
Directory name under content/ where files of this type live.
Atom identifier for this content type.
Front matter fields that must be present.
URL path prefix. Empty string for top-level pages.
Callbacks
@callback default_layout() :: String.t()
Default layout template name (without extension).
@callback directory() :: String.t()
Directory name under content/ where files of this type live.
@callback name() :: atom()
Atom identifier for this content type.
@callback required_fields() :: [atom()]
Front matter fields that must be present.
@callback url_prefix() :: String.t()
URL path prefix. Empty string for top-level pages.