This commit is contained in:
Simon Gardling
2023-10-11 17:38:05 -04:00
commit 032679b34a
242 changed files with 9311 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<div class="balloon-card-item">
<div class="balloon-card-item-line">
{{ partial "balloon/line.html" false }}
{{ partial "balloon/dot.html" }}
{{ partial "balloon/line.html" .last_item }}
</div>
<div class="balloon-card-item-content">
{{- partial "content.html" (dict "ctx" .ctx "content" .ctx.Content) -}}
</div>
</div>

View File

@@ -0,0 +1 @@
<div class="balloon-dot"></div>

View File

@@ -0,0 +1,29 @@
{{ $img := .Params.balloon_img_src | default .Params.balloon_img_src_dark }}
{{ $img_dark := .Params.balloon_img_src_dark | default .Params.balloon_img_src }}
{{ $balloon_circle := .Params.balloon_circle | default true }}
<div class="balloon-head-item">
{{/* For desktop layout */}}
<div class="balloon-head-item-desktop">
<div class="balloon-head-item-img-light">
{{ partial "balloon/head/desktop.html" (dict "img" $img "balloon_circle" $balloon_circle) }}
</div>
<div class="balloon-head-item-img-dark">
{{ partial "balloon/head/desktop.html" (dict "img" $img_dark "balloon_circle" $balloon_circle ) }}
</div>
{{ partial "balloon/line.html" false }}
</div>
{{/* For mobile layout */}}
<div class="balloon-head-item-mobile">
<div class="balloon-head-item-img-light">
{{ partial "balloon/head/mobile.html" (dict "img" $img "balloon_circle" $balloon_circle) }}
</div>
<div class="balloon-head-item-img-dark">
{{ partial "balloon/head/mobile.html" (dict "img" $img_dark "balloon_circle" $balloon_circle ) }}
</div>
</div>
<div class="balloon-head-item-content">
{{- partial "content.html" (dict "ctx" . "content" .Content) -}}
</div>
</div>

View File

@@ -0,0 +1,7 @@
{{ if .img }}
<div class="balloon-head-item-img">
<img alt="balloon_head" src='{{- .img | absURL -}}' {{ if .balloon_circle }}class="rounded"{{ end }}>
</div>
{{ else }}
{{ partial "balloon/dot.html" }}
{{ end }}

View File

@@ -0,0 +1,5 @@
{{ if .img }}
<div class="balloon-head-item-img">
<img alt="balloon_head" src='{{- .img | absURL -}}' {{ if .balloon_circle }}class="rounded"{{ end }}>
</div>
{{ end }}

View File

@@ -0,0 +1,21 @@
{{ if .Params.balloon_resources }}
<div class="balloon-layout">
{{ partial "balloon/head-item.html" . }}
{{ $res := .Site.GetPage .Params.balloon_resources }}
{{ $pages := $res.Resources.ByType "page" }}
{{ if $pages }}
{{ $max_idx := sub (len $pages) 1 }}
{{ range $index, $value := (sort $pages "Params.weight" "asc") }}
{{ partial "balloon/title-item.html" . }}
{{ partial "balloon/card-item.html" (dict "ctx" . "last_item" (eq $index $max_idx)) }}
{{ end }}
{{ else }}
<span>{{ i18n "no_page_under_resouces" (dict "resources_name" "balloon_resources" "resources_path" .Params.balloon_resources ) }}</span>
{{ end }}
</div>
{{ else }}
<span>{{ i18n "resources_not_found" (dict "resources_name" "balloon_resources")}}</span>
{{ end }}

View File

@@ -0,0 +1,6 @@
{{ $last_item := . }}
<div class="balloon-line-container">
{{ if not $last_item }}
<div class="balloon-line" style="width: 2px"></div>
{{ end }}
</div>

View File

@@ -0,0 +1,6 @@
<div class="balloon-title-item">
<div class="balloon-title-item-line">
{{ partial "balloon/line.html" false }}
</div>
<h5 class="balloon-title-item-content">{{ .Title }}</h5>
</div>

View File

@@ -0,0 +1,14 @@
{{ $cover_src := .Params.bookcase_cover_src | default .Params.bookcase_cover_src_dark }}
{{ $cover_src_dark := .Params.bookcase_cover_src_dark | default .Params.bookcase_cover_src }}
{{ $cover_title := .Params.bookcase_cover_title | default .Title }}
<div class="bookcase-item">
<figure>
<img src="{{ $cover_src | absURL }}" class="bookcase-item-img-light">
<img src="{{ $cover_src_dark | absURL }}" class="bookcase-item-img-dark">
<a href="{{ .RelPermalink }}" class="bookcase-item-overlay"></a>
</figure>
<figcaption>
<a href="{{ .RelPermalink }}">{{ $cover_title }}</a>
</figcaption>
</div>

View File

@@ -0,0 +1,24 @@
{{ $ctx := .ctx }}
{{ $title := .title }}
{{ $content := .content }}
{{ $res := .res }}
<div class="content-margin">
<div class="my-8">
<h1>{{ $title }}</h1>
{{ if $content }}
{{- partial "content.html" (dict "ctx" $ctx "content" $content) -}}
{{ end }}
</div>
{{ with $res }}
<div class="bookcase-layout content-margin">
{{ range . }}
{{ $hidden := .Params.bookcase_hidden | default false }}
{{ if not $hidden -}}
{{- partial "bookcase/item.html" . -}}
{{- end }}
{{ end }}
</div>
{{ end }}
</div>

View File

@@ -0,0 +1,39 @@
{{- if .enable -}}
<details class="collapsible-menu-wrapper">
{{- else -}}
<div class="collapsible-menu-wrapper">
{{- end -}}
{{- if .enable -}}
<summary class="collapsible-menu-type">
{{- else -}}
<div class="collapsible-menu-type">
{{- end -}}
<span>{{ i18n .type }}</span>
{{- if .enable -}}
</summary>
{{- else -}}
</div>
{{- end -}}
<div class="collapsible-menu">
{{ if eq .type "changelogs" }}
<article id="collapsible_menu_changelogs">
{{ range $log := .context.Params.changelogs }}
<div>{{ $log.tag | markdownify }}</div>
<div>
{{ range $log.description }}
<div>{{ . | markdownify }}</div>
{{ end }}
</div>
{{ end }}
</article>
{{ else if eq .type "toc" }}
{{ .context.TableOfContents }}
{{ end }}
</div>
{{- if .enable -}}
</details>
{{- else -}}
</div>
{{- end -}}

View File

@@ -0,0 +1,12 @@
{{ $ctx := .ctx }}
{{ $content := .content }}
{{ $enable_line_no := ($ctx.Scratch.Get "params").syntax_highlight.prism.enable_line_no | default true }}
<article {{ if $enable_line_no }}class="line-numbers"{{ end }}>
{{ $content := $content | replaceRE "<table>" "<table class=\"mc-table\">" }}
{{ if eq ($ctx.Scratch.Get "params").syntax_highlight.lib "prism.js" }}
{{ $content = $content | replaceRE "<pre>" "<pre class=\"language-text\">" }}
{{ $content = $content | replaceRE "<pre([^>]*)class=\"([^>]*)\"([^>]*)>" "<pre$1 class=\"mc-prism hide $2\" $3>" }}
{{ end }}
{{ $content | safeHTML }}
</article>

View File

@@ -0,0 +1,3 @@
<div class="content-margin">
{{ template "_internal/disqus.html" . }}
</div>

View File

@@ -0,0 +1,7 @@
{{ with (.Scratch.Get "params").footer }}
<footer>
<article>
{{- . | safeHTML -}}
</article>
</footer>
{{ end }}

View File

@@ -0,0 +1,65 @@
{{ if .Content }}
<div class="content-margin">
{{- partial "content.html" (dict "ctx" . "content" .Content) -}}
</div>
{{ end }}
{{ if .Params.gallery_resources }}
{{ $res := .Site.GetPage .Params.gallery_resources }}
{{ $pages := $res.Resources.ByType "page" }}
{{ if $pages }}
<div class="content-margin gallery-layout">
{{ $max_idx := sub (len $pages) 1 }}
{{ range $index, $value := (sort $pages "Params.weight" "asc") }}
<div class="gallery-item">
{{ $title_link := .Params.gallery_title_link }}
{{ $img_link := .Params.gallery_img_link }}
{{ if .Params.gallery_img_src }}
<figure>
{{ if $img_link }}<a target="_blank" rel="noopener" href="{{ $img_link }}">{{ end }}
<img src="{{ .Params.gallery_img_src | absURL }}" alt="{{ .Title }}">
{{ if $img_link }}</a>{{ end }}
{{ with .Params.gallery_img_caption }}
<figcaption>
<article>
{{ . | safeHTML }}
</article>
</figcaption>
{{ end }}
</figure>
{{ end }}
{{ if .Title }}
<div class="gallery-item-title">
{{ if $title_link }}<a target="_blank" rel="noopener" href="{{ $title_link }}">{{ end }}
<span>{{- .Title -}}</span>
{{ if $title_link }}</a>{{ end }}
</div>
{{ end }}
{{ if .Content }}
<div class="gallery-item-content">
{{- partial "content.html" (dict "ctx" . "content" .Content) -}}
</div>
{{ end }}
{{ if .Params.gallery_statistic }}
<article class="gallery-item-statistic">
{{ range $stat := .Params.gallery_statistic }}
<div>{{ $stat.key | markdownify }}</div>
<div>{{ $stat.value | markdownify }}</div>
{{ end }}
</article>
{{ end }}
</div>
{{ end }}
</div>
{{ else }}
<span>{{ i18n "no_page_under_resouces" (dict "resources_name" "gallery_resources" "resources_path" .Params.gallery_resources ) }}</span>
{{ end }}
{{ else }}
<span>{{ i18n "resources_not_found" (dict "resources_name" "gallery_resources")}}</span>
{{ end }}

View File

@@ -0,0 +1,64 @@
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href='{{ "favicon.ico" | absURL }}' type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
{{- if eq .Kind "home" -}}
{{- print .Site.Title -}}
{{- else if eq .Kind "section" -}}
{{- print .CurrentSection.Title " - " .Site.Title }}
{{- else -}}
{{- print .Title " - " .Site.Title -}}
{{- end -}}
</title>
{{ with .Description }}
<meta name="description" content="{{ . }}" />
{{ end }}
{{ with .Keywords }}
<meta name="keywords" content="{{ delimit . "," }}" />
{{ end }}
{{ with (.Scratch.Get "params").author }}
<meta name="author" content="{{ . }}" />
{{ end }}
{{ if (.Scratch.Get "params").enable_open_graph }}
{{ template "_internal/opengraph.html" . }}
{{ end }}
{{ if (.Scratch.Get "params").enable_twitter_cards }}
{{ template "_internal/twitter_cards.html" . }}
{{ end }}
{{- partial "resources/css.html" . -}}
{{ if (.Scratch.Get "params").ga_code }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{/* Dark theme: inline in `head` to avoid FOUC */}}
<script>
if (!('theme' in localStorage)) {
{{ $color_scheme := (.Scratch.Get "params").color_scheme -}}
{{- if eq $color_scheme "light" -}}
localStorage.theme = 'light';
{{- else if eq $color_scheme "dark" -}}
localStorage.theme = 'dark';
{{- end }}
}
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.setAttribute("data-theme", "dark");
} else {
document.documentElement.setAttribute("data-theme", "light");
}
</script>
{{- partial "resources/js.html" . -}}
{{ if fileExists "/static/user.css" -}}
<link rel="stylesheet" href="{{ urls.JoinPath .Site.BaseURL "user.css" }}">
{{- end }}
</head>

View File

@@ -0,0 +1,59 @@
<header>
<div class="brand">
<div id="sidebar_btn">
<svg id="menu_icon" width="26px" height="26px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "menu" -}}
</svg>
</div>
<div>
<a href="{{ .Site.Home.RelPermalink }}">
{{- with (.Scratch.Get "params").navbar_title }}
{{- . | safeHTML -}}
{{- end -}}
</a>
</div>
</div>
<div class="toolbox">
<div id="theme_tool">
<svg id="dark_mode_btn" class="toolbox-btn" width="18px" height="18px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "sun" -}}
</svg>
<svg id="light_mode_btn" class="toolbox-btn" width="18px" height="18px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "moon" -}}
</svg>
</div>
{{ if (.Scratch.Get "params").enable_site_search }}
<div id="search_tool">
<svg id="search_btn" class="toolbox-btn" width="18px" height="18px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "search" -}}
</svg>
{{- partial "search-menu.html" -}}
</div>
{{ end }}
{{ if .Site.IsMultiLingual }}
<div id="translation_tool" class="dropdown-wrapper pure-menu pure-menu-horizontal toolbox-btn">
<ul class="pure-menu-list">
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
<div class="dropdown-btn pure-menu-link">
<svg width="18px" height="18px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "globe" -}}
</svg>
<span class="dropdown-desc">{{ .Site.Language.LanguageName }}</span>
</div>
<ul class="pure-menu-children">
{{ range .Site.Home.AllTranslations }}
<li class="pure-menu-item">
<a href="{{ .Permalink }}" class="pure-menu-link">{{ .Language.LanguageName }}</a>
</li>
{{ end }}
</ul>
</li>
</ul>
</div>
{{ end }}
</div>
</header>

View File

@@ -0,0 +1,27 @@
{{ $show_date := .show_date | default true }}
{{ $pages := .pages }}
{{ $group_by_year := .group_by_year | default true }}
{{- if $pages -}}
{{- if $show_date -}}
{{- $pages = $pages.ByPublishDate.Reverse -}}
{{- end -}}
<ul class="list-layout">
{{ range $pages }}
<li>
<a href="{{ .RelPermalink }}">
{{- .Title -}}
</a>
{{ if $show_date }}
<span>
{{ if $group_by_year }}
{{- .PublishDate.Format "01/02" -}}
{{ else }}
{{- .PublishDate.Format "2006/01/02" -}}
{{ end }}
</span>
{{ end }}
</li>
{{ end }}
</ul>
{{- end -}}

View File

@@ -0,0 +1,38 @@
<nav id="navbar" class="pure-menu">
{{- $currentPage := . -}}
{{- $currentUrl := .RelPermalink -}}
{{- $baseURL := .Site.BaseURL }}
<ul class="pure-menu-list">
{{- range .Site.Menus.navbar -}}
{{ $navbar_decoration := "" }}
{{- if $currentPage.IsMenuCurrent "navbar" . -}}
{{ $navbar_decoration = "active" }}
{{- else if eq $currentUrl .URL -}}
{{ $navbar_decoration = "active" }}
{{- else if and (in ($currentUrl|lower) (.URL|lower)) (ne (relURL .URL) (relURL $baseURL)) -}}
{{ $navbar_decoration = "insection" }}
{{- end -}}
{{- if .Children -}}
<li class="navbar-item navbar-dropdown pure-menu-item pure-menu-has-children pure-menu-allow-hover {{ $navbar_decoration }}">
{{ if .URL }}
<a href="{{ .URL }}" class="pure-menu-link">{{- .Name -}}</a>
{{ else }}
<div class="pure-menu-link">{{- .Name -}}</div>
{{ end }}
<ul class="pure-menu-children">
{{- partial "navbar/nested-desktop.html" . -}}
</ul>
</li>
{{- else -}}
<li class="navbar-item pure-menu-item {{ $navbar_decoration }}">
{{ if .URL }}
<a href="{{ .URL }}" class="pure-menu-link">{{- .Name -}}</a>
{{ else }}
<div class="pure-menu-link">{{- .Name -}}</div>
{{ end }}
</li>
{{- end -}}
{{- end -}}
</ul>
</nav>

View File

@@ -0,0 +1,22 @@
{{ range .Children }}
{{ if .Children }}
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
{{ if .URL }}
<a href="{{ .URL }}" class="pure-menu-link">{{- .Name -}}</a>
{{ else }}
<div class="pure-menu-link">{{- .Name -}}</div>
{{ end }}
<ul class="pure-menu-children">
{{- partial "navbar/nested-desktop.html" . -}}
</ul>
</li>
{{ else }}
<li class="pure-menu-item">
{{ if .URL }}
<a href="{{ .URL }}" class="pure-menu-link">{{- .Name -}}</a>
{{ else }}
<div class="pure-menu-link">{{- .Name -}}</div>
{{ end }}
</li>
{{ end }}
{{ end }}

View File

@@ -0,0 +1,28 @@
{{ with .Children }}
<ul>
{{ range . }}
{{ if .Children }}
<li>
<details>
<summary>
{{ if .URL }}
<span><a href="{{ .URL }}">{{- .Name -}}</a></span>
{{ else }}
<span>{{- .Name -}}</span>
{{ end }}
</summary>
{{- partial "navbar/nested-mobile.html" . -}}
</details>
</li>
{{ else }}
<li>
{{ if .URL }}
<a href="{{ .URL }}">{{- .Name -}}</a>
{{ else }}
<div>{{- .Name -}}</div>
{{ end }}
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}

View File

@@ -0,0 +1,38 @@
{{ $ctx := .ctx }}
{{ $pages := .pages }}
<div class="postcard-layout content-margin">
{{ range ($ctx.Paginator).Pages }}
<a href="{{ .Permalink }}">
<div class="postcard-item">
<div class="postcard-title">
<span>{{ .Title }}</span>
</div>
<div class="postcard-summary">
<span>{{ .Summary | plainify }}</span>
</div>
<div class="postcard-metadata">
<span>{{ .Date.Format "2006/01/02" }} · {{ template "breadcrumbtext" (dict "p1" .Page.Parent) }}</span>
</div>
</div>
</a>
{{ end }}
{{ template "_internal/pagination.html" $ctx }}
</div>
{{ define "breadcrumbtext" }}
{{ if .p1.Parent }}
{{ if not .p1.Parent.IsHome }}
{{ template "breadcrumbtext" (dict "p1" .p1.Parent) }}
{{ end }}
{{ end }}
{{ if .p1.Parent }}
{{ if .p1.Parent.IsHome }}
<span>{{ .p1.Title }}</span>
{{ else }}
<span>/</span>
<span>{{ .p1.Title }}</span>
{{ end }}
{{ end }}
{{ end }}

View File

@@ -0,0 +1,18 @@
{{- $styles := resources.Get "scss/core.scss" -}}
{{- if hugo.IsProduction -}}
{{- $tocss_opts := dict "targetPath" "style.css" "outputStyle" "compressed" "enableSourceMap" true -}}
{{- $styles = $styles | resources.ToCSS $tocss_opts | resources.Minify | resources.Fingerprint "sha512" -}}
{{- else -}}
{{- $tocss_opts := dict "targetPath" "style.css" "enableSourceMap" true -}}
{{- $styles = $styles | resources.ToCSS $tocss_opts -}}
{{- end -}}
<link rel="stylesheet" href="{{- $styles.RelPermalink -}}" integrity="{{- $styles.Data.Integrity -}}">
{{/* Prism.js style */}}
{{ if or (and (findRE "<pre" .Content 1) (eq (.Scratch.Get "params").syntax_highlight.lib "prism.js")) (.HasShortcode "emgithub") }}
{{ $prism_css := resources.Get "lib/css/prism.css" }}
{{- if hugo.IsProduction -}}
{{ $prism_css = $prism_css | resources.Minify | resources.Fingerprint "sha512" -}}
{{- end -}}
<link rel="stylesheet" href="{{- $prism_css.RelPermalink -}}" integrity="{{- $prism_css.Data.Integrity -}}">
{{ end }}

View File

@@ -0,0 +1,95 @@
{{/* Header */}}
{{ $header_js := resources.Get "js/header.js" }}
{{- if hugo.IsProduction -}}
{{ $header_js = $header_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $header_js = $header_js | js.Build -}}
{{- end -}}
<script defer src="{{ $header_js.RelPermalink }}" integrity="{{- $header_js.Data.Integrity -}}"></script>
{{/* Zooming.js */}}
{{ if (.Scratch.Get "params").enable_zooming_js }}
{{ $zooming_js := resources.Get "js/zooming.js" }}
{{- if hugo.IsProduction -}}
{{ $zooming_js = $zooming_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $zooming_js = $zooming_js | js.Build -}}
{{- end -}}
<script defer src="{{ $zooming_js.RelPermalink }}" integrity="{{- $zooming_js.Data.Integrity -}}"></script>
{{ end }}
{{/* MathJax */}}
{{ if (.Scratch.Get "params").math }}
{{ $math_js := resources.Get "js/math.js" }}
{{- if hugo.IsProduction -}}
{{ $math_js = $math_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $math_js = $math_js | js.Build -}}
{{- end -}}
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script defer src="{{ $math_js.RelPermalink }}" integrity="{{- $math_js.Data.Integrity -}}"></script>
{{ end }}
{{/* Load script for only page contain codeblock */}}
{{ if (findRE "<pre" .Content 1) }}
{{ if eq (.Scratch.Get "params").syntax_highlight.lib "builtin" }}
{{ $enable_code_copy := (.Scratch.Get "params").syntax_highlight.builtin.enable_code_copy | default true }}
{{ if $enable_code_copy }}
{{ $code_copy_js := resources.Get "js/builtin-copy.js" }}
{{- if hugo.IsProduction -}}
{{ $code_copy_js = $code_copy_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $code_copy_js = $code_copy_js | js.Build -}}
{{- end -}}
<script defer src="{{ $code_copy_js.RelPermalink }}" integrity="{{- $code_copy_js.Data.Integrity -}}"></script>
{{ end }}
{{ else if eq (.Scratch.Get "params").syntax_highlight.lib "prism.js" }}
{{ $prism_js := slice (resources.Get "lib/js/prism-v1.29.0.min.js") }}
{{ $enable_line_no := (.Scratch.Get "params").syntax_highlight.prism.enable_line_no | default true }}
{{ if $enable_line_no }}
{{ $prism_js = $prism_js | append (resources.Get "lib/js/prism-line-numbers-v1.29.0.min.js") }}
{{ end }}
{{ $enable_code_copy := (.Scratch.Get "params").syntax_highlight.prism.enable_code_copy | default true }}
{{ if $enable_code_copy }}
{{ $prism_js = $prism_js | append (resources.Get "lib/js/prism-copy-to-clipboard-v1.29.0.min.js") }}
{{ end }}
{{ $prism_js = $prism_js | append (resources.Get "js/prism-autoloader.js") | append (resources.Get "js/prism.js") | resources.Concat "js/prism.js" }}
{{- if hugo.IsProduction -}}
{{ $prism_js = $prism_js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $prism_js = $prism_js | js.Build -}}
{{- end -}}
<script defer src="{{ $prism_js.RelPermalink }}" integrity="{{- $prism_js.Data.Integrity -}}" data-manual></script>
{{ end }}
{{ end }}
{{ if (.Scratch.Get "params").enable_site_search }}
{{ $target_path := printf "js/search-%s.js" .Site.LanguageCode }}
{{ $index_url := "index.json" | absLangURL }}
{{ $build_opts := dict "targetPath" $target_path "params" (dict "index_url" $index_url) }}
{{ $search_js := resources.Get "js/search.js" | js.Build $build_opts }}
{{- if hugo.IsProduction -}}
{{ $search_js = $search_js | js.Build (merge $build_opts (dict "minify" true)) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $search_js = $search_js | js.Build $build_opts -}}
{{- end -}}
<script defer src="{{ $search_js.RelPermalink }}" integrity="{{- $search_js.Data.Integrity -}}"></script>
{{ end }}
{{/* Load highlighter for emgithub */}}
{{ if .HasShortcode "emgithub" }}
{{ $js := slice (resources.Get "lib/js/prism-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "lib/js/prism-line-numbers-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "lib/js/prism-copy-to-clipboard-v1.29.0.min.js") }}
{{ $js = $js | append (resources.Get "js/prism-autoloader.js") }}
{{ $js = $js | resources.Concat "js/emgithub-prism.js" }}
{{- if hugo.IsProduction -}}
{{ $js = $js | js.Build (dict "minify" true) | resources.Fingerprint "sha512" -}}
{{- else -}}
{{ $js = $js | js.Build }}
{{- end -}}
<script defer src="{{ $js.RelPermalink }}" integrity="{{- $js.Data.Integrity -}}" data-manual></script>
{{ end }}

View File

@@ -0,0 +1,16 @@
<div id="search_menu_wrapper" class="hidden">
<div id="search_menu">
<div id="search_menu_toolbar">
<div id="search_menu_input_wrapper">
<input id="search_menu_input" type="text" placeholder='{{ i18n "search" }}'>
</div>
<div id="search_menu_close_btn">
<svg width="18px" height="18px" viewBox="0 0 24 24">
{{- partial "svg/feather.html" "x" -}}
</svg>
</div>
</div>
<div id="search_menu_results">
</div>
</div>
</div>

View File

@@ -0,0 +1,19 @@
<div id="sidebar_canvas_overlay" class="hidden"></div>
<div id="sidebar" class="close">
<ul>
{{- range .Site.Menus.navbar -}}
{{- if .Children -}}
<li>
<details>
<summary><a href="{{ .URL }}">{{- .Name -}}</a></summary>
{{- partial "navbar/nested-mobile.html" . -}}
</details>
</li>
{{- else -}}
<li>
<a href="{{ .URL }}">{{- .Name -}}</a>
</li>
{{- end -}}
{{- end -}}
</ul>
</div>

View File

@@ -0,0 +1,12 @@
{{- $icon_name := . -}}
{{- $feather_sprite := resources.Get "lib/icns/feather-sprite-v4.29.0.svg" -}}
{{- $regex := printf `<symbol id="%s".*?>(.*?)<\/symbol>` $icon_name -}}
{{- $path := index (index (findRESubmatch $regex $feather_sprite.Content) 0) 1 | safeHTML }}
<svg
xmlns="http://www.w3.org/2000/svg"
width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
{{ $path }}
</svg>

View File

@@ -0,0 +1,26 @@
{{ if . }}
{{ $fontSmall := 1 }}
{{ $fontBig := 1.6 }}
{{ $fontSpread := sub $fontBig $fontSmall }}
{{ $termCount := slice }}
{{ range . }}
{{ $termCount = append .Count $termCount }}
{{ end }}
{{ $termCount = sort $termCount }}
{{ $min := int (index $termCount 0) }}
{{ $max := add (int (index $termCount (sub (len $termCount) 1))) 1 }}
<div>
{{ range . }}
{{ $weight := div (sub (math.Log .Count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
{{ $fontSize := (add $fontSmall (mul $fontSpread $weight)) }}
<a class="term-item" href="{{ .Page.RelPermalink }}">
<span style="font-size:{{ $fontSize }}rem">{{- .Page.Title -}}</span>
<span style="font-size:{{ sub $fontSmall 0.2 }}rem"> ({{- .Count -}}) </span>
</a>
{{ end }}
</div>
{{ end }}