Merged main.

This commit is contained in:
donfiguerres 2022-01-17 16:08:20 +08:00
commit 106642ab1a
79 changed files with 1786 additions and 899 deletions

View file

@ -6,14 +6,14 @@
<div class="dropdown languageSelector">
<a class="btn dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ $countryCode := partial "helpers/country-code.html" . }}
<img class="flag" src="https://www.countryflags.io/{{ $countryCode }}/flat/16.png" alt="{{ $countryCode }}">
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
{{ site.Language.LanguageName }}
</a>
<div class="dropdown-menu" aria-labelledby="languageSelector">
{{ range .Translations }}
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang "en") "" .Language.Lang) $pageURL }}">
{{ $countryCode := partial "helpers/country-code.html" . }}
<img class="flag" src="https://www.countryflags.io/{{ $countryCode }}/flat/24.png" alt="{{ $countryCode }}">
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
{{ .Language.LanguageName }}
</a>
{{ end }}

View file

@ -1,28 +1,31 @@
{{/* default logos */}}
{{ $mainLogo := "/images/main-logo.png" }}
{{ $invertedLogo := "/images/inverted-logo.png" }}
{{/* by default, don't use any logo */}}
{{ $mainLogo := "" }}
{{ $invertedLogo := "" }}
{{/* if custom logo has been provided in the config file, then use them */}}
{{/* if custom logo has been provided, use them */}}
{{ if site.Params.logo.main }}
{{ $mainLogo = site.Params.logo.main }}
{{ end }}
{{ if site.Params.logo.inverted }}
{{ $invertedLogo = site.Params.logo.inverted }}
{{ end }}
{{/* resize the logos. don't resize svg because it is not supported */}}
{{ $mainLogo := resources.Get $mainLogo}}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ if $mainLogo }}
{{ $mainLogo = resources.Get $mainLogo}}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ $invertedLogo := resources.Get $invertedLogo}}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg") }}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ if $invertedLogo }}
{{ $invertedLogo = resources.Get $invertedLogo}}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
<nav class="navbar navbar-expand-xl top-navbar final-navbar shadow">
<div class="container">
@ -30,7 +33,9 @@
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
<img src="{{ $mainLogo }}" alt="Logo">
{{ if $mainLogo }}
<img src="{{ $mainLogo }}" alt="Logo">
{{ end }}
{{- site.Title -}}
</a>
<button class="navbar-toggler navbar-light" id="toc-toggler" type="button" onclick="toggleTOC()">
@ -46,6 +51,10 @@
</div>
</div>
<!-- Store the logo information in a hidden img for the JS -->
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ if $mainLogo }}
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
{{ end }}
{{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ end }}
</nav>

View file

@ -1,17 +1,18 @@
{{/* variables for enabling/disabling various features */}}
{{ $blogEnabled := site.Params.features.blog.enable | default false }}
{{ $notesEnabled := site.Params.features.notes.enable | default false }}
{{ $maxVisibleSections := site.Params.topNavbar.maxVisibleSections | default 5 }}
{{/* keep backward compatibility for blog post */}}
{{ if site.Params.enableBlogPost }}
{{ $blogEnabled = true }}
{{ end }}
{{/* default logos */}}
{{ $mainLogo := "/images/main-logo.png" }}
{{ $invertedLogo := "/images/inverted-logo.png" }}
{{/* by default, don't use any logo */}}
{{ $mainLogo := "" }}
{{ $invertedLogo := "" }}
{{/* if custom logo is used, them */}}
{{/* if custom logo has been provided, use them */}}
{{ if site.Params.logo.main }}
{{ $mainLogo = site.Params.logo.main }}
{{ end }}
@ -20,17 +21,21 @@
{{ end }}
{{/* resize the logos. don't resize svg because it is not supported */}}
{{ $mainLogo := resources.Get $mainLogo}}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ if $mainLogo }}
{{ $mainLogo = resources.Get $mainLogo}}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ $invertedLogo := resources.Get $invertedLogo}}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ if $invertedLogo }}
{{ $invertedLogo = resources.Get $invertedLogo}}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ $customMenus := site.Params.customMenus }}
{{ if (index site.Data site.Language.Lang).site.customMenus }}
@ -45,7 +50,9 @@
<nav class="navbar navbar-expand-xl top-navbar initial-navbar" id="top-navbar">
<div class="container">
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
<img src="{{ $invertedLogo }}" id="logo" alt="Logo">
{{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" id="logo" alt="Logo">
{{ end }}
{{- site.Title -}}
</a>
<button
@ -65,18 +72,18 @@
<a class="nav-link" href="#home">{{ i18n "home" }}</a>
</li>
{{ if $sections }}
{{ $sectionCount := 0}}
{{ $sectionCount := 1 }}
{{ range sort $sections "section.weight" }}
{{ if and (.section.enable) (.section.showOnNavbar)}}
{{ $sectionCount = add $sectionCount 1}}
{{ if le $sectionCount 5 }}
{{ if le $sectionCount $maxVisibleSections }}
<li class="nav-item">
<a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
</li>
{{ end }}
{{ end }}
{{- end }}
{{ if gt $sectionCount 5 }}
{{ if gt $sectionCount $maxVisibleSections }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{i18n "more" }}</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
@ -84,7 +91,7 @@
{{ range sort $sections "section.weight" }}
{{ if and (.section.enable) (.section.showOnNavbar) }}
{{ $sectionCount = add $sectionCount 1}}
{{ if gt $sectionCount 5 }}
{{ if gt $sectionCount $maxVisibleSections }}
<a class="dropdown-item" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
{{ end }}
{{ end }}
@ -122,6 +129,10 @@
</div>
</div>
<!-- Store the logo information in a hidden img for the JS -->
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ if $mainLogo }}
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
{{ end }}
{{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ end }}
</nav>

View file

@ -1,33 +1,43 @@
{{ $curPage := . }}
{{ $prevPage := "" }}
{{ $nextPage := "" }}
<!-- List all the pages. It uses the sidebar menu to discover the page order. -->
{{ $pages := slice }}
{{ if isset site.Menus "sidebar" }}
{{ $pages = partial "helpers/get-pages.html" site.Menus.sidebar }}
{{ end }}
<!-- Now, find the current page index in the pages list. Then, find previous page and next page. -->
{{ $idx := 0 }}
{{ range $pages }}
{{ if eq .RelPermalink $curPage.RelPermalink }}
{{ $prevPage = index $pages (sub $idx 1) }}
{{ $nextPage = index $pages (add $idx 1) }}
{{ end }}
{{ $idx = add $idx 1 }}
{{ end }}
<div class="row next-prev-navigator">
{{ $currentPage := . }}
{{ range (where site.RegularPages.ByDate "Type" "in" site.Params.mainSections )}}
{{ if eq .RelPermalink $currentPage.RelPermalink }}
{{ if .Next }}
{{ if (in site.Params.mainSections .Next.Type) }}
<div class="col-md-6 previous-article">
<a href="{{.Next.RelPermalink}}" title="{{ .Next.Title }}" class="btn btn-outline-info">
<div><i class="fas fa-chevron-circle-left"></i> {{ i18n "prev" }}</div>
<div class="next-prev-text">{{ .Next.Title }}</div>
{{ if $prevPage }}
<div class="col-md-6 previous-article">
<a href="{{ $prevPage.RelPermalink }}" title="{{ $prevPage.Title }}" class="btn btn-outline-info">
<div><i class="fas fa-chevron-circle-left"></i> {{ i18n "prev" }}</div>
<div class="next-prev-text">{{ $prevPage.Title }}</div>
</a>
</div>
{{ end }}
{{ if $nextPage }}
{{ $columnWidth:="col-md-12" }}
{{ if $prevPage }}
{{ $columnWidth = "col-md-6" }}
{{ end}}
<div class="{{ $columnWidth }} next-article">
<a href="{{ $nextPage.RelPermalink }}" title="{{ $nextPage.Title }}" class="btn btn-outline-info">
<div>{{ i18n "next" }} <i class="fas fa-chevron-circle-right"></i></div>
<div class="next-prev-text">{{ $nextPage.Title }}</div>
</a>
</div>
{{ end }}
{{ end }}
{{ if .Prev }}
{{ if (in site.Params.mainSections .Prev.Type) }}
{{ $columnWidth:="col-md-12" }}
{{ if .Next }}
{{ if (in site.Params.mainSections .Next.Type) }}
{{ $columnWidth = "col-md-6" }}
{{ end }}
{{ end}}
<div class="{{ $columnWidth }} next-article">
<a href="{{ .Prev.RelPermalink }}" title="{{ .Prev.Title }}" class="btn btn-outline-info">
<div>{{ i18n "next" }} <i class="fas fa-chevron-circle-right"></i></div>
<div class="next-prev-text">{{ .Prev.Title }}</div>
</a>
</div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</div>

View file

@ -0,0 +1,16 @@
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $class:= "" }}
{{ if isset $context.Site.Taxonomies ( lower $taxo ) }}
{{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }}
{{ if (gt (len $taxonomy) 0)}}
{{ range $taxonomy }}
{{if eq $context.Title .Page.Title}}
{{ $class = "active" }}
{{else}}
{{$class = ""}}
{{end}}
<li><a class="taxonomy-term {{ $class }}" href="{{ .Page.Permalink }}" data-taxonomy-term="{{ urlize .Page.Title }}"><span class="taxonomy-label">{{ .Page.Title }}</span></a></li>
{{ end }}
{{ end }}
{{ end }}