refine figure

This commit is contained in:
loikein 2023-04-18 00:29:12 +01:00
parent bb73762987
commit 3cda34976f
5 changed files with 52 additions and 41 deletions

View file

@ -29,6 +29,8 @@ $ht-code-border-radius: .4em;
&::before{
content: "> ";
// font-family: "Noto Emoji";
font-family: inherit;
position: absolute;
left: 0;
color: #111;
@ -65,7 +67,7 @@ $ht-code-border-radius: .4em;
@media screen and (max-width: 760px) {
.highlight .chroma {
.highlight {
width: 90%;
}
}

View file

@ -310,13 +310,12 @@ div.table-wrapper {
}
@media screen and (max-width: 760px) {
h2,
h3,
p,
footer {
width: 90%;
}
pre.code {
width: 87.5%;
}
ul {
width: 85%;
}

View file

@ -1,47 +1,57 @@
{{ $alt := .Get "alt" | default "Image" }}
{{ $type := .Get "type" | default "normal" }}
<!-- begin figure tag -->
{{ if not (eq $type "margin") }}
{{ if eq $type "full" }}
<figure class="fullwidth">
{{ else }}
<figure {{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{ end }}
{{ end }}
<!-- get a default label just in case -->
{{- $label := printf "%#v" (add .Ordinal 1) | printf "%s%s" "marginfig-" | printf "%s" -}}
{{- if .Get "label" -}}
{{- $label = .Get "label" -}}
{{- end -}}
<!-- begin inner elements -->
{{ if eq $type "full" }}
<!-- begin figure tag -->
{{- if not (eq $type "margin") -}}
{{ if eq $type "full" }}<!-- full -->
<figure class="fullwidth">
{{ else }}<!-- normal -->
<figure {{ with .Get "class" }}class="{{ . }}"{{ end }}>
{{ end }}
{{- end -}}
<!-- begin child elements -->
{{- if eq $type "full" -}}<!-- child for full -->
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
<img src="{{ .Get "src" }}" alt="{{ $alt }}">
{{ if .Get "link" }}</a>{{ end }}
<figcaption>
{{ else }}{{/* margin or normal */}}
<label for="{{ .Get "label" }}" class="margin-toggle marginnote-ind">{{ .Site.Params.marginNoteInd }}</label>
<input type="checkbox" id="{{ .Get "label" }}" class="margin-toggle"/>
<span class="marginnote">
{{ if eq $type "margin" }}
{{- else -}}<!-- child for margin or normal (begin) -->
{{- if or (or (.Get "caption") (.Get "attr")) (eq $type "margin") -}}<!-- begin marginnote -->
<label for="{{ $label }}" class="margin-toggle marginnote-ind">{{ .Site.Params.marginNoteInd }}</label>
<input type="checkbox" id="{{ $label }}" class="margin-toggle"/>
<span class="marginnote">
{{- end -}}
{{- if eq $type "margin" -}}<!-- margin image inside marginnote -->
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
<img src="{{ .Get "src" }}" alt="{{ $alt }}">
{{ if .Get "link" }}</a>{{ end }}
{{ end }}
{{ end }}
{{- end -}}
{{ with .Get "title"}}<strong>{{ . }} </strong>{{ end}}
{{ with .Get "caption"}}{{ . }}{{ end }}
{{ with .Get "attrlink"}}<a href="{{ .}}">{{ end }}
{{ with .Get "attr" }}{{ . }}{{ end }}
{{ if .Get "attrlink" }}</a>{{ end }}
{{- end -}}<!-- child for margin or normal (end) -->
<!-- end inner elements -->
{{ if eq $type "full" }}
{{ with .Get "title"}}<strong>{{ . | markdownify }}. </strong>{{ end}}
{{ with .Get "caption"}}{{ . | markdownify }}{{ end }}
{{ with .Get "attr" }}{{ . | markdownify }}.{{ end }}
<!-- end child elements -->
{{ if eq $type "full" }}<!-- end full -->
</figcaption>
{{ else }}
</span>
{{ else }}<!-- end margin or normal -->
{{- if or (or (.Get "caption") (.Get "attr")) (eq $type "margin") -}}</span>{{- end -}}<!-- end marginnote -->
{{ end }}
{{ if ( eq $type "normal" ) }}
{{ if (eq $type "normal") }}
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
<img src="{{ .Get "src" }}" alt="{{ $alt }}">
{{ if .Get "link" }}</a>{{ end }}
{{ end }}

View file

@ -1,7 +1,7 @@
{{- $marginnoteDomIdSuffix := (add .Ordinal 1) -}}
{{- $label := (add .Ordinal 1) -}}
{{- $ind := .Get "ind" | default .Site.Params.marginNoteInd -}}
<label for="marginnote-{{ $marginnoteDomIdSuffix }}" class="margin-toggle marginnote-ind">{{ $ind }}</label>
<input type="checkbox" id="marginnote-{{ $marginnoteDomIdSuffix }}" class="margin-toggle"/>
<label for="marginnote-{{ $label }}" class="margin-toggle marginnote-ind">{{ $ind }}</label>
<input type="checkbox" id="marginnote-{{ $label }}" class="margin-toggle"/>
<span class="marginnote">
{{ .Inner | markdownify}}
</span>

View file

@ -3,9 +3,9 @@
{{- else -}}
{{- $.Page.Scratch.Set "sidenoteCounter" 1 -}}
{{- end -}}
{{- $sidenoteDomIdSuffix := $.Page.Scratch.Get "sidenoteCounter" -}}
<label for="sidenote-{{ $sidenoteDomIdSuffix }}" class="margin-toggle sidenote-number">({{ $sidenoteDomIdSuffix }})</label>
<input type="checkbox" id="sidenote-{{ $sidenoteDomIdSuffix }}" class="margin-toggle"/>
{{- $label := $.Page.Scratch.Get "sidenoteCounter" -}}
<label for="sidenote-{{ $label }}" class="margin-toggle sidenote-number">({{ $label }})</label>
<input type="checkbox" id="sidenote-{{ $label }}" class="margin-toggle"/>
<span class="sidenote">
<span class="sidenote-number">({{ $sidenoteDomIdSuffix }})</span>{{ .Inner | markdownify }}
<span class="sidenote-number">({{ $label }})</span>{{ .Inner | markdownify }}
</span>