Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Plugin System #505

Open
leandrocp opened this issue May 23, 2024 · 0 comments
Open

[Proposal] Plugin System #505

leandrocp opened this issue May 23, 2024 · 0 comments
Labels
area:plugin Extend Beacon proposal Idea in research phase

Comments

@leandrocp
Copy link
Contributor

leandrocp commented May 23, 2024

Allow users to pack config, functions, and data to extend Beacon.

Enable plugins in your site config:

plugins: [MyBlogPlugin]

And the plugin implements Beacon.Plugin:

defmodule MyBlogPlugin do
  @behaviour Beacon.Plugin

  @impl true
  def config do
    %Beacon.Config{
      extra_page_fields: [MyBlogPlugin.PageFields.Type]
      # ... and more if needed
    }
  end

  @impl true
  def install(opts) do
    # install script to seed data / bootstrap content like components
    # eg: insert components
  end

  # provide extra functions to be used on sites
  def latest_blog_posts(limit) do
    Beacon.Content.list_published_pages(...)
  end
end

defmodule MyBlogPlugin.PageFields.Type do
  @behaviour Beacon.Content.PageField
  # ... omitted 
end
  • With this approach we can extend Beacon as necessary by adding new callbacks to inject code into different levels of its lifecycle.
  • Config can only be merged, ie: can't remove values.
@leandrocp leandrocp added proposal Idea in research phase area:plugin Extend Beacon labels May 23, 2024
@leandrocp leandrocp changed the title Plugin System [Proposal] Plugin System Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:plugin Extend Beacon proposal Idea in research phase
Projects
None yet
Development

No branches or pull requests

1 participant