diff options
| author | verdant <im@verdant.ee> | 2026-05-31 16:33:36 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-05-31 16:33:36 +0800 |
| commit | 172adfb014596423d7cc3043f2a288ac01884cba (patch) | |
| tree | f788b0b10f330daf8c3a6d1a8ed656a1d1253390 /layouts/_default/list.html | |
| parent | f9869a2cf060976c69aeade3d3f231bf1fbdddd3 (diff) | |
| download | blog-172adfb014596423d7cc3043f2a288ac01884cba.tar.gz blog-172adfb014596423d7cc3043f2a288ac01884cba.zip | |
Add minify configuration, modify favicon url
Diffstat (limited to 'layouts/_default/list.html')
| -rw-r--r-- | layouts/_default/list.html | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 8c1db86..3992a01 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,50 +1,6 @@ {{ define "main" }} <content> - {{ if .Site.Params.postSearch }} - <input - id="search-input" - type="text" - placeholder="Search..." - style="margin-top: 16px" - /> - <script> - // 等待 DOM 完全加载后执行 - document.addEventListener('DOMContentLoaded', function () { - // 缓存 DOM 元素 - const searchInput = document.getElementById('search-input'); - const posts = document.querySelectorAll('.blog-posts li'); - const years = document.querySelectorAll('.blog-posts h3'); - // 更新搜索结果 - function updateSearchResults(searchTerm) { - let visiblePosts = 0; - const displayedYears = new Set(); - posts.forEach(function (post) { - const title = post.querySelector('a').textContent.toLowerCase(); - const year = post.querySelector('time').getAttribute('datetime').split('-')[0]; - if (title.includes(searchTerm)) { - post.style.display = ''; - visiblePosts++; - displayedYears.add(year); - } else { - post.style.display = 'none'; - } - }); - - {{ if .Site.Params.groupByYear }} - years.forEach(function (y) { - const year = y.textContent; - y.style.display = displayedYears.has(year) ? '' : 'none'; - }); - {{ end }} - } - - searchInput.addEventListener('input', function () { - updateSearchResults(this.value.toLowerCase().trim()); - }); - }); - </script> - {{ end }} <ul class="blog-posts"> {{ $currentYear := 0 }} {{ range .Pages }} {{ if and (not .Params.hidden) (not (in .Params.categories "往昔")) }} |
