Skip to content

Commit

Permalink
Merge pull request #82 from nisargap/master
Browse files Browse the repository at this point in the history
Added support for Twitter metadata specification
  • Loading branch information
Lednerb authored Jun 11, 2018
2 parents bf2f08d + 0cc10cd commit 5660da6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.2.1/dist/instantsearch.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.2.1/dist/instantsearch-theme-algolia.min.css">

{{ partial "twitter-card" . }}

{{ if isset .Site.Params "css_modules" }}
{{ range .Site.Params.css_modules }}
Expand Down
31 changes: 31 additions & 0 deletions layouts/partials/twitter-card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{ with .Params.twitter }}
<meta name="twitter:card" content="{{- .card -}}">
<meta name="twitter:site" content="{{- .site -}}">
{{ if ne .card "app" -}}
<meta name="twitter:title" content="{{- .title -}}">
<meta name="twitter:image" content="{{- .image -}}">
{{ with .image_alt -}}<meta name="twitter:image:alt" content="{{- . -}}">{{- end }}
{{- end }}
{{ with .creator -}}<meta name="twitter:creator" content="{{- . -}}">{{- end }}

{{- if eq .card "app" }}
{{ with .app_country }}<meta name="twitter:app:country" content="{{- . -}}">{{ end }}
{{ with .app_name_iphone }}<meta name="twitter:app:name:iphone" content="{{- . -}}">{{ end }}
{{ with .app_id_iphone }}<meta name="twitter:app:id:iphone" content="{{- . -}}">{{ end }}
{{ with .app_url_iphone }}<meta name="twitter:app:url:iphone" content="{{- . -}}">{{ end }}
{{ with .app_name_ipad }}<meta name="twitter:app:name:ipad" content="{{- . -}}">{{ end }}
{{ with .app_id_ipad }}<meta name="twitter:app:id:ipad" content="{{- . -}}">{{ end }}
{{ with .app_url_ipad }}<meta name="twitter:app:url:ipad" content="{{- . -}}">{{ end }}
{{ with .app_name_googleplay }}<meta name="twitter:app:name:googleplay" content="{{- . -}}">{{ end }}
{{ with .app_id_googleplay }}<meta name="twitter:app:id:googleplay" content="{{- . -}}">{{ end }}
{{ with .app_url_googleplay }}<meta name="twitter:app:url:googleplay" content="{{- . -}}">{{ end }}
{{- end }}

{{- if eq .card "player" }}
{{ with .player }}<meta name="twitter:player" content="{{- . -}}">{{ end }}
{{ with .player_width }}<meta name="twitter:player:width" content="{{- . -}}">{{ end }}
{{ with .player_height }}<meta name="twitter:player:height" content="{{- . -}}">{{ end }}
{{ with .player_stream }}<meta name="twitter:player:stream" content="{{- . -}}">{{ end }}
{{ with .player_stream_content_type }}<meta name="twitter:player:stream:content_type" content="{{- . -}}">{{ end }}
{{- end }}
{{ end }}

0 comments on commit 5660da6

Please sign in to comment.