aboutsummaryrefslogtreecommitdiffstats
path: root/layouts/_default/list.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_default/list.html')
-rw-r--r--layouts/_default/list.html44
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 "往昔")) }}