mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-07-07 12:37:31 -05:00
Compare commits
2 Commits
master
...
rewrite-fi
Author | SHA1 | Date | |
---|---|---|---|
e0d2c536e4
|
|||
8fafc843ef
|
@ -198,14 +198,14 @@ video {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.post-media > figure.border img,
|
||||
.post-media > figure.border video {
|
||||
.post-media > figure img,
|
||||
.post-media > figure video {
|
||||
padding: 5px;
|
||||
border: 7px solid var(--figure-border);
|
||||
}
|
||||
|
||||
figure.border img,
|
||||
figure.border video {
|
||||
figure img,
|
||||
figure video {
|
||||
padding: 5px;
|
||||
border: 2px solid var(--figure-border);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ markup:
|
||||
lineNos: true
|
||||
goldmark:
|
||||
parser:
|
||||
# don't put <p> around ![]() image in markdown (used to embed any resource now)
|
||||
wrapStandAloneImageWithinParagraph: false
|
||||
attribute:
|
||||
block: true
|
||||
# this is enabled by default already
|
||||
|
@ -7,6 +7,8 @@ table_of_contents:
|
||||
|
||||
browser_no_video_support:
|
||||
other: "Your browser does not support video."
|
||||
browser_no_video_support_link:
|
||||
other: "Click here to download it instead."
|
||||
|
||||
latest_posts:
|
||||
other: "Latest Posts"
|
||||
|
12
layouts/_markup/render-image.html
Normal file
12
layouts/_markup/render-image.html
Normal file
@ -0,0 +1,12 @@
|
||||
{{/* TODO: should we use .PageInner */}}
|
||||
{{ partial "embed-resource.html" (.Page.Resources.Get .Destination) }}
|
||||
{{ with .Title }}
|
||||
{{ errorf "%q" . }}
|
||||
{{ end }}
|
||||
{{ with .Attributes }}
|
||||
{{/* FIXME: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html */}}
|
||||
{{ errorf "%q" . }}
|
||||
{{ end }}
|
||||
{{ with .Text }}
|
||||
{{ errorf "%q" . }}
|
||||
{{ end }}
|
21
layouts/_partials/embed-resource.html
Normal file
21
layouts/_partials/embed-resource.html
Normal file
@ -0,0 +1,21 @@
|
||||
{{ if eq .ResourceType "image" }}
|
||||
{{/* TODO: figure out whether loading="lazy" should be set because MDN
|
||||
* claims that images won't work with JS disabled since it would
|
||||
* make tracking possible, but my experience says otherwise
|
||||
*/}}
|
||||
<img src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
|
||||
{{ else if eq .ResourceType "video" }}
|
||||
<video controls preload="metadata">
|
||||
{{/* FIXME
|
||||
<source src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
|
||||
*/}}
|
||||
{{ i18n "browser_no_video_support" }}
|
||||
<a href="{{ .Permalink }}" target="_blank" rel="noopener">
|
||||
{{ i18n "browser_no_video_support_link" }}
|
||||
</video>
|
||||
{{ else }}
|
||||
{{/* TODO: could consider implementing more types, listed at:
|
||||
* https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
*/}}
|
||||
{{ errorf "Handling %q resource not supported" .ResourceType }}
|
||||
{{ end }}
|
10
layouts/_partials/feature-figure.html
Normal file
10
layouts/_partials/feature-figure.html
Normal file
@ -0,0 +1,10 @@
|
||||
{{ with .Resources.Get "feature" }}
|
||||
<div class="post-media">
|
||||
<figure>
|
||||
{{ partial "embed-resource.html" . }}
|
||||
{{ with .Title }}
|
||||
<figcaption>{{ . }}</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
</div>
|
||||
{{ end }}
|
@ -1,27 +0,0 @@
|
||||
{{ $hidecaption := index . "hidecaption" }}
|
||||
|
||||
{{ if index . "noborder" }}
|
||||
<figure>
|
||||
{{ else }}
|
||||
<figure class="border">
|
||||
{{ end }}
|
||||
|
||||
{{ with index . "src" }}
|
||||
{{ if eq .MediaType.MainType "image" }}
|
||||
<img src="{{ .Permalink }}" alt="{{ .Title }}" loading="lazy" />
|
||||
{{ else if eq .MediaType.MainType "video" }}
|
||||
<video controls preload="metadata">
|
||||
<source src="{{ .Permalink }}" alt="{{ .Title }}">
|
||||
{{ i18n "browser_no_video_support" }}
|
||||
</video>
|
||||
{{ end }}
|
||||
|
||||
{{ if not $hidecaption }}
|
||||
{{ with .Title }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</figure>
|
@ -1,28 +0,0 @@
|
||||
{{ $hidecaption := index . "hidecaption" }}
|
||||
{{ $type := index . "type" }}
|
||||
{{ $src := index . "src" }}
|
||||
{{ $alt := index . "alt" }}
|
||||
|
||||
{{ if index . "border" }}
|
||||
<figure class="border">
|
||||
{{ else }}
|
||||
<figure>
|
||||
{{ end }}
|
||||
|
||||
{{ if eq $type "image" }}
|
||||
<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" />
|
||||
{{ else if eq $type "video" }}
|
||||
<video controls preload="metadata">
|
||||
<source src="{{ $src }}" alt="{{ $alt }}">
|
||||
{{ i18n "browser_no_video_support" }}
|
||||
</video>
|
||||
{{ end }}
|
||||
|
||||
{{ if not $hidecaption }}
|
||||
{{ with $alt }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</figure>
|
@ -1,15 +1,17 @@
|
||||
{{ $resource := .Page.Resources.GetMatch (.Get "src") }}
|
||||
|
||||
{{ $noborder := false }}
|
||||
{{ if .Get "noborder" }}
|
||||
{{ $noborder = true }}
|
||||
{{ end }}
|
||||
|
||||
{{ $hidecaption := false }}
|
||||
{{ if .Get "hidecaption" }}
|
||||
{{ $hidecaption = true }}
|
||||
{{ end }}
|
||||
|
||||
<p>
|
||||
{{ partial "figure.html" (dict "src" $resource "noborder" $noborder "hidecaption" $hidecaption) }}
|
||||
</p>
|
||||
<figure>
|
||||
{{ with .Get "src" }}
|
||||
{{ with $.Page.Resources.Get . }}
|
||||
{{ partial "embed-resource.html" . }}
|
||||
{{ with .Title }}
|
||||
<figcaption>{{ . | markdownify }}</figcaption>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "resource %q not found" . }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ .Inner }}
|
||||
{{ with .Get "caption" }}
|
||||
<figcaption>{{ . | markdownify }}</figcaption>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</figure>
|
||||
|
@ -1,13 +0,0 @@
|
||||
{{ $border := false }}
|
||||
{{ if .Get "border" }}
|
||||
{{ $border = true }}
|
||||
{{ end }}
|
||||
|
||||
{{ $hidecaption := false }}
|
||||
{{ if .Get "hidecaption" }}
|
||||
{{ $hidecaption = true }}
|
||||
{{ end }}
|
||||
|
||||
<p>
|
||||
{{ partial "remote_figure.html" (dict "src" (.Get "src") "border" $border "hidecaption" $hidecaption "type" (.Get "type") "alt" (.Get "alt")) }}
|
||||
</p>
|
9
layouts/_shortcodes/resource.html
Normal file
9
layouts/_shortcodes/resource.html
Normal file
@ -0,0 +1,9 @@
|
||||
{{ with .Get 0 }}
|
||||
{{ with $.Page.Resources.Get . }}
|
||||
{{ partial "embed-resource.html" . }}
|
||||
{{ else }}
|
||||
{{ errorf "resource %q not found" . }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "resource name not provided as first parameter" }}
|
||||
{{ end }}
|
@ -22,11 +22,7 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
<div class="post-media">
|
||||
{{ partial "figure.html" (dict "src" .) }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ partial "feature-figure.html" . }}
|
||||
|
||||
<article class="post-content">
|
||||
{{ .Content }}
|
||||
|
@ -6,11 +6,7 @@
|
||||
|
||||
{{ partial "page-metadata/post-short.html" . }}
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
<div class="post-media">
|
||||
{{ partial "figure.html" (dict "src" .) }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ partial "feature-figure.html" . }}
|
||||
|
||||
<div class="page-description">
|
||||
{{ partial "description-or-summary.html" . }}
|
||||
|
Reference in New Issue
Block a user