~srivathsan/blaze

87c140663df625c9d809e6cf00e51a114bdf980b — Srivathsan Murali 3 years ago 10d9fdb master
don't hardcode index page url
2 files changed, 3 insertions(+), 13 deletions(-)

M builder/page.go
M builder/templates.go
M builder/page.go => builder/page.go +3 -7
@@ 60,18 60,14 @@ func ParsePage(relativePath string, config *config.BlazeConfig) (*Page, error) {
		page.Extension = filepath.Ext(page.sourcePath)
	}

	url := fmt.Sprintf("/%s", changeExtension(relativePath, page.Extension))
	page.Url = fmt.Sprintf("/%s", changeExtension(relativePath, page.Extension))
	if page.UrlFormat != "" {
		url, err = ParseUrlFormat(page)
		page.Url, err = ParseUrlFormat(page)
		if err != nil {
			return nil, err
		}
	}
	page.outputPath = filepath.Join(config.OutputDir(), url)
	if filepath.Base(url) == "index.html" {
		url = filepath.Dir(url)
	}
	page.Url = url
	page.outputPath = filepath.Join(config.OutputDir(), page.Url)
	page.Content, err = ParseTemplateString(page.Site, page.Content, page)
	if err != nil {
		return nil, err

M builder/templates.go => builder/templates.go +0 -6
@@ 36,12 36,6 @@ func listPages(path string, config *config.BlazeConfig) []*Page {

func getTemplateFuncs(config *config.BlazeConfig) template.FuncMap {
	return template.FuncMap{
		"isRoot": func(url string) bool {
			return url == "/"
		},
		"isNotRoot": func(url string) bool {
			return url != "/"
		},
		"basePath": func(urlPath string) string {
			return filepath.Base(urlPath)
		},