feat(blogo,plugins,listplugin): list plugin support
This commit is contained in:
@@ -76,6 +76,13 @@ func New(opts ...Options) Blogo {
|
|||||||
func (b *blogo) Use(p Plugin) {
|
func (b *blogo) Use(p Plugin) {
|
||||||
log := b.log.With(slog.String("plugin", p.Name()))
|
log := b.log.With(slog.String("plugin", p.Name()))
|
||||||
|
|
||||||
|
if p, ok := p.(ListPlugin); ok {
|
||||||
|
log.Debug("Added plugin", slog.String("type", "PluginList"))
|
||||||
|
for _, p := range p.Plugins() {
|
||||||
|
b.Use(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if p, ok := p.(SourcerPlugin); ok {
|
if p, ok := p.(SourcerPlugin); ok {
|
||||||
log.Debug("Added plugin", slog.String("type", "SourcerPlugin"))
|
log.Debug("Added plugin", slog.String("type", "SourcerPlugin"))
|
||||||
b.sources = append(b.sources, p)
|
b.sources = append(b.sources, p)
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ type Plugin interface {
|
|||||||
Name() string
|
Name() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListPlugin interface {
|
||||||
|
Plugin
|
||||||
|
Plugins() []Plugin
|
||||||
|
}
|
||||||
|
|
||||||
type RendererPlugin interface {
|
type RendererPlugin interface {
|
||||||
Plugin
|
Plugin
|
||||||
Render(src fs.File, out io.Writer) error
|
Render(src fs.File, out io.Writer) error
|
||||||
|
|||||||
Reference in New Issue
Block a user