First commit
Some checks failed
Blowfish Docs Deploy / build (push) Has been cancelled
Blowfish Docs Deploy / deploy (push) Has been cancelled
Test Build / Build Example Site (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Update Hugo version / updateBlowfish (push) Has been cancelled
Some checks failed
Blowfish Docs Deploy / build (push) Has been cancelled
Blowfish Docs Deploy / deploy (push) Has been cancelled
Test Build / Build Example Site (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Update Hugo version / updateBlowfish (push) Has been cancelled
Delete exampleSite Add initial content, images & docker-compose.yml Use extend-head.html for analytics Set remote url to gitea.novicelab.io Remove original .git due to "shallow update not allowed" error
This commit is contained in:
93
layouts/_default/_markup/render-blockquote.html
Normal file
93
layouts/_default/_markup/render-blockquote.html
Normal file
@@ -0,0 +1,93 @@
|
||||
{{- /* To customize your own admonitions, you can do the following:
|
||||
|
||||
1. Change colors
|
||||
|
||||
Define your colors in `assets/css/custom.css` using the variables from:
|
||||
https://github.com/nunocoracao/blowfish/blob/main/assets/css/components/admonition.css
|
||||
|
||||
Example:
|
||||
```
|
||||
:root {
|
||||
--adm-note-bg: red;
|
||||
}
|
||||
html.dark {
|
||||
--adm-note-bg: green;
|
||||
}
|
||||
```
|
||||
|
||||
This will update the background color for light and dark mode.
|
||||
|
||||
2. Change icons and type settings
|
||||
|
||||
You can override the default type and icon mappings by creating your own
|
||||
`impls/hooks/admonition-maps.html` in your `layouts` folder.
|
||||
This allows you to assign different icons or styles for each admonition type.
|
||||
*/ -}}
|
||||
|
||||
{{- if eq .Type "alert" -}}
|
||||
{{- $maps := partialCached "impls/hooks/admonition-maps.html" . -}}
|
||||
{{- $typeMap := $maps.typeMap -}}
|
||||
{{- $iconMap := $maps.iconMap -}}
|
||||
|
||||
{{- $rawType := .AlertType | lower -}}
|
||||
{{- $normalizedType := index $typeMap $rawType | default $rawType -}}
|
||||
{{- $iconName := .Attributes.icon | default (index $iconMap $normalizedType) | default "circle-info" -}}
|
||||
|
||||
{{- $admonitionTitle := .AlertTitle | default ((i18n (printf "admonition.%s" $normalizedType) | default $normalizedType) | title) -}}
|
||||
|
||||
{{- $containerClass := "admonition relative overflow-hidden rounded-lg border-l-4 my-3 px-4 py-3 shadow-sm" -}}
|
||||
{{- $headerClass := "flex items-center gap-2 font-semibold text-inherit" -}}
|
||||
{{- $contentClass := "admonition-content mt-3 text-base leading-relaxed text-inherit" -}}
|
||||
|
||||
{{- $isCollapsible := in (slice "+" "-") .AlertSign -}}
|
||||
{{- if $isCollapsible -}}
|
||||
<details
|
||||
class="{{ $containerClass }} group"
|
||||
data-type="{{ $normalizedType }}"
|
||||
{{ if eq .AlertSign "+" }}open{{ end }}>
|
||||
<summary class="{{ $headerClass }} cursor-pointer">
|
||||
<div class="flex shrink-0 h-5 w-5 items-center justify-center text-lg">
|
||||
{{- partial "icon.html" $iconName -}}
|
||||
</div>
|
||||
<div class="grow">
|
||||
{{ $admonitionTitle }}
|
||||
</div>
|
||||
<div
|
||||
class="ms-auto flex h-5 w-5 items-center justify-center transition-transform ease-in-out -rotate-90 group-open:rotate-0 print:hidden">
|
||||
{{- partial "icon.html" "chevron-down" -}}
|
||||
</div>
|
||||
</summary>
|
||||
{{- if .Text -}}
|
||||
<div class="{{ $contentClass }}">
|
||||
{{- .Text | safeHTML -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</details>
|
||||
{{- else -}}
|
||||
<div class="{{ $containerClass }}" data-type="{{ $normalizedType }}">
|
||||
<div class="{{ $headerClass }}">
|
||||
<div class="flex shrink-0 h-5 w-5 items-center justify-center text-lg">
|
||||
{{- partial "icon.html" $iconName -}}
|
||||
</div>
|
||||
<div class="grow">
|
||||
{{ $admonitionTitle }}
|
||||
</div>
|
||||
</div>
|
||||
{{- if .Text -}}
|
||||
<div class="{{ $contentClass }}">
|
||||
{{- .Text | safeHTML -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- else -}}
|
||||
<blockquote
|
||||
{{- range $k, $v := .Attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
{{- .Text | safeHTML -}}
|
||||
</blockquote>
|
||||
{{- end -}}
|
||||
10
layouts/_default/_markup/render-codeblock.html
Normal file
10
layouts/_default/_markup/render-codeblock.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{{- $title := or .Attributes.title "" -}}
|
||||
{{- $lang := or .Type "text" -}}
|
||||
<div class="highlight-wrapper">
|
||||
{{- with $title -}}
|
||||
<div class="codeblock-title">
|
||||
{{- $title -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- transform.Highlight .Inner $lang .Options -}}
|
||||
</div>
|
||||
10
layouts/_default/_markup/render-heading.html
Normal file
10
layouts/_default/_markup/render-heading.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{{ $anchor := anchorize .Anchor }}
|
||||
<h{{ .Level }} class="relative group">{{ .Text | safeHTML }}
|
||||
<div id="{{ $anchor }}" class="anchor"></div>
|
||||
{{ if .Page.Params.showHeadingAnchors | default (.Page.Site.Params.article.showHeadingAnchors | default true) }}
|
||||
<span
|
||||
class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
|
||||
<a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#{{ $anchor }}" aria-label="{{ i18n "article.anchor_label" }}">#</a>
|
||||
</span>
|
||||
{{ end }}
|
||||
</h{{ .Level }}>
|
||||
114
layouts/_default/_markup/render-image.html
Normal file
114
layouts/_default/_markup/render-image.html
Normal file
@@ -0,0 +1,114 @@
|
||||
{{- define "RenderImageSimple" -}}
|
||||
{{- $imgObj := .imgObj -}}
|
||||
{{- $src := .src -}}
|
||||
{{- $alt := .alt -}}
|
||||
<img
|
||||
class="my-0 rounded-md"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"
|
||||
alt="{{ $alt }}"
|
||||
src="{{ $src }}"
|
||||
{{ with $imgObj -}}
|
||||
{{ with $imgObj.Width }}width="{{ . }}"{{ end }}
|
||||
{{ with $imgObj.Height }}height="{{ . }}"{{ end }}
|
||||
{{- end }}>
|
||||
{{- end -}}
|
||||
|
||||
{{- define "RenderImageResponsive" -}}
|
||||
{{/* Responsive Image
|
||||
The current setting sizes="(min-width: 768px) 50vw, 65vw" makes the iPhone 16 and 16 Pro
|
||||
select a smaller image, while the iPhone 16 Pro Max selects a larger image.
|
||||
|
||||
Steps:
|
||||
1. Check the media queries in the `sizes` property.
|
||||
2. Find the first matching value. For example, on a mobile device with a CSS pixel width
|
||||
of 390px and DPR = 3 (iPhone 13), given setting sizes="(min-width: 768px) 50vw, 100vw",
|
||||
it matches the `100vw` option.
|
||||
3. Calculate the optimal image size: 390 × 3 × 100% (100vw) = 1170.
|
||||
4. Find the corresponding match in the `srcset`.
|
||||
|
||||
To make the browser select a smaller image on mobile devices
|
||||
override the template and change the `sizes` property to "(min-width: 768px) 50vw, 30vw"
|
||||
|
||||
The sizes="auto" is valid only when loading="lazy".
|
||||
*/}}
|
||||
{{- $imgObj := .imgObj -}}
|
||||
{{- $alt := .alt -}}
|
||||
{{- $originalWidth := $imgObj.Width -}}
|
||||
|
||||
{{- $img800 := $imgObj -}}
|
||||
{{- $img1280 := $imgObj -}}
|
||||
{{- if gt $originalWidth 800 -}}
|
||||
{{- $img800 = $imgObj.Resize "800x" -}}
|
||||
{{- end -}}
|
||||
{{- if gt $originalWidth 1280 -}}
|
||||
{{- $img1280 = $imgObj.Resize "1280x" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $srcset := printf "%s 800w, %s 1280w" $img800.RelPermalink $img1280.RelPermalink -}}
|
||||
|
||||
|
||||
<img
|
||||
class="my-0 rounded-md"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="auto"
|
||||
alt="{{ $alt }}"
|
||||
{{ with $imgObj.Width }}width="{{ . }}"{{ end }}
|
||||
{{ with $imgObj.Height }}height="{{ . }}"{{ end }}
|
||||
src="{{ $img800.RelPermalink }}"
|
||||
srcset="{{ $srcset }}"
|
||||
sizes="(min-width: 768px) 50vw, 65vw"
|
||||
data-zoom-src="{{ $imgObj.RelPermalink }}">
|
||||
{{- end -}}
|
||||
|
||||
{{- define "RenderImageCaption" -}}
|
||||
{{- with .caption -}}
|
||||
<figcaption>{{ . | markdownify }}</figcaption>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $disableImageOptimizationMD := .Page.Site.Params.disableImageOptimizationMD | default false -}}
|
||||
{{- $urlStr := .Destination | safeURL -}}
|
||||
{{- $url := urls.Parse $urlStr -}}
|
||||
{{- $altText := .Text -}}
|
||||
{{- $caption := .Title -}}
|
||||
{{- $isRemote := findRE "^(https?|data)" $url.Scheme -}}
|
||||
{{- $resource := "" -}}
|
||||
|
||||
{{- if not $isRemote -}}
|
||||
{{- $resource = or ($.Page.Resources.GetMatch $urlStr) (resources.Get $urlStr) -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
<figure
|
||||
{{- range $k, $v := .Attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
{{- if $isRemote -}}
|
||||
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $urlStr "alt" $altText) -}}
|
||||
{{- else if $resource -}}
|
||||
{{- $isSVG := eq $resource.MediaType.SubType "svg" -}}
|
||||
{{- $shouldOptimize := and (not $disableImageOptimizationMD) (not $isSVG) -}}
|
||||
{{- if $shouldOptimize -}}
|
||||
{{- template "RenderImageResponsive" (dict "imgObj" $resource "alt" $altText) -}}
|
||||
{{- else -}}
|
||||
{{/* Not optimize image
|
||||
If it is an SVG file, pass the permalink
|
||||
Otherwise, pass the resource to allow width and height attributes
|
||||
*/}}
|
||||
{{- if $isSVG -}}
|
||||
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $resource.RelPermalink "alt" $altText) -}}
|
||||
{{- else -}}
|
||||
{{- template "RenderImageSimple" (dict "imgObj" $resource "src" $resource.RelPermalink "alt" $altText) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- template "RenderImageSimple" (dict "imgObj" "" "src" $urlStr "alt" $altText) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- template "RenderImageCaption" (dict "caption" $caption) -}}
|
||||
</figure>
|
||||
38
layouts/_default/_markup/render-link.html
Normal file
38
layouts/_default/_markup/render-link.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{{/* From Hugo, Apache v2 license
|
||||
https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-link.html
|
||||
*/}}
|
||||
{{- $u := urls.Parse .Destination -}}
|
||||
{{- $href := $u.String -}}
|
||||
{{- if strings.HasPrefix $u.String "#" -}}
|
||||
{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment -}}
|
||||
{{- else if and $href (not $u.IsAbs) -}}
|
||||
{{- $path := strings.TrimPrefix "./" $u.Path -}}
|
||||
{{- with or
|
||||
($.PageInner.GetPage $path)
|
||||
($.PageInner.Resources.Get $path)
|
||||
(resources.Get $path)
|
||||
-}}
|
||||
{{- $href = .RelPermalink -}}
|
||||
{{- with $u.RawQuery -}}
|
||||
{{- $href = printf "%s?%s" $href . -}}
|
||||
{{- end -}}
|
||||
{{- with $u.Fragment -}}
|
||||
{{- $href = printf "%s#%s" $href . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Open external links in a new tab if
|
||||
configured to do so by the page param externalLinkForceNewTab
|
||||
or site param article.externalLinkForceNewTab
|
||||
and the link starts with http: or https:
|
||||
*/}}
|
||||
{{- $forceNewTab := .Page.Params.externalLinkForceNewTab | default (.Page.Site.Params.article.externalLinkForceNewTab | default true) -}}
|
||||
{{- $isExternal := or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") -}}
|
||||
{{- $newTab := and $forceNewTab $isExternal -}}
|
||||
|
||||
<a href="{{ $href }}" {{ with .Title }}title="{{ . }}"{{ end }}
|
||||
{{- if $newTab }} target="_blank" rel="noreferrer"{{ end }}>
|
||||
{{- .Text | safeHTML -}}
|
||||
</a>
|
||||
{{- /* Trim EOF */ -}}
|
||||
Reference in New Issue
Block a user