Welcome to mirror list, hosted at ThFree Co, Russian Federation.

planner.go « hugolib - github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f03bbb0af07bfe02f42b9f2cae52960c3d10981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package hugolib

import (
	"fmt"
	"io"
)

func (s *Site) ShowPlan(out io.Writer) (err error) {
	if s.Source == nil || len(s.Source.Files()) <= 0 {
		fmt.Fprintf(out, "No source files provided.\n")
	}

	for _, p := range s.Pages {
		fmt.Fprintf(out, "%s", p.Source.Path())
		if p.IsRenderable() {
			fmt.Fprintf(out, " (renderer: markdown)")
		} else {
			fmt.Fprintf(out, " (renderer: n/a)")
		}
		if s.Tmpl != nil {
			for _, l := range p.Layout() {
				fmt.Fprintf(out, " (layout: %s, exists: %t)", l, s.Tmpl.Lookup(l) != nil)
			}
		}
		fmt.Fprintf(out, "\n")
		fmt.Fprintf(out, " canonical => ")
		if s.Targets.Page == nil {
			fmt.Fprintf(out, "%s\n\n", "!no target specified!")
			continue
		}

		trns, err := s.PageTarget().Translate(p.TargetPath())
		if err != nil {
			return err
		}
		fmt.Fprintf(out, "%s\n", trns)

		if s.Targets.Alias == nil {
			continue
		}

		for _, alias := range p.Aliases {
			aliasTrans, err := s.AliasTarget().Translate(alias)
			if err != nil {
				return err
			}
			fmt.Fprintf(out, " %s => %s\n", alias, aliasTrans)
		}
		fmt.Fprintln(out)
	}
	return
}