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

change a BUNCH of if's to with's to prepare for theme extraction

This commit is contained in:
2019-12-03 12:41:55 -05:00
parent ac0bbc6343
commit 96ad258d36
23 changed files with 153 additions and 104 deletions

View File

@@ -1,7 +1,7 @@
<amp-iframe
layout="responsive"
width="1200"
height="{{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}"
height="{{ with .Get "height" }}{{ . }}{{ else }}500{{ end }}"
scrolling="no"
src="https://codepen.io/{{ .Get "username" }}/embed/{{ .Get "id" }}/?height={{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}&amp;theme-id=light&amp;default-tab={{ .Get "left-tab" }}{{ if .Get "right-tab" }},{{ .Get "right-tab" }}{{ end }}">
src="https://codepen.io/{{ .Get "username" }}/embed/{{ .Get "id" }}/?height={{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}&amp;theme-id=light&amp;default-tab={{ .Get "left-tab" }}{{ with .Get "right-tab" }},{{ . }}{{ end }}">
</amp-iframe>

View File

@@ -1 +1,6 @@
<iframe height="{{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}" style="width: 100%;" scrolling="no" src="https://codepen.io/{{ .Get "username" }}/embed/{{ .Get "id" }}/?height={{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}&amp;theme-id=light&amp;default-tab={{ .Get "left-tab" }}{{ if .Get "right-tab" }},{{ .Get "right-tab" }}{{ end }}"></iframe>
<iframe
height="{{ with .Get "height" }}{{ . }}{{ else }}500{{ end }}"
style="width: 100%;"
scrolling="no"
src="https://codepen.io/{{ .Get "username" }}/embed/{{ .Get "id" }}/?height={{ with .Get "height" }}{{ . }}{{ else }}500{{ end }}&amp;theme-id=light&amp;default-tab={{ .Get "left-tab" }}{{ with .Get "right-tab" }},{{ . }}{{ end }}">
</iframe>

View File

@@ -1 +1,3 @@
<p class="center"><a href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}" target="_blank" rel="noopener">View on GitHub</a></p>
<p class="center">
<a href="https://github.com/{{ .Get "username" }}/{{ with .Get "repo" }}{{ . }}{{ end }}" target="_blank" rel="noopener">View on GitHub.</a>
</p>

View File

@@ -1,2 +1,5 @@
<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></p>
<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>
</p>
<script async defer src="https://buttons.github.io/buttons.js"></script>

View File

@@ -10,7 +10,7 @@
{{- $retinaWidth := (mul $setWidth 2) -}}
{{- if gt $original.Width $retinaWidth -}}
{{- $finalWidth := (printf "%dx" $retinaWidth ) -}}
{{- $finalWidth := (printf "%dx" $retinaWidth) -}}
{{- .Scratch.Set "image" ($original.Resize $finalWidth) -}}
{{- end -}}
{{- else -}}
@@ -28,13 +28,12 @@
<p class="image">
<amp-img
alt="{{ .Get "alt" }}"
{{ with .Get "alt" }}alt="{{ . }}"{{ end }}
src="{{ $image.Permalink }}"
width="{{ $displayWidth }}"
height="{{ $displayHeight }}"
layout="intrinsic"
>
layout="intrinsic">
</amp-img>
</p>
{{- with (.Get "caption") }}<p class="caption"><em>{{ . }}</em></p>{{ end -}}
{{- with .Get "caption" }}<p class="caption"><em>{{ . }}</em></p>{{ end -}}

View File

@@ -12,7 +12,7 @@
{{- $retinaWidth := (mul $setWidth 2) -}}
{{- if gt $original.Width $retinaWidth -}}
{{- $finalWidth := (printf "%dx" $retinaWidth ) -}}
{{- $finalWidth := (printf "%dx" $retinaWidth) -}}
{{- .Scratch.Set "image" ($original.Resize $finalWidth) -}}
{{- end -}}
{{- else -}}
@@ -35,11 +35,11 @@
<p>
{{- end -}}
<img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
{{- if .Get "alt" }} alt="{{ .Get "alt" }}"{{ end }}
{{- if .Get "caption" }} title="{{ .Get "caption"}}"{{ end }}>
{{- if .Get "caption" -}}
{{- with .Get "alt" }} alt="{{ . }}"{{ end }}
{{- with .Get "caption" }} title="{{ . }}"{{ end }}>
{{- with .Get "caption" -}}
</picture>
<figcaption>{{ .Get "caption" }}</figcaption>
<figcaption>{{ . }}</figcaption>
</figure>
{{- else -}}
</p>

View File

@@ -1,21 +1,16 @@
{{- $video_webm := .Page.Resources.GetMatch (.Get "webm") -}}
{{- $video_mp4 := .Page.Resources.GetMatch (.Get "mp4") -}}
{{- $video_ogg := .Page.Resources.GetMatch (.Get "ogg") -}}
{{- $img_poster := .Page.Resources.GetMatch (.Get "poster") -}}
<amp-video
layout="responsive"
width="{{ if .Get "width" }}{{ .Get "width" }}{{ else }}910{{ end }}"
height="{{ if .Get "height" }}{{ .Get "height" }}{{ else }}600{{ end }}"
{{- if .Get "poster" }} poster="{{ $img_poster.Permalink }}"{{ end }}
width="{{ with .Get "width" }}{{ . }}{{ else }}910{{ end }}"
height="{{ with .Get "height" }}{{ . }}{{ else }}600{{ end }}"
{{- with .Page.Resources.GetMatch (.Get "poster") }} poster="{{ .Permalink }}"{{ end }}
{{- if .Get "autoplay" }} autoplay{{ end }}
{{- if .Get "loop" }} loop{{ end }}
{{- if ne (.Get "nocontrols") "1" }} controls{{ end }}>
{{ if .Get "webm" }}<source src="{{ $video_webm.Permalink }}" type="video/webm">{{ end }}
{{ if .Get "mp4" }}<source src="{{ $video_mp4.Permalink }}" type="video/mp4">{{ end }}
{{ if .Get "ogg" }}<source src="{{ $video_ogg.Permalink }}" type="video/ogg">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "webm") }}<source src="{{ .Permalink }}" type="video/webm">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "mp4") }}<source src="{{ .Permalink }}" type="video/mp4">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "ogg") }}<source src="{{ .Permalink }}" type="video/ogg">{{ end }}
<div fallback>
<p>Your browser does not support HTML5 video. <a href="{{ $video_mp4.Permalink }}">Load the .mp4 video directly.</a></p>
<p>Your browser does not support HTML5 video. {{ with .Page.Resources.GetMatch (.Get "mp4") }}<a href="{{ .Permalink }}">Load the .mp4 video directly.</a>{{ end }}</p>
</div>
</amp-video>

View File

@@ -1,18 +1,13 @@
{{- $video_webm := .Page.Resources.GetMatch (.Get "webm") -}}
{{- $video_mp4 := .Page.Resources.GetMatch (.Get "mp4") -}}
{{- $video_ogg := .Page.Resources.GetMatch (.Get "ogg") -}}
{{- $img_poster := .Page.Resources.GetMatch (.Get "poster") -}}
<video class="embed"
{{- if .Get "width" }} width="{{ .Get "width" }}"{{ end }}
{{- if .Get "height" }} height="{{ .Get "height" }}"{{ end }}
{{- if .Get "poster" }} poster="{{ $img_poster.Permalink }}"{{ end }}
{{- with .Get "width" }} width="{{ . }}"{{ end }}
{{- with .Get "height" }} height="{{ . }}"{{ end }}
{{- with .Page.Resources.GetMatch (.Get "poster") }} poster="{{ .Permalink }}"{{ end }}
{{- if .Get "autoplay" }} autoplay{{ end }}
{{- if .Get "loop" }} loop{{ end }}
{{- if ne (.Get "nocontrols") "1" }} controls{{ end }}>
{{ if .Get "webm" }}<source src="{{ $video_webm.Permalink }}" type="video/webm">{{ end }}
{{ if .Get "mp4" }}<source src="{{ $video_mp4.Permalink }}" type="video/mp4">{{ end }}
{{ if .Get "ogg" }}<source src="{{ $video_ogg.Permalink }}" type="video/ogg">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "webm") }}<source src="{{ .Permalink }}" type="video/webm">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "mp4") }}<source src="{{ .Permalink }}" type="video/mp4">{{ end }}
{{ with .Page.Resources.GetMatch (.Get "ogg") }}<source src="{{ .Permalink }}" type="video/ogg">{{ end }}
<p>Your browser does not support HTML5 video. <a href="{{ $video_mp4.Permalink }}">Load the .mp4 video directly.</a></p>
<p>Your browser does not support HTML5 video. {{ with .Page.Resources.GetMatch (.Get "mp4") }}<a href="{{ .Permalink }}">Load the .mp4 video directly.</a>{{ end }}</p>
</video>

View File

@@ -1,3 +1,7 @@
<div class="embed video-player">
<iframe class="youtube-player" src="https://www.youtube-nocookie.com/embed/{{ index .Params 0 }}?autoplay=0&amp;hl=en&amp;fs=1&amp;showinfo=1&amp;rel=0&amp;iv_load_policy=3" allowfullscreen></iframe>
<iframe
class="youtube-player"
src="https://www.youtube-nocookie.com/embed/{{ index .Params 0 }}?autoplay=0&amp;hl=en&amp;fs=1&amp;showinfo=1&amp;rel=0&amp;iv_load_policy=3"
allowfullscreen>
</iframe>
</div>