Support twitter card
parent
b9a199180f
commit
8b2647b4f3
@ -0,0 +1,5 @@
|
|||||||
|
## 2017.12.09 Version 1.0
|
||||||
|
|
||||||
|
- [x] Support twitter card.
|
||||||
|
- [x] Remove name in `.Site.Params`. It's duplicate with `.Site.title`.
|
||||||
|
- [x] Add `author` in `.Site.Params`.
|
@ -1,11 +1,11 @@
|
|||||||
<ul id="post-list" class="archive readmore">
|
<ul id="post-list" class="archive readmore">
|
||||||
<h3>{{ with .Site.Params.readMore }}{{ . }}{{ else }}Read more{{ end }}</h3>
|
<h3>{{ .Site.Params.readMore | default "Read more" }}</h3>
|
||||||
{{ range first 10 (where .Site.Pages "Params.hidden" "ne" "true") }}
|
|
||||||
{{ $url := replace .Permalink .Site.BaseURL "" }}
|
{{ $kind := where .Site.RegularPages "Section" "!=" "" }}
|
||||||
{{ if and (ne $url "about/") }}
|
{{ $othr := where $kind "URL" "!=" .URL }}
|
||||||
|
{{ range first 10 $othr }}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ .Permalink }}">{{ .Title }}<aside class="dates">{{ .Date.Format "Jan 2" }}</aside></a>
|
<a href="{{ .URL }}">{{ .LinkTitle }}<aside class="dates">{{ .Date.Format "Jan 2 2006" }}</aside></a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
</ul>
|
||||||
</ul>
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
{{ if .IsPage }}
|
||||||
|
{{ with .Params.images }}
|
||||||
|
<!-- Twitter summary card with large image must be at least 280x150px -->
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image:src" content="{{ index . 0 | absURL }}"/>
|
||||||
|
{{ else }}
|
||||||
|
<meta name="twitter:card" content="summary"/>
|
||||||
|
{{ if .Site.Params.twitterCardImage }}
|
||||||
|
<meta name="twitter:image" content="{{ .Site.Params.twitterCardImage | absURL }}" />
|
||||||
|
{{ else }}
|
||||||
|
<meta name="twitter:image" content="{{ .Site.BaseURL }}images/avatar.png" />
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
<!-- Twitter Card data -->
|
||||||
|
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||||
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"/>
|
||||||
|
{{ with .Site.Params.twitter }}
|
||||||
|
<meta name="twitter:site" content="@{{ . }}"/>
|
||||||
|
{{ end }}
|
||||||
|
{{ range .Site.Authors }}
|
||||||
|
{{ with .twitter }}
|
||||||
|
<meta name="twitter:creator" content="@{{ . }}"/>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
<!-- no post authors, show site author -->
|
||||||
|
{{ if eq (len .Site.Authors) 0 }}
|
||||||
|
<meta name="twitter:creator" content="@{{ .Site.Params.author }}"/>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ else }}
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary" />
|
||||||
|
{{ with .Site.Params.twitter }}
|
||||||
|
<meta name="twitter:site" content="@{{ . }}"/>
|
||||||
|
{{ end }}
|
||||||
|
{{ with .Site.Params.author }}
|
||||||
|
<meta name="twitter:creator" content="@{{ . }}"/>
|
||||||
|
{{ end }}
|
||||||
|
<meta name="twitter:title" content="{{ .Site.Title }}"/>
|
||||||
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"/>
|
||||||
|
{{ if .Site.Params.twitterCardImage }}
|
||||||
|
<meta name="twitter:image" content="{{ .Site.Params.twitterCardImage | absURL }}" />
|
||||||
|
{{ else }}
|
||||||
|
<meta name="twitter:image" content="{{ .Site.BaseURL }}images/avatar.png" />
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
Loading…
Reference in New Issue