mirror of https://github.com/jlelse/GoBlog
Use fallback title generated from summary in HTML HEAD title
This commit is contained in:
parent
6a2642f25f
commit
8012691d7a
|
@ -86,12 +86,8 @@ func parseMicroformatsFromReader(u string, r io.Reader) (*microformatsResult, er
|
|||
m.Title = ""
|
||||
}
|
||||
// Shorten content and title if too long
|
||||
if cr := []rune(m.Content); len(cr) > 500 {
|
||||
m.Content = string(cr[0:497]) + "…"
|
||||
}
|
||||
if tr := []rune(m.Title); len(tr) > 60 {
|
||||
m.Title = string(tr[0:57]) + "…"
|
||||
}
|
||||
m.Content = truncateStringWithEllipsis(m.Content, 500)
|
||||
m.Title = truncateStringWithEllipsis(m.Title, 60)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -128,6 +128,10 @@ func (a *goBlog) postSummary(p *post) (summary string) {
|
|||
return
|
||||
}
|
||||
|
||||
func (a *goBlog) fallbackTitle(p *post) string {
|
||||
return truncateStringWithEllipsis(a.postSummary(p), 30)
|
||||
}
|
||||
|
||||
func (a *goBlog) postTranslations(p *post) []*post {
|
||||
translationkey := p.firstParameter("translationkey")
|
||||
if translationkey == "" {
|
||||
|
|
6
ui.go
6
ui.go
|
@ -887,7 +887,11 @@ func (a *goBlog) renderPost(hb *htmlbuilder.HtmlBuilder, rd *renderData) {
|
|||
a.renderBase(
|
||||
hb, rd,
|
||||
func(hb *htmlbuilder.HtmlBuilder) {
|
||||
a.renderTitleTag(hb, rd.Blog, p.RenderedTitle)
|
||||
if p.RenderedTitle != "" {
|
||||
a.renderTitleTag(hb, rd.Blog, p.RenderedTitle)
|
||||
} else {
|
||||
a.renderTitleTag(hb, rd.Blog, a.fallbackTitle(p))
|
||||
}
|
||||
hb.WriteElementOpen("link", "rel", "stylesheet", "href", a.assetFileName("css/chroma.css"))
|
||||
a.renderPostHeadMeta(hb, p)
|
||||
if su := a.shortPostURL(p); su != "" {
|
||||
|
|
Loading…
Reference in New Issue