mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 13:56:22 -04:00
if multiple of the same shortcode are used, only load scripts once
This commit is contained in:
parent
951c5f2c3f
commit
fa98e48664
@ -5,11 +5,12 @@
|
|||||||
{{ partial "head" . }}
|
{{ partial "head" . }}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{ block "header" . }}{{ partial "header" . }}{{ end }}
|
{{ partial "header" . }}
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
{{ block "main" . }}{{ end }}
|
{{ block "main" . }}{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ block "footer" . }}{{ partial "footer" . }}{{ end }}
|
{{ partial "footer" . }}
|
||||||
|
{{ partial "scripts" . }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
|
<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
|
||||||
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
|
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
|
||||||
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
|
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
|
||||||
|
<script async custom-element="amp-facebook" src="https://cdn.ampproject.org/v0/amp-facebook-0.1.js"></script>
|
||||||
<title>{{ .Title }} – {{ .Site.Title }}</title>
|
<title>{{ .Title }} – {{ .Site.Title }}</title>
|
||||||
{{ with .OutputFormats.Get "html" }}<link rel="canonical" href="{{ .Permalink }}">{{ end }}
|
{{ with .OutputFormats.Get "html" }}<link rel="canonical" href="{{ .Permalink }}">{{ end }}
|
||||||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<div id="commento"></div>
|
<div id="commento"></div>
|
||||||
<script src="https://comments.jarv.is/js/commento.js"></script>
|
<script async defer src="https://comments.jarv.is/js/commento.js"></script>
|
||||||
|
@ -44,4 +44,3 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{ with .Site.Author.twitterid }}<meta name="twitter:creator_id" content="{{ . }}">{{ end }}
|
{{ with .Site.Author.twitterid }}<meta name="twitter:creator_id" content="{{ . }}">{{ end }}
|
||||||
<meta name="twitter:dnt" content="on">
|
<meta name="twitter:dnt" content="on">
|
||||||
<meta name="twitter:widgets:csp" content="on">
|
|
||||||
|
14
layouts/partials/scripts.html
Normal file
14
layouts/partials/scripts.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{{- if .HasShortcode "gh-buttons"}}
|
||||||
|
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{- if .HasShortcode "tweet"}}
|
||||||
|
<script async defer src="https://platform.twitter.com/widgets.js"></script>
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{- if .HasShortcode "facebook"}}
|
||||||
|
<div id="fb-root"></div>
|
||||||
|
<script async defer src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v5.0"></script>
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{- template "_internal/google_analytics_async.html" . }}
|
@ -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>
|
||||||
|
6
layouts/shortcodes/facebook.amp.html
Normal file
6
layouts/shortcodes/facebook.amp.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<amp-facebook
|
||||||
|
width="552"
|
||||||
|
height="310"
|
||||||
|
layout="responsive"
|
||||||
|
data-href="{{ .Get "url" }}">
|
||||||
|
</amp-facebook>
|
3
layouts/shortcodes/facebook.html
Normal file
3
layouts/shortcodes/facebook.html
Normal 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 -}}
|
1
layouts/shortcodes/facebook.rss.html
Symbolic link
1
layouts/shortcodes/facebook.rss.html
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
facebook.html
|
@ -1,5 +1,4 @@
|
|||||||
<p style="text-align: center;">
|
<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>
|
<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="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>
|
</p>
|
||||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
||||||
|
5
layouts/shortcodes/tweet.html
Normal file
5
layouts/shortcodes/tweet.html
Normal 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 -}}
|
@ -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 -}}
|
|
1
layouts/shortcodes/tweet.rss.html
Symbolic link
1
layouts/shortcodes/tweet.rss.html
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
tweet.html
|
@ -98,9 +98,3 @@
|
|||||||
to = "/403.html"
|
to = "/403.html"
|
||||||
status = 403
|
status = 403
|
||||||
force = true
|
force = true
|
||||||
# no clue what these requests are? but there are a lot...
|
|
||||||
[[redirects]]
|
|
||||||
from = "/plus/*.php"
|
|
||||||
to = "/403.html"
|
|
||||||
status = 403
|
|
||||||
force = true
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user