~srivathsan/blaze

57222ad9dc28f8abc38d5ce6c9cf2bdd7c5f2543 — Srivathsan Murali 3 years ago a473711
Get extention from template or source
1 files changed, 9 insertions(+), 3 deletions(-)

M builder/page.go
M builder/page.go => builder/page.go +9 -3
@@ 20,8 20,8 @@ type Page struct {
	Date       time.Time `yaml:"date"`
	Draft      bool      `yaml:"draft"`
	ListsPath  string    `yaml:"lists-path"`
	Extension  string    `yaml:"extension"`
	Content    string    `fm:"content"`
	Extension  string
	Url        string
	HTML       []byte
	sourcePath string


@@ 60,7 60,6 @@ func ParsePage(relativePath string, config *config.BlazeConfig) (*Page, error) {
	log.Println("Parsing path:", relativePath)
	page := &Page{
		sourcePath: filepath.Join(config.ContentDir(), relativePath),
		Extension:  ".html",
		Site:       config,
		Draft:      false,
	}


@@ 74,9 73,16 @@ func ParsePage(relativePath string, config *config.BlazeConfig) (*Page, error) {
	if err != nil {
		return nil, err
	}
	page.Template = fmt.Sprintf("%s%s", page.Template, page.Extension)

	if page.Template != "" {
		page.Extension = filepath.Ext(page.Template)
	} else {
		page.Extension = filepath.Ext(page.sourcePath)
	}

	url := fmt.Sprintf("/%s", changeExtension(relativePath, page.Extension))
	page.outputPath = filepath.Join(config.OutputDir(), url)

	if filepath.Base(url) == "index.html" {
		url = filepath.Dir(url)
	}