diff options
author | Jimmy Cai <github@jimmycai.com> | 2022-10-29 18:14:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-29 18:14:19 +0300 |
commit | b03390d237427a2b9cfee55949cb1da62f1a6856 (patch) | |
tree | fd7da57cfcebc07d16483f3e9c3d71aee3562138 /layouts | |
parent | 8a597a5c9c861d2bce22a5e06c7667cd9c8e263a (diff) |
Revert "Merge branch 'canary' into master" (#712)
Revert "Merge branch 'canary' into master (#711)"
This reverts commit 8a597a5c9c861d2bce22a5e06c7667cd9c8e263a.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-codeblock.html | 20 | ||||
-rw-r--r-- | layouts/_default/_markup/render-image.html | 2 | ||||
-rw-r--r-- | layouts/_default/archives.html | 6 | ||||
-rw-r--r-- | layouts/_default/list.html | 2 | ||||
-rw-r--r-- | layouts/_default/rss.xml | 1 | ||||
-rw-r--r-- | layouts/index.html | 5 | ||||
-rw-r--r-- | layouts/page/search.json | 7 | ||||
-rw-r--r-- | layouts/partials/article-list/compact.html | 2 | ||||
-rw-r--r-- | layouts/partials/article/components/header.html | 2 | ||||
-rw-r--r-- | layouts/partials/article/components/photoswipe.html | 88 | ||||
-rw-r--r-- | layouts/partials/article/components/related-content.html | 2 | ||||
-rw-r--r-- | layouts/partials/data/title.html | 7 | ||||
-rw-r--r-- | layouts/partials/footer/components/script.html | 2 | ||||
-rw-r--r-- | layouts/partials/footer/footer.html | 2 | ||||
-rw-r--r-- | layouts/partials/head/colorScheme.html | 4 | ||||
-rw-r--r-- | layouts/partials/head/head.html | 7 | ||||
-rw-r--r-- | layouts/partials/head/opengraph/provider/twitter.html | 2 | ||||
-rw-r--r-- | layouts/partials/sidebar/left.html | 4 | ||||
-rw-r--r-- | layouts/partials/widget/archives.html | 4 |
19 files changed, 104 insertions, 65 deletions
diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html deleted file mode 100644 index 21c5100..0000000 --- a/layouts/_default/_markup/render-codeblock.html +++ /dev/null @@ -1,20 +0,0 @@ -{{- $class := .Attributes.class | default "" -}} -{{- $lang := .Attributes.lang | default .Type -}} -<div class="codeblock"> - <header> - <span class="codeblock-lang">{{ $lang }}</span> - <button - class="codeblock-copy" - data-id="codeblock-id-{{ .Ordinal }}" - data-copied-text="{{ T `article.codeblock.copied` }}" - > - {{ T `article.codeblock.copy` }} - </button> - </header> - <code id="codeblock-id-{{ .Ordinal }}" style="display:none;">{{- .Inner -}}</code> - {{- if transform.CanHighlight $lang -}} - <div class="{{ $class }}">{{- highlight .Inner $lang -}}</div> - {{- else -}} - <pre><code class="{{ $class }}">{{- .Inner -}}</code></pre> - {{- end -}} -</div> diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 5577736..0ed5584 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -17,7 +17,7 @@ {{- $Height = $image.Height -}} {{- $galleryImage = true -}} - {{- if .Page.Site.Params.imageProcessing.content.enabled -}} + {{- if (default true .Page.Site.Params.imageProcessing.content.enabled) -}} {{- $small := $image.Resize `480x` -}} {{- $big := $image.Resize `1024x` -}} {{- $Srcset = printf `%s 480w, %s 1024w` $small.RelPermalink $big.RelPermalink -}} diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 9df633e..5d5243c 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -16,8 +16,10 @@ </header> {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} - - {{ range $pages.GroupByDate "2006" }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + + {{ range $filtered.GroupByDate "2006" }} {{ $id := lower (replace .Key " " "-") }} <div class="archives-group" id="{{ $id }}"> <h2 class="archives-date section-title"><a href="{{ $.RelPermalink }}#{{ $id }}">{{ .Key }}</a></h2> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4e1e0b5..9bc618d 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -25,7 +25,7 @@ {{- $Width := $image.resource.Width -}} {{- $Height := $image.resource.Height -}} - {{- if .Page.Site.Params.imageProcessing.cover.enabled -}} + {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} {{- $thumbnail := $image.resource.Fill "120x120" -}} {{- $Permalink = $thumbnail.RelPermalink -}} {{- $Width = $thumbnail.Width -}} diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 0d3170e..e9f3f1a 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -6,6 +6,7 @@ {{- else -}} {{- $pages = $pctx.Pages -}} {{- end -}} +{{- $pages := where $pages "Params.hidden" "!=" true -}} {{- $limit := .Site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} diff --git a/layouts/index.html b/layouts/index.html index 5c1eaa5..0cd0b88 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,6 +1,9 @@ {{ define "main" }} {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} - {{ $pag := .Paginate ($pages) }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $pag := .Paginate ($filtered) }} + <section class="article-list"> {{ range $index, $element := $pag.Pages }} {{ partial "article-list/default" . }} diff --git a/layouts/page/search.json b/layouts/page/search.json index a0f5184..5d4e627 100644 --- a/layouts/page/search.json +++ b/layouts/page/search.json @@ -1,13 +1,16 @@ {{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}} +{{- $notHidden := where .Site.RegularPages "Params.hidden" "!=" true -}} +{{- $filtered := ($pages | intersect $notHidden) -}} + {{- $result := slice -}} -{{- range $pages -}} +{{- range $filtered -}} {{- $data := dict "title" .Title "date" .Date "permalink" .Permalink "content" (.Plain) -}} {{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}} {{- if $image.exists -}} {{- $imagePermalink := "" -}} - {{- if and $image.resource .Page.Site.Params.imageProcessing.cover.enabled -}} + {{- if and $image.resource (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} {{- $thumbnail := $image.resource.Fill "120x120" -}} {{- $imagePermalink = (absURL $thumbnail.Permalink) -}} {{- else -}} diff --git a/layouts/partials/article-list/compact.html b/layouts/partials/article-list/compact.html index edd58a0..376512a 100644 --- a/layouts/partials/article-list/compact.html +++ b/layouts/partials/article-list/compact.html @@ -19,7 +19,7 @@ {{- $Width := $image.resource.Width -}} {{- $Height := $image.resource.Height -}} - {{- if .Page.Site.Params.imageProcessing.cover.enabled -}} + {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} {{- $thumbnail := $image.resource.Fill "120x120" -}} {{- $Permalink = $thumbnail.RelPermalink -}} {{- $Width = $thumbnail.Width -}} diff --git a/layouts/partials/article/components/header.html b/layouts/partials/article/components/header.html index 78b41bd..7582ec2 100644 --- a/layouts/partials/article/components/header.html +++ b/layouts/partials/article/components/header.html @@ -9,7 +9,7 @@ {{- $Height := $image.resource.Height -}} {{- $Srcset := "" -}} - {{- if .Page.Site.Params.imageProcessing.cover.enabled -}} + {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} {{- $thumbnail := $image.resource.Resize "800x" -}} {{- $thumbnailRetina := $image.resource.Resize "1600x" -}} {{- $Srcset = printf "%s 800w, %s 1600w" $thumbnail.RelPermalink $thumbnailRetina.RelPermalink -}} diff --git a/layouts/partials/article/components/photoswipe.html b/layouts/partials/article/components/photoswipe.html index 425825c..c33ff49 100644 --- a/layouts/partials/article/components/photoswipe.html +++ b/layouts/partials/article/components/photoswipe.html @@ -1,20 +1,68 @@ -{{- $opts := dict "minify" hugo.IsProduction "format" "esm" -}} -{{- $galleryScript := resources.Get "ts/gallery.ts" | js.Build $opts -}} - -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@5.2.7/dist/photoswipe.css" - integrity="sha256-olf9rfn3AG8zR6lkPXkN3PZq63z8tElx7Ela6T4eklo=" crossorigin="anonymous"> - -<script type="module"> - import StackGallery from '{{ $galleryScript.RelPermalink }}'; - import PhotoSwipeLightbox from 'https://cdn.jsdelivr.net/npm/photoswipe@5.2.7/dist/photoswipe-lightbox.esm.min.js'; - - console.log(StackGallery) - StackGallery(document.querySelector('.article-content')); - - const lightbox = new PhotoSwipeLightbox({ - gallery: '.article-content', - children: '.gallery-image a', - pswpModule: () => import('https://cdn.jsdelivr.net/npm/photoswipe@5.2.7/dist/photoswipe.esm.min.js') - }); - lightbox.init(); -</script>
\ No newline at end of file +<!-- Root element of PhotoSwipe. Must have class pswp. --> +<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"> + + <!-- Background of PhotoSwipe. + It's a separate element as animating opacity is faster than rgba(). --> + <div class="pswp__bg"></div> + + <!-- Slides wrapper with overflow:hidden. --> + <div class="pswp__scroll-wrap"> + + <!-- Container that holds slides. + PhotoSwipe keeps only 3 of them in the DOM to save memory. + Don't modify these 3 pswp__item elements, data is added later on. --> + <div class="pswp__container"> + <div class="pswp__item"></div> + <div class="pswp__item"></div> + <div class="pswp__item"></div> + </div> + + <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. --> + <div class="pswp__ui pswp__ui--hidden"> + + <div class="pswp__top-bar"> + + <!-- Controls are self-explanatory. Order can be changed. --> + + <div class="pswp__counter"></div> + + <button class="pswp__button pswp__button--close" title="Close (Esc)"></button> + + <button class="pswp__button pswp__button--share" title="Share"></button> + + <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button> + + <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button> + + <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR --> + <!-- element will get class pswp__preloader--active when preloader is running --> + <div class="pswp__preloader"> + <div class="pswp__preloader__icn"> + <div class="pswp__preloader__cut"> + <div class="pswp__preloader__donut"></div> + </div> + </div> + </div> + </div> + + <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"> + <div class="pswp__share-tooltip"></div> + </div> + + <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"> + </button> + + <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"> + </button> + + <div class="pswp__caption"> + <div class="pswp__caption__center"></div> + </div> + + </div> + + </div> + +</div> + +{{- partial "helper/external" (dict "Context" . "Namespace" "PhotoSwipe") -}}
\ No newline at end of file diff --git a/layouts/partials/article/components/related-content.html b/layouts/partials/article/components/related-content.html index 822fc73..aba88e3 100644 --- a/layouts/partials/article/components/related-content.html +++ b/layouts/partials/article/components/related-content.html @@ -1,4 +1,4 @@ -{{ $related := .Site.RegularPages.Related . | first 5 }} +{{ $related := (where (.Site.RegularPages.Related .) "Params.hidden" "!=" true) | first 5 }} {{ with $related }} <aside class="related-content--wrapper"> <h2 class="section-title">{{ T "article.relatedContent" }}</h2> diff --git a/layouts/partials/data/title.html b/layouts/partials/data/title.html index 938a5da..85a7bc7 100644 --- a/layouts/partials/data/title.html +++ b/layouts/partials/data/title.html @@ -6,7 +6,9 @@ <!-- Build paginator --> {{ $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections }} - {{ $pag := .Paginate ($pages) }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $pag := .Paginate ($filtered) }} {{ if .Paginator.HasPrev }} <!-- Paginated. Append page number to title --> @@ -18,7 +20,8 @@ <!-- Taxonomy page --> <!-- Build paginator --> - {{ $pag := .Paginate .Pages }} + {{ $notHidden := where .Pages "Params.hidden" "!=" true }} + {{ $pag := .Paginate ($notHidden) }} <!-- {TAXONOMY_TYPE}: {TAXONOMY_TERM} --> {{ $title = slice (title .Data.Singular) ": " $title }} diff --git a/layouts/partials/footer/components/script.html b/layouts/partials/footer/components/script.html index f25dc83..4cb350c 100644 --- a/layouts/partials/footer/components/script.html +++ b/layouts/partials/footer/components/script.html @@ -1,3 +1,5 @@ +{{- partial "helper/external" (dict "Context" . "Namespace" "Vibrant") -}} + {{- $opts := dict "minify" hugo.IsProduction -}} {{- $script := resources.Get "ts/main.ts" | js.Build $opts -}} diff --git a/layouts/partials/footer/footer.html b/layouts/partials/footer/footer.html index 3b2b46f..49caa89 100644 --- a/layouts/partials/footer/footer.html +++ b/layouts/partials/footer/footer.html @@ -1,4 +1,4 @@ -{{- $ThemeVersion := "4.0.0-alpha.0" -}} +{{- $ThemeVersion := "3.16.0" -}} <footer class="site-footer"> <section class="copyright"> © diff --git a/layouts/partials/head/colorScheme.html b/layouts/partials/head/colorScheme.html index 04d63a5..42f4dd8 100644 --- a/layouts/partials/head/colorScheme.html +++ b/layouts/partials/head/colorScheme.html @@ -1,5 +1,5 @@ -{{- $defaultColorScheme := .Site.Params.colorScheme.default -}} -{{- if not .Site.Params.colorScheme.toggle -}} +{{- $defaultColorScheme := default "auto" .Site.Params.colorScheme.default -}} +{{- if not (default false .Site.Params.colorScheme.toggle) -}} {{/* If toggle is disabled, force default scheme */}} <script> (function() { diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html index 5de6071..be63710 100644 --- a/layouts/partials/head/head.html +++ b/layouts/partials/head/head.html @@ -19,12 +19,7 @@ {{- end -}} {{ with .Site.Params.favicon }} - {{ $favicon := resources.Get . }} - {{ if $favicon }} - <link rel="shortcut icon" href="{{ $favicon.RelPermalink }}" /> - {{ else }} - {{ errorf "Failed loading favicon from %q" . }} - {{ end }} + <link rel="shortcut icon" href="{{ . }}" /> {{ end }} {{- template "_internal/google_analytics.html" . -}} diff --git a/layouts/partials/head/opengraph/provider/twitter.html b/layouts/partials/head/opengraph/provider/twitter.html index a837ba3..03bbf22 100644 --- a/layouts/partials/head/opengraph/provider/twitter.html +++ b/layouts/partials/head/opengraph/provider/twitter.html @@ -11,6 +11,6 @@ {{- $image := partialCached "helper/image" (dict "Context" . "Type" "opengraph") .RelPermalink "opengraph" -}} {{- if $image.exists -}} - <meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}"> + <meta name="twitter:card" content="{{ default `summary_large_image` .Site.Params.opengraph.twitter.card }}"> <meta name="twitter:image" content='{{ absURL $image.permalink }}' /> {{- end -}}
\ No newline at end of file diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html index 2dfa1d4..f94e50a 100644 --- a/layouts/partials/sidebar/left.html +++ b/layouts/partials/sidebar/left.html @@ -7,7 +7,7 @@ <header> {{ with .Site.Params.sidebar.avatar }} - {{ if .enabled }} + {{ if (default true .enabled) }} <figure class="site-avatar"> <a href="{{ .Site.BaseURL | relLangURL }}"> {{ if not .local }} @@ -89,7 +89,7 @@ </li> {{ end }} - {{ if .Site.Params.colorScheme.toggle }} + {{ if (default false .Site.Params.colorScheme.toggle) }} <li id="dark-mode-toggle"> {{ partial "helper/icon" "toggle-left" }} {{ partial "helper/icon" "toggle-right" }} diff --git a/layouts/partials/widget/archives.html b/layouts/partials/widget/archives.html index e42da27..1f2abc5 100644 --- a/layouts/partials/widget/archives.html +++ b/layouts/partials/widget/archives.html @@ -10,7 +10,9 @@ <h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2> {{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }} - {{ $archives := $pages.GroupByDate "2006" }} + {{ $notHidden := where $context.Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $archives := $filtered.GroupByDate "2006" }} <div class="widget-archive--list"> {{ range $index, $item := first (add $limit 1) ($archives) }} |