# `PhoenixBlog`
[🔗](https://github.com/lalabuy948/phoenix_blog/blob/v0.1.7/lib/phoenix_blog.ex#L1)

Plug-and-play blog engine for Phoenix with Editor.js integration.

## Setup

1. Add `{:phoenix_blog, "~> 0.1"}` to your `mix.exs`
2. Configure: `config :phoenix_blog, repo: MyApp.Repo`
3. Create and run the migration (see `PhoenixBlog.Migration`)
4. Mount routes in your router (see `PhoenixBlog.Web.Router`)

# `change_post`

Returns an `%Ecto.Changeset{}` for tracking post changes.

# `count_posts`

Returns the count of posts matching the given admin filters.

# `count_published_posts`

Returns the count of published posts matching the given filters.

# `create_post`

Creates a post.

# `delete_post`

Deletes a post permanently.

# `get_post!`

Gets a single post by ID.

Raises `Ecto.NoResultsError` if the post does not exist.

# `get_post_by_slug!`

Gets a single published post by slug.

Raises `Ecto.NoResultsError` if the post does not exist.

# `get_post_by_slug_admin`

Gets a single post by slug (admin version, no status/deleted filters).

# `like_count`

Returns the like count for a single post.

# `like_counts_for_posts`

Returns a map of `%{post_id => like_count}` for a list of post IDs.
Efficient batch query for feed pages.

# `liked_by_user?`

Returns true if the user has liked the post.

# `liked_post_ids_for_user`

Returns a MapSet of post IDs that the given user has liked from the provided list.

# `list_latest_published_posts`

Returns the latest N published posts.

# `list_posts`

Returns posts for admin with optional filters and pagination.

## Options

  * `:page` - Page number (default: 1)
  * `:per_page` - Items per page (default: 20)
  * `:status` - Filter by status
  * `:search` - Search by title
  * `:tag` - Filter by tag
  * `:show_deleted` - Include soft-deleted posts (default: false)

# `list_published_posts`

Returns published posts for public display with pagination.

## Options

  * `:page` - Page number (default: 1)
  * `:per_page` - Items per page (default: 12)
  * `:search` - Search by title
  * `:tag` - Filter by tag

# `list_published_tags`

Returns all unique tags from published posts, sorted alphabetically.

# `publish_post`

Publishes a post.

# `restore_post`

Restores a soft-deleted post.

# `soft_delete_post`

Soft deletes a post.

# `toggle_like`

Toggles a like for the given post by the given user.

Returns `{:ok, :liked}` or `{:ok, :unliked}`.
Requires `config :phoenix_blog, likes_enabled: true`.

# `update_post`

Updates a post.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
