mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-30 06:19:00 +01:00
Rename a couple of plugin methods
This commit is contained in:
parent
c64c4fe7cc
commit
4a6665f30c
@ -18,7 +18,7 @@ func init() {
|
||||
register("jekyll-feed", &jekyllFeedPlugin{})
|
||||
}
|
||||
|
||||
func (p *jekyllFeedPlugin) Initialize(s Site) error {
|
||||
func (p *jekyllFeedPlugin) AfterInitSite(s Site) error {
|
||||
p.site = s
|
||||
return nil
|
||||
}
|
||||
@ -33,7 +33,7 @@ func (p *jekyllFeedPlugin) ConfigureTemplateEngine(e *liquid.Engine) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *jekyllFeedPlugin) PostRead(s Site) error {
|
||||
func (p *jekyllFeedPlugin) PostReadSite(s Site) error {
|
||||
path := "/feed.xml"
|
||||
if cfg, ok := s.Config().Map("feed"); ok {
|
||||
if pp, ok := cfg["path"].(string); ok {
|
||||
|
@ -18,7 +18,7 @@ func (p *paginatePlugin) ModifyRenderContext(s Site, m map[string]interface{}) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *paginatePlugin) PostRead(s Site) error {
|
||||
func (p *paginatePlugin) PostReadSite(s Site) error {
|
||||
// s.AddDocument(newTemplateDoc(s, "/sitemap.xml", sitemapTemplateSource), true)
|
||||
// s.AddDocument(newTemplateDoc(s, "/robots.txt", `Sitemap: {{ "sitemap.xml" | absolute_url }}`), true)
|
||||
// iterate over pagesets
|
||||
|
@ -20,12 +20,12 @@ import (
|
||||
|
||||
// Plugin describes the hooks that a plugin can override.
|
||||
type Plugin interface {
|
||||
Initialize(Site) error
|
||||
AfterInitSite(Site) error
|
||||
ConfigureTemplateEngine(*liquid.Engine) error
|
||||
ModifyPluginList([]string) []string
|
||||
ModifySiteDrop(Site, map[string]interface{}) error
|
||||
PostInitPage(Site, Page) error
|
||||
PostRead(Site) error
|
||||
PostReadSite(Site) error
|
||||
PostRender([]byte) ([]byte, error)
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ func Lookup(name string) (Plugin, bool) {
|
||||
func Install(names []string, site Site) error {
|
||||
for _, name := range names {
|
||||
if p, found := directory[name]; found {
|
||||
if err := p.Initialize(site); err != nil {
|
||||
if err := p.AfterInitSite(site); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -81,12 +81,12 @@ func Names() []string {
|
||||
// This is internal until better baked.
|
||||
type plugin struct{}
|
||||
|
||||
func (p plugin) Initialize(Site) error { return nil }
|
||||
func (p plugin) AfterInitSite(Site) error { return nil }
|
||||
func (p plugin) ConfigureTemplateEngine(*liquid.Engine) error { return nil }
|
||||
func (p plugin) ModifyPluginList(names []string) []string { return names }
|
||||
func (p plugin) ModifySiteDrop(Site, map[string]interface{}) error { return nil }
|
||||
func (p plugin) PostInitPage(Site, Page) error { return nil }
|
||||
func (p plugin) PostRead(Site) error { return nil }
|
||||
func (p plugin) PostReadSite(Site) error { return nil }
|
||||
func (p plugin) PostRender(b []byte) ([]byte, error) { return b, nil }
|
||||
|
||||
var directory = map[string]Plugin{}
|
||||
@ -147,7 +147,7 @@ var requireFrontMatterExclude = []string{
|
||||
"PULL_REQUEST_TEMPLATE",
|
||||
}
|
||||
|
||||
func (p jekyllOptionalFrontMatterPlugin) Initialize(s Site) error {
|
||||
func (p jekyllOptionalFrontMatterPlugin) AfterInitSite(s Site) error {
|
||||
m := map[string]bool{}
|
||||
for _, k := range requireFrontMatterExclude {
|
||||
m[k] = true
|
||||
|
@ -22,7 +22,7 @@ func init() {
|
||||
redirectTemplate = tmpl
|
||||
}
|
||||
|
||||
func (p jekyllRedirectFromPlugin) PostRead(site Site) error {
|
||||
func (p jekyllRedirectFromPlugin) PostReadSite(site Site) error {
|
||||
ps := site.Pages()
|
||||
newPages, err := p.processRedirectFrom(site, ps)
|
||||
if err != nil {
|
||||
|
@ -23,7 +23,7 @@ func init() {
|
||||
register("jekyll-seo-tag", &jekyllSEOTagPlugin{})
|
||||
}
|
||||
|
||||
func (p *jekyllSEOTagPlugin) Initialize(s Site) error {
|
||||
func (p *jekyllSEOTagPlugin) AfterInitSite(s Site) error {
|
||||
p.site = s
|
||||
return nil
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ func init() {
|
||||
register("jekyll-sitemap", &sitemapPlugin{})
|
||||
}
|
||||
|
||||
func (p *sitemapPlugin) PostRead(s Site) error {
|
||||
func (p *sitemapPlugin) PostReadSite(s Site) error {
|
||||
s.AddDocument(newTemplateDoc(s, "/sitemap.xml", sitemapTemplateSource), true)
|
||||
s.AddDocument(newTemplateDoc(s, "/robots.txt", `Sitemap: {{ "sitemap.xml" | absolute_url }}`), true)
|
||||
return nil
|
||||
|
@ -55,7 +55,7 @@ func (s *Site) Read() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return s.runHooks(func(p plugins.Plugin) error { return p.PostRead(s) })
|
||||
return s.runHooks(func(p plugins.Plugin) error { return p.PostReadSite(s) })
|
||||
}
|
||||
|
||||
// readFiles scans the source directory and creates pages and collection.
|
||||
|
Loading…
Reference in New Issue
Block a user