Site updated: 2026-12-02 14:00:46
This commit is contained in:
1 parent
e50083577d
commit
c3196d96d1
251 files changed
+12972
-1564
No files matched your search
+52
-6
@@ -46,9 +46,21 @@
|
||||
display: inline;
|
||||
margin: 0;
|
||||
}
|
||||
/* 子评论缩进 + 回复标记 */
|
||||
.leancloud-recent-comment .wl-recent-child {
|
||||
padding-left: 1.4rem;
|
||||
border-bottom: none;
|
||||
font-size: 0.78rem;
|
||||
color: var(--color-secondary, #999);
|
||||
}
|
||||
.leancloud-recent-comment .wl-reply-tag {
|
||||
color: var(--color-primary, #6bc30d);
|
||||
margin-right: 0.3em;
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head><body itemscope itemtype="http://schema.org/WebPage"><div id="loading"><div class="cat"><div class="body"></div><div class="head"><div class="face"></div></div><div class="foot"><div class="tummy-end"></div><div class="bottom"></div><div class="legs left"></div><div class="legs right"></div></div><div class="paw"><div class="hands left"></div><div class="hands right"></div></div></div></div><div id="container"><header id="header" itemscope itemtype="http://schema.org/WPHeader"><div class="inner"><div id="brand"><div class="pjax"><a href="/" class="logo" rel="start"><p class="artboard">☆∵∴Hito∴∵★</p><h1 itemprop="name headline" class="title">涛声依旧</h1></a><p class="meta" itemprop="description">= 天下事有难易乎?为之,则难者亦易矣 =</p></div></div><nav id="nav"><div class="inner"><div class="toggle"><div class="lines" aria-label="切换导航栏"><span class="line"></span> <span class="line"></span> <span class="line"></span></div></div><ul class="menu"><li class="item title"><a href="/" rel="start">☆∵∴Hito∴∵★</a></li></ul><ul class="right"><li class="item theme"><i class="ic i-sun"></i></li><li class="item search"><i class="ic i-search"></i></li></ul></div></nav></div><div id="imgs" class="pjax"><ul><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?30136"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?16725"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?662651"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?276162"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?709127"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?576278"></li></ul></div></header><div id="waves"><svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"/></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"/><use xlink:href="#gentle-wave" x="48" y="3"/><use xlink:href="#gentle-wave" x="48" y="5"/><use xlink:href="#gentle-wave" x="48" y="7"/></g></svg></div><main><div class="inner"><div id="main" class="pjax"><div class="index wrap"><div class="segments posts"><article class="item"><div class="cover"><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑"><img data-src="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?322958"></a></div><div class="info"><div class="meta"><span class="item" title="创建时间:2022-09-17 23:12:00"><span class="icon"><i class="ic i-calendar"></i> </span><time itemprop="dateCreated datePublished" datetime="2022-09-17T23:12:00+08:00">2022-09-17</time> </span><span class="item" title="本文字数"><span class="icon"><i class="ic i-pen"></i> </span><span>588</span> <span class="text">字</span> </span><span class="item" title="阅读时长"><span class="icon"><i class="ic i-clock"></i> </span><span>1 分钟</span> </span><span class="item" title="评论数量"><span class="icon"><i class="ic i-comments"></i> </span><span class="waline-comment-count" data-path="/2022/09/17/Hexo-Theme-Shoka-algolia搜索踩坑/"></span></span></div><h3><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑">Hexo + Theme.Shoka + algolia搜索踩坑</a></h3><div class="excerpt"># Hexo + Theme.Shoka 安装 安装介绍 # algolia 注册 algolia 不支持国内邮箱注册,而 google 和 github 由于国内被墙也没法使用。所以只能先注册 netlify 然后通过 netlify 注册 algolia。 登录 algolia 后创建一个 index,名字随意记住既可。 点击右上角红点,弹出窗口点 settings 按钮。 点击 API KEYS,获取 appId 和 adminApiKey 填入 hexo 的_config.yml 中 apiKey 暂时不填。 algolia: appId: #Your appId...</div><div class="meta footer"><span><a href="/categories/%E6%9E%81%E7%A9%BA%E9%97%B4/Docker/Hexo/" itemprop="url" title="Hexo"><i class="ic i-flag"></i>Hexo</a></span></div><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑" class="btn">more...</a></div></article><article class="item"><div class="cover"><a href="/2022/09/16/%E6%9E%81%E7%A9%BA%E9%97%B4chevereto%E5%9B%BE%E5%BA%8Adocker%E7%89%88%E5%AE%89%E8%A3%85/" itemprop="url" title="极空间chevereto图床docker版安装"><img data-src="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?878265Line truncated
|
||||
</head><body itemscope itemtype="http://schema.org/WebPage"><div id="loading"><div class="cat"><div class="body"></div><div class="head"><div class="face"></div></div><div class="foot"><div class="tummy-end"></div><div class="bottom"></div><div class="legs left"></div><div class="legs right"></div></div><div class="paw"><div class="hands left"></div><div class="hands right"></div></div></div></div><div id="container"><header id="header" itemscope itemtype="http://schema.org/WPHeader"><div class="inner"><div id="brand"><div class="pjax"><a href="/" class="logo" rel="start"><p class="artboard">☆∵∴Hito∴∵★</p><h1 itemprop="name headline" class="title">涛声依旧</h1></a><p class="meta" itemprop="description">= 天下事有难易乎?为之,则难者亦易矣 =</p></div></div><nav id="nav"><div class="inner"><div class="toggle"><div class="lines" aria-label="切换导航栏"><span class="line"></span> <span class="line"></span> <span class="line"></span></div></div><ul class="menu"><li class="item title"><a href="/" rel="start">☆∵∴Hito∴∵★</a></li></ul><ul class="right"><li class="item theme"><i class="ic i-sun"></i></li><li class="item search"><i class="ic i-search"></i></li></ul></div></nav></div><div id="imgs" class="pjax"><ul><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?225548"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?21001"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?124015"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?56972"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?737499"></li><li class="item" data-background-image="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?295887"></li></ul></div></header><div id="waves"><svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"/></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"/><use xlink:href="#gentle-wave" x="48" y="3"/><use xlink:href="#gentle-wave" x="48" y="5"/><use xlink:href="#gentle-wave" x="48" y="7"/></g></svg></div><main><div class="inner"><div id="main" class="pjax"><div class="index wrap"><div class="segments posts"><article class="item"><div class="cover"><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑"><img data-src="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?481991"></a></div><div class="info"><div class="meta"><span class="item" title="创建时间:2022-09-17 23:12:00"><span class="icon"><i class="ic i-calendar"></i> </span><time itemprop="dateCreated datePublished" datetime="2022-09-17T23:12:00+08:00">2022-09-17</time> </span><span class="item" title="本文字数"><span class="icon"><i class="ic i-pen"></i> </span><span>588</span> <span class="text">字</span> </span><span class="item" title="阅读时长"><span class="icon"><i class="ic i-clock"></i> </span><span>1 分钟</span> </span><span class="item" title="评论数量"><span class="icon"><i class="ic i-comments"></i> </span><span class="waline-comment-count" data-path="/2022/09/17/Hexo-Theme-Shoka-algolia搜索踩坑/"></span></span></div><h3><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑">Hexo + Theme.Shoka + algolia搜索踩坑</a></h3><div class="excerpt"># Hexo + Theme.Shoka 安装 安装介绍 # algolia 注册 algolia 不支持国内邮箱注册,而 google 和 github 由于国内被墙也没法使用。所以只能先注册 netlify 然后通过 netlify 注册 algolia。 登录 algolia 后创建一个 index,名字随意记住既可。 点击右上角红点,弹出窗口点 settings 按钮。 点击 API KEYS,获取 appId 和 adminApiKey 填入 hexo 的_config.yml 中 apiKey 暂时不填。 algolia: appId: #Your appId...</div><div class="meta footer"><span><a href="/categories/%E6%9E%81%E7%A9%BA%E9%97%B4/Docker/Hexo/" itemprop="url" title="Hexo"><i class="ic i-flag"></i>Hexo</a></span></div><a href="/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/" itemprop="url" title="Hexo + Theme.Shoka + algolia搜索踩坑" class="btn">more...</a></div></article><article class="item"><div class="cover"><a href="/2022/09/16/%E6%9E%81%E7%A9%BA%E9%97%B4chevereto%E5%9B%BE%E5%BA%8Adocker%E7%89%88%E5%AE%89%E8%A3%85/" itemprop="url" title="极空间chevereto图床docker版安装"><img data-src="https://ndis.hitoli.com:8443/nas-dispatcher/common/downloadImg?59591"Line truncated
|
||||
// 侧栏「最新评论」:挂在 footer 的 .leancloud-recent-comment 容器(PJAX 不替换 footer,全局渲染一次即可)
|
||||
// 动态 import 加载 ESM 版 waline.js;普通 <script src> 会报 export 语法错误
|
||||
(async () => {
|
||||
@@ -91,14 +103,48 @@
|
||||
.then(res => {
|
||||
const list = (res && res.data) || [];
|
||||
if (!list.length) { setTimeout(() => loadRecent(attempt + 1), 3000 * attempt); return; }
|
||||
el.innerHTML = '<ul class="wl-recent-list">' + list.map(c => {
|
||||
// comment 是 HTML(服务端已 sanitize),提取纯文本并截断
|
||||
// 组装层级:pid 指向父评论 objectId。父评论不在本批数据里时按顶级处理
|
||||
const byId = {};
|
||||
list.forEach(c => { byId[c.objectId] = c; });
|
||||
const nickOf = (id) => (byId[id] && byId[id].nick) || '';
|
||||
const esc = (s) => String(s || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
const itemHtml = (c, indent) => {
|
||||
const tmp = document.createElement('div');
|
||||
tmp.innerHTML = c.comment || '';
|
||||
const text = (tmp.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 60);
|
||||
// 去掉服务端已加的 "@昵称 ," 前缀(渲染成缩进层级后冗余)
|
||||
let text = (tmp.textContent || '').replace(/^\s*@\S+?\s*,\s*/, '').trim().replace(/\s+/g, ' ').slice(0, 60);
|
||||
const replyTag = indent ? '<span class="wl-reply-tag">↳ 回复 ' + esc(nickOf(c.pid)) + '</span>' : '';
|
||||
const link = c.url || c.path || '';
|
||||
return '<li class="wl-recent-item"><a href="' + link + '">' + (c.nick || '匿名') + '</a>:' + text + '</li>';
|
||||
}).join('') + '</ul>';
|
||||
return '<li class="wl-recent-item' + (indent ? ' wl-recent-child' : '') + '">'
|
||||
+ replyTag
|
||||
+ '<a href="' + link + '">' + esc(c.nick || '匿名') + '</a>:' + esc(text)
|
||||
+ '</li>';
|
||||
};
|
||||
// 子评论紧跟在父评论后面输出(保持数据原有时间序)
|
||||
const rendered = {};
|
||||
const html = [];
|
||||
list.forEach(c => {
|
||||
if (rendered[c.objectId]) return;
|
||||
if (!c.pid || !byId[c.pid]) {
|
||||
html.push(itemHtml(c, false));
|
||||
rendered[c.objectId] = true;
|
||||
// 输出它的子孙(可能连续多层,循环找)
|
||||
let changed = true;
|
||||
while (changed) {
|
||||
changed = false;
|
||||
list.forEach(s => {
|
||||
if (!rendered[s.objectId] && s.pid && rendered[s.pid]) {
|
||||
html.push(itemHtml(s, true));
|
||||
rendered[s.objectId] = true;
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// 兜底:pid 指向的父评论比自己晚出现的数据(乱序),补渲染
|
||||
list.forEach(c => { if (!rendered[c.objectId]) html.push(itemHtml(c, true)); });
|
||||
el.innerHTML = '<ul class="wl-recent-list">' + html.join('') + '</ul>';
|
||||
})
|
||||
.catch(() => {
|
||||
setTimeout(() => loadRecent(attempt + 1), 3000 * attempt);
|
||||
|
||||
Reference in new issue
Block a user