Skip to content

Repository files navigation

PhoenixKitPosts

Hex.pm

Social posts module for PhoenixKit — user-generated posts with threaded comments, likes/dislikes, tags, Pinterest-style boards, media galleries, @mentions, view tracking, and scheduled publishing.

Not a blog/CMS. For long-form articles — Markdown/.phk content, slugged pages, versioned and multilingual publishing — use PhoenixKit's built-in Publishing module. PhoenixKitPosts is for social, feed-style posting: posts, likes, boards, mentions, and threaded comments.

Requirements

  • Elixir ~> 1.18
  • PhoenixKit ~> 1.7 (host application)
  • Phoenix LiveView ~> 1.1

Installation

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

{:phoenix_kit_posts,"~> 0.2"}

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

Features

  • Post management — Create, update, delete, publish posts with draft/public/unlisted/scheduled status
  • Threaded comments — Nested comments with unlimited depth, plus like/dislike tracking per comment
  • Like and dislike system — One-per-user enforcement with denormalized counter caches
  • Tag system — Hashtag parsing and auto-slugification
  • Group collections — Pinterest-style boards for organizing posts with ordering
  • Media attachments — Multiple files per post with position-based ordering and featured image support
  • User mentions — Track @mentions within posts
  • View tracking — Track post views with denormalized counters
  • Scheduled publishing — Automatic publishing at a specified time via Oban workers
  • Admin UI — LiveView-based admin pages for posts, groups, and settings

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 postPhoenixKitPosts.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 mediaPhoenixKitPosts.attach_media(post.uuid,file_uuid,position: 1)# Mention a userPhoenixKitPosts.add_mention_to_post(post.uuid,mentioned_user_uuid)# Query postsposts=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.

Links

About

Posts Module for PhoenixKit. User generated content - create, update, delete, publish posts.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages