func (t *thumbnail) Process(ctx goldsmith.Context, f goldsmith.File) error { defer ctx.DispatchFile(f) thumbPath, create := t.thumbName(f.Path()) if !create { return nil } var ( fn goldsmith.File err error ) if cached(ctx, f.Path(), thumbPath) { thumbPathDst := filepath.Join(ctx.DstDir(), thumbPath) fn, err = goldsmith.NewFileFromAsset(thumbPath, thumbPathDst) if err != nil { return err } } else { var err error fn, err = t.thumbnail(f, thumbPath) if err != nil { return err } } ctx.DispatchFile(fn) return nil }
func (i *include) Initialize(ctx goldsmith.Context) error { var paths []string err := filepath.Walk(i.src, func(path string, info os.FileInfo, err error) error { if err == nil && !info.IsDir() { paths = append(paths, path) } return err }) if err != nil { return err } for _, path := range paths { srcRelPath, err := filepath.Rel(i.src, path) if err != nil { panic(err) } dstRelPath := filepath.Join(i.dst, srcRelPath) f, err := goldsmith.NewFileFromAsset(dstRelPath, path) if err != nil { return err } ctx.DispatchFile(f) } return nil }