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

docs: improve documentation on hooks and inflections #792

Open
jclusso opened this issue Aug 8, 2023 · 2 comments
Open

docs: improve documentation on hooks and inflections #792

jclusso opened this issue Aug 8, 2023 · 2 comments
Assignees
Milestone

Comments

@jclusso
Copy link
Contributor

jclusso commented Aug 8, 2023

For the life of me, I can't figure out where usage of hooks go when working with them directly. A proper example would be greatly helpful here. If they belong in the initializer or a config. I figured it would be nice to have a hooks.rb file in the config folder, but I was unsuccessful in getting that to work.

# or using the hooks API directly:
Bridgetown::Hooks.register_one :posts, :post_render do |post|
# code to call after Bridgetown renders a post
end
```

This also leads me to having no idea how to get inflections to work. I think a full example showing where and what hook it should use would be great.

The "inflector" loaded in from Rails' ActiveSupport is used to convert between singular and plural collection names automatically. If you need to customize the inflector with words it doesn't specifically recognize, create a plugin and add your own:
```ruby
ActiveSuport::Inflector.inflections(:en) do |inflect|
inflect.plural /^(ox)$/i, '\1\2en'
inflect.singular /^(ox)en/i, '\1'
end
```

@jclusso
Copy link
Contributor Author

jclusso commented Aug 9, 2023

The second part of this can be ignored once #793 is merged.

@jclusso jclusso changed the title Improve documentation on hooks and inflections docs: improve documentation on hooks and inflections Aug 9, 2023
@jaredcwhite
Copy link
Member

@jclusso Thanks for calling this out. Part of the issue I think is I really dislike that hooks API, as it's a holdover from Jekyll days, and I've been trying to move away from it in various ways. I'm realizing now there's not adequate documentation on how to use hook in initializer files, which is the new preferred way to define hooks going forward outside of a Builder. It needs updating here: https://www.bridgetownrb.com/docs/configuration/initializers

@jaredcwhite jaredcwhite self-assigned this Nov 2, 2023
@jaredcwhite jaredcwhite added this to the 1.4 milestone Nov 2, 2023
@jaredcwhite jaredcwhite modified the milestones: 1.4, 2.0 Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants