PhoenixKitPosts

Hex.pm

Posts module for PhoenixKit — blog posts, comments, tags, groups, likes, media, mentions, view tracking, and scheduled publishing.

Requirements

Installation

Add to your parent PhoenixKit app's mix.exs:

{:phoenix_kit_posts, "~> 0.1.0"}

Run mix deps.get. The module appears in the admin panel automatically via PhoenixKit's auto-discovery — no additional configuration required.

Features

Usage

# Create a post
{:ok, post} = PhoenixKitPosts.create_post(user_uuid, %{
title: "My First Post",
content: "Hello world!",
type: "post",
status: "draft"
})
# Publish a post
{:ok, post} = PhoenixKitPosts.publish_post(post)
# Schedule a post for later
{:ok, post} = PhoenixKitPosts.schedule_post(post, ~U[2026-04-01 12:00:00Z])
# Like a post (one per user, enforced by unique constraint)
{:ok, like} = PhoenixKitPosts.like_post(post.uuid, user_uuid)
# Tag a post
PhoenixKitPosts.add_tags_to_post(post, ["elixir", "phoenix"])
# Create a group and organize posts
{:ok, group} = PhoenixKitPosts.create_group(user_uuid, %{
name: "Travel Photos",
description: "My adventures"
})
PhoenixKitPosts.add_post_to_group(post.uuid, group.uuid)
# Attach media
PhoenixKitPosts.attach_media(post.uuid, file_uuid, position: 1)
# Mention a user
PhoenixKitPosts.add_mention_to_post(post.uuid, mentioned_user_uuid)
# Query posts
posts = PhoenixKitPosts.list_public_posts(page: 1, per_page: 20)
post = PhoenixKitPosts.get_post_by_slug("my-first-post")

Configuration

Settings are managed through the PhoenixKit Settings API and can be configured via the admin UI at /admin/settings/posts.

SettingTypeDefaultDescription
posts_enabledbooleantrueEnable/disable the module
posts_per_pageinteger20Posts per page in admin listing
posts_default_statusstring"draft"Default status for new posts
posts_likes_enabledbooleantrueEnable/disable like system
posts_allow_schedulingbooleantrueAllow scheduled publishing
posts_allow_groupsbooleantrueAllow post groups/boards
posts_allow_repostsbooleantrueAllow reposting
posts_seo_auto_slugbooleantrueAuto-generate URL slugs
posts_show_view_countbooleantrueShow view counts publicly
posts_require_approvalbooleanfalseRequire admin approval
posts_max_mediainteger10Max media attachments per post
posts_max_title_lengthinteger255Max title character length
posts_max_subtitle_lengthinteger500Max subtitle character length
posts_max_content_lengthinteger50000Max content character length
posts_max_mentionsinteger10Max mentions per post
posts_max_tagsinteger20Max tags per post

Documentation

Generate docs locally with:

mix docs

Development

mix deps.get # Install dependencies
mix test # Run tests
mix format # Format code
mix credo --strict # Static analysis
mix dialyzer # Type checking
mix precommit # All of the above

License

MIT — see LICENSE for details.