summaryrefslogtreecommitdiffstats
path: root/tpl/tplimpl/embedded
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/tplimpl/embedded')
-rw-r--r--tpl/tplimpl/embedded/templates/_default/_markup/render-image.html11
-rw-r--r--tpl/tplimpl/embedded/templates/_default/_markup/render-link.html9
-rw-r--r--tpl/tplimpl/embedded/templates/_default/rss.xml2
-rw-r--r--tpl/tplimpl/embedded/templates/opengraph.html12
-rw-r--r--tpl/tplimpl/embedded/templates/schema.html4
-rw-r--r--tpl/tplimpl/embedded/templates/shortcodes/youtube.html20
-rw-r--r--tpl/tplimpl/embedded/templates/twitter_cards.html24
7 files changed, 42 insertions, 40 deletions
diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html
index 013e31235..89514cb83 100644
--- a/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html
+++ b/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html
@@ -1,11 +1,18 @@
{{- $u := urls.Parse .Destination -}}
{{- $src := $u.String -}}
{{- if not $u.IsAbs -}}
- {{- with or (.PageInner.Resources.Get $u.Path) (resources.Get $u.Path) -}}
+ {{- $path := strings.TrimPrefix "./" $u.Path }}
+ {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
{{- $src = .RelPermalink -}}
+ {{- with $u.RawQuery -}}
+ {{- $src = printf "%s?%s" $src . -}}
+ {{- end -}}
+ {{- with $u.Fragment -}}
+ {{- $src = printf "%s#%s" $src . -}}
+ {{- end -}}
{{- end -}}
{{- end -}}
-{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" .Title) -}}
+{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}}
<img
{{- range $k, $v := $attributes -}}
{{- if $v -}}
diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html
index 8903d3dfb..daf3f11e1 100644
--- a/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html
+++ b/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html
@@ -3,10 +3,11 @@
{{- if strings.HasPrefix $u.String "#" }}
{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment }}
{{- else if not $u.IsAbs -}}
+ {{- $path := strings.TrimPrefix "./" $u.Path }}
{{- with or
- ($.PageInner.GetPage $u.Path)
- ($.PageInner.Resources.Get $u.Path)
- (resources.Get $u.Path)
+ ($.PageInner.GetPage $path)
+ ($.PageInner.Resources.Get $path)
+ (resources.Get $path)
-}}
{{- $href = .RelPermalink -}}
{{- with $u.RawQuery -}}
@@ -17,7 +18,7 @@
{{- end -}}
{{- end -}}
{{- end -}}
-{{- $attributes := dict "href" $href "title" .Title -}}
+{{- $attributes := dict "href" $href "title" (.Title | transform.HTMLEscape) -}}
<a
{{- range $k, $v := $attributes -}}
{{- if $v -}}
diff --git a/tpl/tplimpl/embedded/templates/_default/rss.xml b/tpl/tplimpl/embedded/templates/_default/rss.xml
index a3cade657..2e505f1bc 100644
--- a/tpl/tplimpl/embedded/templates/_default/rss.xml
+++ b/tpl/tplimpl/embedded/templates/_default/rss.xml
@@ -48,7 +48,7 @@
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
- <generator>Hugo {{ hugo.Version }}</generator>
+ <generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
diff --git a/tpl/tplimpl/embedded/templates/opengraph.html b/tpl/tplimpl/embedded/templates/opengraph.html
index c245e5bd1..59e63d6be 100644
--- a/tpl/tplimpl/embedded/templates/opengraph.html
+++ b/tpl/tplimpl/embedded/templates/opengraph.html
@@ -4,21 +4,23 @@
<meta property="og:site_name" content="{{ . }}">
{{- end }}
-{{- with or .Title site.Title site.Params.title | plainify}}
+{{- with or .Title site.Title site.Params.title | plainify }}
<meta property="og:title" content="{{ . }}">
{{- end }}
-{{- with or .Description .Summary site.Params.description | plainify }}
+{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape | chomp }}
<meta property="og:description" content="{{ . }}">
{{- end }}
-{{- with or .Params.locale site.Language.LanguageCode site.Language.Lang }}
- <meta property="og:locale" content="{{ . }}">
+{{- with or .Params.locale site.Language.LanguageCode }}
+ <meta property="og:locale" content="{{ replace . `-` `_` }}">
{{- end }}
{{- if .IsPage }}
<meta property="og:type" content="article">
- <meta property="article:section" content="{{ .Section }}">
+ {{- with .Section }}
+ <meta property="article:section" content="{{ . }}">
+ {{- end }}
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }}
<meta property="article:published_time" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
diff --git a/tpl/tplimpl/embedded/templates/schema.html b/tpl/tplimpl/embedded/templates/schema.html
index c4e89abd6..2b3c5425a 100644
--- a/tpl/tplimpl/embedded/templates/schema.html
+++ b/tpl/tplimpl/embedded/templates/schema.html
@@ -1,8 +1,8 @@
-{{- with or .Title site.Title }}
+{{- with or .Title site.Title | plainify }}
<meta itemprop="name" content="{{ . }}">
{{- end }}
-{{- with or .Description .Summary site.Params.Description }}
+{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape | chomp }}
<meta itemprop="description" content="{{ . }}">
{{- end }}
diff --git a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html
index bf72be45b..93fa18197 100644
--- a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html
@@ -8,10 +8,10 @@ Renders an embedded YouTube video.
@param {int} [end] The time, measured in seconds from the start of the video, when the player should stop playing the video.
@param {string} [id] The video id. Optional if the id is provided as first positional argument.
@param {string} [loading=eager] The loading attribute of the iframe element.
-@param {bool} [loop=false] Whether to indefinitely repeat the video.
+@param {bool} [loop=false] Whether to indefinitely repeat the video. Ignores the start and end arguments after the first play.
@param {bool} [mute=false] Whether to mute the video. Always true when autoplay is true.
@param {int} [start] The time, measured in seconds from the start of the video, when the player should start playing the video.
-@param {string} [title] The title attribute of the iframe element. Defaults to the title returned by YouTube oEmbed API.
+@param {string} [title] The title attribute of the iframe element. Defaults to "YouTube video".
@returns {template.HTML}
@@ -26,20 +26,6 @@ Renders an embedded YouTube video.
{{- if not $pc.Disable }}
{{- with $id := or (.Get "id") (.Get 0) }}
- {{- /* Get data from the YouTube oEmbed API. */}}
- {{- $q := querify "url" (printf "https://www.youtube.com/watch?v=%s" $id) "format" "json" }}
- {{- $url := printf "https://www.youtube.com/oembed?%s" $q }}
- {{- $data := dict }}
- {{- with resources.GetRemote $url }}
- {{- with .Err }}
- {{- erroridf $remoteErrID "The %q shortcode was unable to get remote resource %q. %s. See %s" $.Name $url . $.Position }}
- {{- else }}
- {{- $data = .Content | transform.Unmarshal }}
- {{- end }}
- {{- else }}
- {{- erroridf $remoteErrID "The %q shortcode was unable to get remote resource %q. See %s" $.Name $url $.Position }}
- {{- end }}
-
{{/* Set defaults. */}}
{{- $allowFullScreen := "allowfullscreen" }}
{{- $autoplay := 0 }}
@@ -50,7 +36,7 @@ Renders an embedded YouTube video.
{{- $loop := 0 }}
{{- $mute := 0 }}
{{- $start := 0 }}
- {{- $title := $data.title }}
+ {{- $title := "YouTube video" }}
{{- /* Get arguments. */}}
{{- if in (slice "false" false 0) ($.Get "allowFullScreen") }}
diff --git a/tpl/tplimpl/embedded/templates/twitter_cards.html b/tpl/tplimpl/embedded/templates/twitter_cards.html
index 14c92274b..6f156c7a7 100644
--- a/tpl/tplimpl/embedded/templates/twitter_cards.html
+++ b/tpl/tplimpl/embedded/templates/twitter_cards.html
@@ -1,12 +1,18 @@
-{{- $images := partial "_funcs/get-page-images" . -}}
-{{- with index $images 0 -}}
-<meta name="twitter:card" content="summary_large_image">
-<meta name="twitter:image" content="{{ .Permalink }}">
-{{- else -}}
-<meta name="twitter:card" content="summary">
-{{- end -}}
-<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 -}}">
+{{- $images := partial "_funcs/get-page-images" . }}
+{{- with index $images 0 }}
+ <meta name="twitter:card" content="summary_large_image">
+ <meta name="twitter:image" content="{{ .Permalink }}">
+{{- else }}
+ <meta name="twitter:card" content="summary">
+{{- end }}
+
+{{- with or .Title site.Title site.Params.title | plainify }}
+ <meta name="twitter:title" content="{{ . }}">
+{{- end }}
+
+{{- with or .Description .Summary site.Params.description | plainify | htmlUnescape | chomp }}
+ <meta name="twitter:description" content="{{ . }}">
+{{- end }}
{{- $twitterSite := "" }}
{{- with site.Params.social }}