diff --git a/posts.go b/posts.go index af4a215..11c241b 100644 --- a/posts.go +++ b/posts.go @@ -186,7 +186,7 @@ func getPosts(context context.Context, config *postsRequestConfig) (posts []*Pos defaultSelection := "select p.path, coalesce(content, ''), coalesce(published, ''), coalesce(updated, ''), coalesce(parameter, ''), coalesce(value, '') " postsTable := "posts" if config.taxonomy != nil && len(config.taxonomyValue) > 0 { - postsTable = "(select distinct p.* from " + postsTable + " p left outer join post_parameters pp on p.path = pp.path where pp.parameter = '" + config.taxonomy.Name + "' and pp.value = '" + config.taxonomyValue + "')" + postsTable = "(select distinct p.* from " + postsTable + " p left outer join post_parameters pp on p.path = pp.path where pp.parameter = '" + config.taxonomy.Name + "' and lower(pp.value) = lower('" + config.taxonomyValue + "'))" } if len(config.sections) > 0 { postsTable = "(select * from " + postsTable + " where" @@ -199,7 +199,7 @@ func getPosts(context context.Context, config *postsRequestConfig) (posts []*Pos postsTable += ")" } defaultTables := " from " + postsTable + " p left outer join post_parameters pp on p.path = pp.path " - defaultSorting := " order by coalesce(p.updated, p.published) desc " + defaultSorting := " order by p.published desc " if config.path != "" { query := defaultSelection + defaultTables + " where p.path=?" + defaultSorting rows, err = appDb.QueryContext(context, query, config.path) diff --git a/render.go b/render.go index 3e9b513..2ab7f22 100644 --- a/render.go +++ b/render.go @@ -70,6 +70,7 @@ func initRendering() { return template.HTML(buf.String()), err }, "urlize": urlize, + "sort": sortedStrings, } templates = make(map[string]*template.Template) diff --git a/templates/summary.gohtml b/templates/summary.gohtml index 7880bd6..466fb22 100644 --- a/templates/summary.gohtml +++ b/templates/summary.gohtml @@ -1,6 +1,7 @@ {{ define "summary" }}
{{ with p . "title" }}

{{ . }}

{{ end }} + {{ with .Published }}

{{ dateformat . "02. Jan 2006" }}

{{ end }}

{{ summary . }}

View
diff --git a/templates/taxonomy.gohtml b/templates/taxonomy.gohtml index a9023d1..ea5d1eb 100644 --- a/templates/taxonomy.gohtml +++ b/templates/taxonomy.gohtml @@ -8,7 +8,7 @@ {{ with .Taxonomy.Description }}{{ md . }}{{ end }} diff --git a/utils.go b/utils.go index cd81805..7f54f73 100644 --- a/utils.go +++ b/utils.go @@ -1,6 +1,7 @@ package main import ( + "sort" "strings" ) @@ -38,3 +39,10 @@ func firstSentences(value string, count int) string { } return value } + +func sortedStrings(s []string) []string { + sort.Slice(s, func(i, j int) bool { + return strings.ToLower(s[i]) < strings.ToLower(s[j]) + }) + return s +}