Site & Pages
Get the site configuration
Site
site = Brix.get_site()
site.name #=> "My Site"
site.domain #=> "example.com"
site.tagline #=> "A brief tagline"Get a page by slug
{:ok, page} = Brix.get_page("/blog/hello")
# Include drafts
{:ok, draft} = Brix.get_page("/wip", status: :draft)
# Any status
{:ok, page} = Brix.get_page("/wip", status: :all)List pages with filters
# All published pages (default)
Brix.list_pages()
# Filter by tag
Brix.list_pages(tag: "coffee")
# Filter by author
Brix.list_pages(author: "maya")
# Filter by slug prefix
Brix.list_pages(prefix: "/blog/")
# Combine filters
Brix.list_pages(
tag: "coffee",
author: "maya",
prefix: "/blog/",
status: :published
)Page helpers
Brix.Page.published?(page) #=> true | false
# Case-insensitive search across title,
# meta_description, and section fields
Brix.Page.matches?(page, "elixir") #=> true | false
# Plain-text excerpt (default 200 chars)
Brix.Page.excerpt(page) #=> "First 200 chars..."
Brix.Page.excerpt(page, 100) #=> "First 100 chars..."Layouts, Authors, Tags, Media
Core resource lookups
Layouts
{:ok, layout} = Brix.get_layout("default")
layout.name #=> "default"
layout.header_sections #=> [%Section{}, ...]
layout.footer_sections #=> [%Section{}, ...]Authors
{:ok, author} = Brix.get_author("maya")
author.name #=> "Maya"
author.bio #=> "Author biography"
author.avatar #=> "maya-avatar"
Brix.list_authors() #=> [%Author{}, ...]Tags
{:ok, tag} = Brix.get_tag("coffee")
tag.display_name #=> "Coffee"
Brix.list_tags() #=> [%Tag{}, ...]Media
{:ok, media} = Brix.get_media("hero-image")
media.path #=> "files/hero.jpg"
media.alt #=> "Hero image"
media.content_type #=> "image/jpeg"
Brix.list_media() #=> [%Media{}, ...]Collections & Shared Sections
Groupings and reusable content
Collections
{:ok, collection} = Brix.get_collection("blog")
collection.name #=> "Blog"
collection.filters #=> %{prefix: "/blog/"}
collection.sort_by #=> "published_at"
# List pages matching collection filters
pages = Brix.list_collection_pages(collection)
Brix.list_collections() #=> [%Collection{}, ...]Shared sections
{:ok, section} = Brix.get_shared_section("main-nav")
section.template #=> "nav"
section.fields #=> %{"links" => [...]}
Brix.list_shared_sections() #=> [%SharedSection{}, ...]Section templates
{:ok, tmpl} = Brix.get_section_template("hero")
tmpl.fields
#=> %{"heading" => %{type: :string, required: true},
# "image" => %{type: :media}}
Brix.list_section_templates() #=> [%SectionTemplate{}, ...]SEO Metadata
Resolved metadata via Brix.Meta.field/3
Field resolution
site = Brix.get_site()
{:ok, page} = Brix.get_page("/blog/hello")
# Each field falls back page -> site
Brix.Meta.field(page, site, :title)
Brix.Meta.field(page, site, :description)
Brix.Meta.field(page, site, :og_title)
Brix.Meta.field(page, site, :og_description)
Brix.Meta.field(page, site, :og_image)Fallback chain
:title => page.meta_title || page.title
|| site.meta_title || site.name
:description => page.meta_description
|| site.meta_description
:og_title => page.og_title
|| field(page, site, :title)
:og_description => page.og_description
|| field(page, site, :description)
:og_image => page.og_image || site.og_imageWorks with collections too
{:ok, collection} = Brix.get_collection("blog")
Brix.Meta.field(collection, site, :title)
Brix.Meta.field(collection, site, :og_image)Reload
Refresh content from disk
Reload the store
# Reloads all content from the filesystem
Brix.reload() #=> :ok | {:error, reason}Slug redirects
# Look up old slugs from slug_history
Brix.find_redirect("/old-url") #=> {:ok, "/new-url"}
Brix.find_redirect("/unknown") #=> :error