mirror of
https://github.com/gohugoio/hugo.git
synced 2024-07-05 08:42:12 +00:00
Adding support for linkTitles
This commit is contained in:
parent
b580a25d1f
commit
9388f23606
|
@ -15,6 +15,8 @@ are available in the context for the templates.
|
||||||
**.Date** The date the content is published on.<br>
|
**.Date** The date the content is published on.<br>
|
||||||
**.Indexes** These will use the field name of the plural form of the index (see tags and categories above)<br>
|
**.Indexes** These will use the field name of the plural form of the index (see tags and categories above)<br>
|
||||||
**.Permalink** The Permanent link for this page.<br>
|
**.Permalink** The Permanent link for this page.<br>
|
||||||
|
**.RelPermalink** The Relative permanent link for this page.<br>
|
||||||
|
**.LinkTitle** Access when creating links to this content. Will use linktitle if set in front-matter, else title<br>
|
||||||
**.FuzzyWordCount** The approximate number of words in the content.<br>
|
**.FuzzyWordCount** The approximate number of words in the content.<br>
|
||||||
**.RSSLink** Link to the indexes' rss link <br>
|
**.RSSLink** Link to the indexes' rss link <br>
|
||||||
**.Prev** Pointer to the previous content (based on pub date)<br>
|
**.Prev** Pointer to the previous content (based on pub date)<br>
|
||||||
|
@ -46,7 +48,7 @@ includes indexes, lists and the homepage.
|
||||||
Also available is `.Site` which has the following:
|
Also available is `.Site` which has the following:
|
||||||
|
|
||||||
**.Site.BaseUrl** The base URL for the site as defined in the config.json file.<br>
|
**.Site.BaseUrl** The base URL for the site as defined in the config.json file.<br>
|
||||||
**.Site.Indexes** The names of the indexes of the site.<br>
|
**.Site.Indexes** The indexes for the entire site.<br>
|
||||||
**.Site.LastChange** The date of the last change of the most recent content.<br>
|
**.Site.LastChange** The date of the last change of the most recent content.<br>
|
||||||
**.Site.Recent** Array of all content ordered by Date, newest first<br>
|
**.Site.Recent** Array of all content ordered by Date, newest first<br>
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ type Page struct {
|
||||||
Markup string
|
Markup string
|
||||||
renderable bool
|
renderable bool
|
||||||
layout string
|
layout string
|
||||||
|
linkTitle string
|
||||||
PageMeta
|
PageMeta
|
||||||
File
|
File
|
||||||
Position
|
Position
|
||||||
|
@ -276,6 +277,14 @@ func (p *Page) permalink() (*url.URL, error) {
|
||||||
return MakePermalink(base, path), nil
|
return MakePermalink(base, path), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Page) LinkTitle() string {
|
||||||
|
if len(p.linkTitle) > 0 {
|
||||||
|
return p.linkTitle
|
||||||
|
} else {
|
||||||
|
return p.Title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Page) Permalink() (string, error) {
|
func (p *Page) Permalink() (string, error) {
|
||||||
link, err := p.permalink()
|
link, err := p.permalink()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -334,6 +343,8 @@ func (page *Page) update(f interface{}) error {
|
||||||
switch loki {
|
switch loki {
|
||||||
case "title":
|
case "title":
|
||||||
page.Title = interfaceToString(v)
|
page.Title = interfaceToString(v)
|
||||||
|
case "linktitle":
|
||||||
|
page.linkTitle = interfaceToString(v)
|
||||||
case "description":
|
case "description":
|
||||||
page.Description = interfaceToString(v)
|
page.Description = interfaceToString(v)
|
||||||
case "slug":
|
case "slug":
|
||||||
|
|
Loading…
Reference in a new issue