diff options
| author | yingyu5658 <i@yingyu5658.me> | 2025-12-29 21:20:34 +0800 |
|---|---|---|
| committer | yingyu5658 <i@yingyu5658.me> | 2025-12-29 21:20:34 +0800 |
| commit | 43b4395e10e0c8e032077cf44ea570fd382faef5 (patch) | |
| tree | cab63690c80a9eb876699f02e55fb70146446793 | |
| parent | 666022b097de6b18b5432b9fb59fd3aa39afe5e8 (diff) | |
| download | blog-43b4395e10e0c8e032077cf44ea570fd382faef5.tar.gz blog-43b4395e10e0c8e032077cf44ea570fd382faef5.zip | |
chore: Delete some redundancy file
| -rw-r--r-- | content/categories/随笔/_index.md | 3 | ||||
| -rw-r--r-- | layouts/no-comments/single.html | 136 | ||||
| -rw-r--r-- | layouts/partials/archives-list.html | 30 |
3 files changed, 0 insertions, 169 deletions
diff --git a/content/categories/随笔/_index.md b/content/categories/随笔/_index.md deleted file mode 100644 index 7df7597..0000000 --- a/content/categories/随笔/_index.md +++ /dev/null @@ -1,3 +0,0 @@ ---- -title: 随笔 ---- diff --git a/layouts/no-comments/single.html b/layouts/no-comments/single.html deleted file mode 100644 index 58160be..0000000 --- a/layouts/no-comments/single.html +++ /dev/null @@ -1,136 +0,0 @@ -{{ define "main" }} -{{ if eq .Type "blog" }} -{{ if not .Params.menu }} -<h1>{{ .Title }}</h1> -{{ if .Date }} -<p> - <i> - <time datetime='{{ .Date.Format "2006-01-02" }}' pubdate> - {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }} - </time> - </i> -</p> -{{ end }} -{{ end }} -{{ end }} - -<content> {{ .Content }} </content> - -<p> - {{ range (.GetTerms "tags") }} - <a href="{{ .Permalink }}">#{{ .LinkTitle }}</a> - {{ end }} -</p> - -{{ $upvoteEnabled := default .Site.Params.upvote .Params.upvote }} -{{ if $upvoteEnabled }} -<div class="upvote-container"> -<small class="upvote"> - <button class="upvote-btn" id="upvote-btn"> - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"> - <polyline points="17 11 12 6 7 11"></polyline> - <polyline points="17 18 12 13 7 18"></polyline> - </svg> - <span class="upvote-count" id="upvote-count">0</span> - </button> -</small> -</div> - -<script> - let hasUpvoted = false; - let upvoteBtn; - let upvoteCount; - - // 页面加载时获取点赞数量 - document.addEventListener('DOMContentLoaded', function() { - const slug = '{{ .Slug }}'; - upvoteBtn = document.getElementById('upvote-btn'); - upvoteCount = document.getElementById('upvote-count'); - getCount(slug); - - // 处理点赞按钮的点击事件 - upvoteBtn.addEventListener('click', handleUpvote); - }); - - // 点赞方法 - async function handleUpvote() { - if (hasUpvoted) { - console.log('You have already upvoted this post!'); - return; - } - const slug = '{{ .Slug }}'; - - // 禁用按钮以防止重复点击 - upvoteBtn.disabled = true; - // 给按钮添加 upvoted 类以赋以点击过的样式 - upvoteBtn.classList.add('upvoted'); - // 更新 upvote-count 的值 +1 - upvoteCount.innerText = parseInt(upvoteCount.innerText) + 1; - - try { - const response = await fetch('{{ .Site.Params.upvoteURL }}upvote', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ postId: slug, diff: 1 }), - }); - - if (response.ok) { - console.log('Upvote successful!'); - hasUpvoted = true; - await getCount(slug, 3); - } else { - console.log('Upvote failed!'); - } - } catch (error) { - console.error('Error: ', error); - } finally { - upvoteBtn.disabled = false; - } - } - - // 获取 Upvote 数量的方法,支持设置重试次数,默认不重试 - async function getCount(slug, retryCount = 0) { - try { - const response = await fetch('{{ .Site.Params.upvoteURL }}count?post=' + slug, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - }); - - const data = await response.json(); - - if (data.code === 0) { - const count = data.data.count; - upvoteCount.innerText = count; - hasUpvoted = data.data.hasUpvoted; - if (hasUpvoted) { - upvoteBtn.classList.add('upvoted'); - } else { - upvoteBtn.classList.remove('upvoted'); - } - } else { - console.error('Failed to get upvote count: ', data.msg); - } - } catch (error) { - console.error('Error: ', error); - if (retryCount > 0) { - setTimeout(() => { - getCount(slug, retryCount - 1); - }, 1000); - } - } - } -</script> -{{ end }} - -<!-- Place the TOC at the end to ensure the article content loads first. --> -{{ $tocEnabled := default .Site.Params.toc .Params.toc }} -{{ if $tocEnabled }} -<div class="toc"> -{{ partial "toc.html" . }} -</div> -{{ end }} -{{ end }} diff --git a/layouts/partials/archives-list.html b/layouts/partials/archives-list.html deleted file mode 100644 index b9767f7..0000000 --- a/layouts/partials/archives-list.html +++ /dev/null @@ -1,30 +0,0 @@ -{{ $allPages := where .Site.RegularPages "Type" "in" (slice "posts" "blog") }} -{{ $visiblePages := where $allPages "Params.hidden" "!=" true }} -{{ $pagesToShow := $visiblePages.ByDate.Reverse }} - -<div class="archives-content"> - <h2>归档</h2> - - <p>共有 {{ len $pagesToShow }} 篇文章</p> - - <ul class="blog-posts"> - {{ $currentYear := 0 }} - {{ range $pagesToShow }} - {{ $year := .Date.Year }} - {{ if ne $year $currentYear }} - <h3>{{ $year }}</h3> - {{ $currentYear = $year }} - {{ end }} - <li> - <span> - <i> - <time datetime='{{ .Date.Format "2006-01-02" }}'> - {{ .Date.Format "2006-01-02" }} - </time> - </i> - </span> - <a href="{{ .Permalink }}">{{ .Title }}</a> - </li> - {{ end }} - </ul> -</div> |
