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