mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-12-03 04:18:57 -05:00
simplify shortcode JS logic and only call AMP script if shortcodes present
fixes https://search.google.com/search-console/amp/drilldown?resource_id=sc-domain%3Ajarv.is&item_key=GgcIIhADKKZO&utm_source=wnc_10030322&utm_medium=gamma&utm_campaign=wnc_10030322&utm_content=msg_100058679&hl=en&sharing_key=VVX9zj1yTzUxHPzmKFP4Gg
This commit is contained in:
@@ -4,3 +4,8 @@
|
||||
<div class="embed facebook">
|
||||
{{ $json.html | safeHTML }}
|
||||
</div>
|
||||
|
||||
{{- define "__shortcode_facebook_js" }}
|
||||
<div id="fb-root"></div>
|
||||
<script async defer src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v5.0"></script>
|
||||
{{- end }}
|
||||
|
||||
@@ -2,3 +2,7 @@
|
||||
<a class="github-button" href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star {{ .Get "username" }}/{{ .Get "repo" }} on GitHub">Star</a>
|
||||
<a class="github-button" href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}/issues" data-icon="octicon-issue-opened" data-size="large" data-show-count="true" aria-label="Issues for {{ .Get "username" }}/{{ .Get "repo" }} on GitHub">Issue</a>
|
||||
</p></div>
|
||||
|
||||
{{- define "__shortcode_gh-buttons_js" }}
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
{{- end }}
|
||||
|
||||
7
layouts/shortcodes/instagram.amp.html
Normal file
7
layouts/shortcodes/instagram.amp.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<amp-instagram
|
||||
data-shortcode="{{ .Get "id" }}"
|
||||
data-captioned
|
||||
width="500"
|
||||
height="500"
|
||||
layout="responsive">
|
||||
</amp-instagram>
|
||||
10
layouts/shortcodes/instagram.html
Normal file
10
layouts/shortcodes/instagram.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{{- $url := printf "https://api.instagram.com/oembed/?omitscript=1&url=https://www.instagram.com/p/%s" (.Get "id") -}}
|
||||
{{- $json := getJSON $url -}}
|
||||
|
||||
<div class="embed instagram">
|
||||
{{ $json.html | safeHTML }}
|
||||
</div>
|
||||
|
||||
{{- define "__shortcode_instagram_js" }}
|
||||
<script async src="https://www.instagram.com/embed.js"></script>
|
||||
{{- end }}
|
||||
1
layouts/shortcodes/instagram.rss.xml
Normal file
1
layouts/shortcodes/instagram.rss.xml
Normal file
@@ -0,0 +1 @@
|
||||
<p style="text-align: center;"><a href="https://www.instagram.com/p/{{ .Get "id" }}" target="_blank" rel="noopener">View this image on Instagram.</a></p>
|
||||
@@ -4,3 +4,7 @@
|
||||
<div class="embed tweet">
|
||||
{{ $json.html | safeHTML }}
|
||||
</div>
|
||||
|
||||
{{- define "__shortcode_twitter_js" }}
|
||||
<script async defer src="https://platform.twitter.com/widgets.js"></script>
|
||||
{{- end }}
|
||||
|
||||
6
layouts/shortcodes/vimeo.amp.html
Normal file
6
layouts/shortcodes/vimeo.amp.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<amp-vimeo
|
||||
data-videoid="{{ .Get "id" }}"
|
||||
layout="responsive"
|
||||
width="500"
|
||||
height="281">
|
||||
</amp-vimeo>
|
||||
7
layouts/shortcodes/vimeo.html
Normal file
7
layouts/shortcodes/vimeo.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="embed vimeo" style="padding:75% 0 0 0;position:relative;">
|
||||
<iframe src="https://player.vimeo.com/video/{{ .Get "id" }}&dnt=1" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="fullscreen" allowfullscreen></iframe>
|
||||
</div>
|
||||
|
||||
{{- define "__shortcode_vimeo_js" }}
|
||||
<script src="https://player.vimeo.com/api/player.js"></script>
|
||||
{{ end }}
|
||||
1
layouts/shortcodes/vimeo.rss.xml
Normal file
1
layouts/shortcodes/vimeo.rss.xml
Normal file
@@ -0,0 +1 @@
|
||||
<p style="text-align: center;"><a href="https://vimeo.com/{{ .Get "id" }}" target="_blank" rel="noopener">Watch this video on Vimeo.</a></p>
|
||||
@@ -1 +1 @@
|
||||
<p style="text-align: center;"><a href="https://www.youtube.com/watch?v={{ index .Params 0 }}">Watch this video on YouTube.</a></p>
|
||||
<p style="text-align: center;"><a href="https://www.youtube.com/watch?v={{ index .Params 0 }}" target="_blank" rel="noopener">Watch this video on YouTube.</a></p>
|
||||
|
||||
Reference in New Issue
Block a user