new Plugin api after
option
#1240
Mister-Hope
started this conversation in
Ideas
Replies: 3 comments 7 replies
-
Any feedback with this api proposal? @meteorlxy |
Beta Was this translation helpful? Give feedback.
0 replies
-
Maybe there could also be a |
Beta Was this translation helpful? Give feedback.
6 replies
-
实际运行似乎先加载的主题插件,而且源码中也是这样的: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since plugins may access other plugins data, for example,
plugin-git
generate createTIme, updateTime and contributors, and these can be used in:So related plugins may would like to have
plugin-git
being called first.However, the squence caliing plugin can be problematic.
E.g.: For default theme. git plugin is called inside theme, and if users choose to call blogPlugin manually. blogPlugin will execlute first in every lifecycle, so it will fail to read git information. Another case can be
vuepress-theme-hope
, where the both plugins are built-in.So to let everything work well, as long as users are calling any plugin, he shall call all plugins which the plugin is related to first manually. I.E., for the case above, users must call gitPlugin manually before blogPlugin to let the second one read git information.
New API
after
markdown-it plugins gives me insperations. If a plugin requires it running after another one, we can introduce a
after
field for it to declare:e.g.: for blog plugin, it may add
after: ['@vuepress/plugin-git']
, and for feed plugin, it may addafter: ['@vuepress/plugin-git', 'vuepress-plugin-seo2']
For our side, we shall read
after
option and sort the final plugins array according to it, so that every plugin can read other plugin data if needed.User/theme plugin priority and plugin can not call plugins behavior can be all remain unchanged. This is a greate way to provide "Soft require support" between plugins.
@meteorlxy
Beta Was this translation helpful? Give feedback.
All reactions