1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-12-03 04:18:57 -05:00

if multiple of the same shortcode are used, only load scripts once

This commit is contained in:
2019-12-15 23:11:18 -05:00
parent 951c5f2c3f
commit fa98e48664
13 changed files with 37 additions and 18 deletions

View File

@@ -1 +1 @@
<p><a href="https://codepen.io/{{ .Get "username" }}/pen/{{ .Get "id" }}" target="_blank" rel="noopener">Open this CodePen in a new window.</a></p>
<p style="text-align: center;"><a href="https://codepen.io/{{ .Get "username" }}/pen/{{ .Get "id" }}" target="_blank" rel="noopener">Open this CodePen in a new window.</a></p>

View File

@@ -0,0 +1,6 @@
<amp-facebook
width="552"
height="310"
layout="responsive"
data-href="{{ .Get "url" }}">
</amp-facebook>

View File

@@ -0,0 +1,3 @@
{{- $url := printf "https://www.facebook.com/plugins/post/oembed.json/?omitscript=1&url=%s" (.Get "url" | urlize) -}}
{{- $json := getJSON $url -}}
{{- $json.html | safeHTML -}}

View File

@@ -0,0 +1 @@
facebook.html

View File

@@ -1,5 +1,4 @@
<p style="text-align: center;">
<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>&nbsp;&nbsp;&nbsp;
<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="Issue {{ .Get "username" }}/{{ .Get "repo" }} on GitHub">Issue</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>
<script async defer src="https://buttons.github.io/buttons.js"></script>

View File

@@ -0,0 +1,5 @@
{{- /* Modified from tpl/tplimpl/embedded/templates/shortcodes/twitter.html, minus script */ -}}
{{- $url := printf "https://api.twitter.com/1/statuses/oembed.json?id=%v&dnt=1&omit_script=1" (index .Params 0) -}}
{{- $json := getJSON $url -}}
{{- $json.html | safeHTML -}}

View File

@@ -1,5 +0,0 @@
{{- /* Modified from /tpl/tplimpl/embedded/templates/shortcodes/twitter.html to fetch tweet without script (&omit_script=1) */ -}}
{{- $url := printf "https://api.twitter.com/1/statuses/oembed.json?id=%d&omit_script=true" (index .Params 0) -}}
{{- $json := getJSON $url -}}
{{- $json.html | safeHTML -}}

View File

@@ -0,0 +1 @@
tweet.html