blinkk / amagaki

A high-performance TypeScript static website generator for building highly-interactive websites. Localization inbuilt. Flexible URLs. Content managed and templates separated.
https://amagaki.dev
MIT License
36 stars 2 forks source link

fix!: Change `afterRender` hook to be a sync trigger. #214

Closed Zoramite closed 1 year ago

Zoramite commented 1 year ago

Updates the afterRender hook to not be async since it needs to use the results of the previous plugin to make the next set of changes.

jeremydw commented 1 year ago

Think it's safe to make this change? Is it needed with the submission of https://github.com/blinkk/amagaki/commit/85db1a54d7fd9d094083afc9640303ab409c8070

Zoramite commented 1 year ago

It is needed because the logic for the afterRender hook is that you can change the contents after the render, this should have been sync because you want to be able to chain plugins together to have them modify things after the previous plugin is done changing it.

For example, if you have one plugin that prettifies the html and another that replaces all occurances of foo with bar, if they are done async you technically might run one before the other in an inconsistent manner or overwrite the changes that the other plugin performed.