mix elementorex.gen.cms (ElementorexCms v0.1.0)

Copy Markdown View Source

Generates everything to manage pages built with the visual editor: migration, schema, context, an admin list, the editor page and the public page.

$ mix elementorex.gen.cms Pages Page pages

The three arguments are the context, the schema and the table, like mix phx.gen.live. It creates:

  • priv/repo/migrations/*_create_pages.exs - title, unique slug, body (the document, jsonb), status and published_at
  • lib/my_app/pages/page.ex and lib/my_app/pages.ex
  • lib/my_app_web/live/page_live/index.ex (+ .html.heex) - list and creation, for your admin
  • lib/my_app_web/live/page_live/editor.ex (+ .html.heex) - the editor, with save and publish
  • lib/my_app_web/live/page_live/show.ex (+ .html.heex) - the public page at /p/:slug (only published pages)

Then add the routes it prints (the admin ones inside your authenticated admin live_session) and run the migration.

Options

  • --binary-id - use UUID primary keys (default: your app's :generators config)
  • --public-path - public prefix (default /p)
  • --admin-path - admin prefix (default /admin/<table>)
  • --force - overwrite existing files