-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Currently, if I use WP plugin, it completely replaces implementation from core controller. It is also not possible to combine it with theme controller.
The current code: https://github.com/datopian/frontend-v2/blob/master/plugins/wp/index.js#L14-L32
Desired flow:
Plugin --> Theme --> Core
so that devs can implement any solution in their theme.
Acceptance criteria
- WP plugin doesn't override home route but adds posts into response variables (
res.locals) so that it can be used in the views - WP plugin controller is called before theme controller
Tasks
- Analysis
- TODO
Analysis
Right now the execution flow of the controller is Theme--> Plugin --> Core. We can add the middleware route controller for WP task on wp plugin and pass the variable using res.locals in between the controller on this flow Plugin --> Theme --> Core
-
Insertion of the wp middleware on the home route
next():
https://github.com/datopian/frontend-v2/blob/master/plugins/wp/index.js#L14-L31
add variableres.locals.post= posts -
Rearrange the execution flow by rearranging the extension load.
https://github.com/datopian/frontend-v2/blob/master/utils/index.js#L246-L282 -
Get data from res.locals and pass to the template
https://github.com/datopian/frontend-v2/blob/master/routes/dms.js#L36-42