PhoenixKitWeb.Live.Modules.Blogging.Metadata (phoenix_kit v1.5.1)

View Source

Metadata helpers for .phk (PhoenixKit) blogging posts.

Metadata is stored as a simple key-value format at the top of the file:

---
slug: home
title: Welcome
status: published
published_at: 2025-10-29T18:48:00Z
---

Content goes here...

Summary

Functions

Returns default metadata for a new post.

Parses .phk content, extracting metadata from frontmatter and returning the content.

Serializes metadata as YAML-style frontmatter.

Types

metadata()

@type metadata() :: %{
  status: String.t(),
  title: String.t(),
  description: String.t() | nil,
  slug: String.t(),
  published_at: String.t(),
  created_at: String.t() | nil,
  created_by_id: String.t() | nil,
  created_by_email: String.t() | nil,
  updated_by_id: String.t() | nil,
  updated_by_email: String.t() | nil
}

Functions

default_metadata()

@spec default_metadata() :: metadata()

Returns default metadata for a new post.

parse_with_content(content)

@spec parse_with_content(String.t()) ::
  {:ok, metadata(), String.t()} | {:error, atom()}

Parses .phk content, extracting metadata from frontmatter and returning the content.

serialize(metadata)

@spec serialize(metadata()) :: String.t()

Serializes metadata as YAML-style frontmatter.