saberland/saber
Allow plugin to modify siteConfig and themeConfig
Aberta
#508 aberto em 8 de out. de 2019
contribution welcomehacktoberfesttype: feature
Métricas do repositório
- Stars
- (2.151 estrelas)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
Feature request
What problem does this feature solve?
Plugins should be able to set default value for siteConfig, and probably themeConfig.
e.g. You create a plugin to fetch siteConfig from headless CMS, but you also want the user to be able to override siteConfig via saber-config.yml.
What does the proposed API look like?
A plugin:
exports.name = 'my-plugin-name'
exports.apply = api => {
api.hooks.getSaberConfig.tapPromise('my-plugin-name', async config => {
config.siteConfig = merge(await getSiteConfigFromApi(), config.siteConfig)
return config
})
}
How should this be implemented in your opinion?
Call the getSaberConfig hook before calling afterPlugins hook:
And call it again when config file is modified: