mirror of https://github.com/jkjoy/sunpeiwen.git
update some post
This commit is contained in:
parent
5bc6dafcc7
commit
b997aa02cb
|
@ -1149,7 +1149,7 @@ static_prefix:
|
|||
|
||||
disqusjs: https://lib.baomitu.com/disqusjs/1.3.0/
|
||||
|
||||
twikoo: https://lib.baomitu.com/twikoo/1.6.21/
|
||||
twikoo: https://lib.baomitu.com/twikoo/1.6.22/
|
||||
|
||||
discuss: https://lib.baomitu.com/discuss/1.2.1/
|
||||
|
||||
|
|
|
@ -11,10 +11,70 @@ updated: '2023-8-13T14:28:41.53+8:0'
|
|||
cover:
|
||||
---
|
||||
上文提到
|
||||
|
||||
[给Memos添加Twikoo评论](/2023/507a5d86.html)
|
||||
|
||||
-2023.10.17更新memos0.16版本
|
||||
|
||||
2023.9.26更新提醒: memos升级到0.15.1后版本,本方法失效
|
||||
## 自定义脚本
|
||||
```
|
||||
// Artalk comments 2023.8.15更新
|
||||
// 用 JS 向页面中插入 JS
|
||||
function addArtalkJS() {
|
||||
var memosArtalk = document.createElement("script");
|
||||
memosArtalk.src = `https://unpkg.com/artalk/dist/Artalk.js`;
|
||||
var artakPos = document.getElementsByTagName("script")[0];
|
||||
artakPos.parentNode.insertBefore(memosArtalk, artakPos);
|
||||
};
|
||||
// div
|
||||
function startArtalk() {
|
||||
start = setInterval(function(){
|
||||
var artalkDom = document.getElementById('Comments') || '';
|
||||
var memoAt = document.querySelector('.resource-wrapper') || '';
|
||||
var memoLoading = document.querySelector('.action-button-container') || '';
|
||||
var memoLoadingA = document.querySelector('.action-button-container a') || '';
|
||||
if(window.location.href.replace(/^.*\/(m)\/.*$/,'$1') == "m" && memoLoadingA){
|
||||
memoLoading.innerHTML = "评论加载中……"
|
||||
}
|
||||
if(window.location.href.replace(/^.*\/(m)\/.*$/,'$1') == "m" && !artalkDom){
|
||||
addArtalkJS()
|
||||
if(memoAt){
|
||||
clearInterval(start)
|
||||
var cssLink = document.createElement("link");
|
||||
cssLink.rel = "stylesheet";
|
||||
cssLink.href = "https://unpkg.com/artalk/dist/Artalk.css";
|
||||
document.head.appendChild(cssLink);
|
||||
memoAt.insertAdjacentHTML('afterend', '<div id="Comments"></div>');
|
||||
setTimeout(function() {
|
||||
Artalk.init({
|
||||
el: '#Comments',
|
||||
pageKey: location.pathname,
|
||||
pageTitle: document.title,
|
||||
server: 'https://artalk.loliko.cn',//更改为自己
|
||||
site: 'memos',
|
||||
darkMode: 'auto'
|
||||
});
|
||||
Artalk.on('list-loaded', function() {
|
||||
// console.log('评论加载完成');
|
||||
memoLoading.innerHTML = ''
|
||||
startArtalk();
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
//console.log(window.location.href);
|
||||
}, 1000)
|
||||
}
|
||||
startArtalk();
|
||||
```
|
||||
## 自定义样式
|
||||
```
|
||||
.text-sm.text-gray-500.ml-1{display:none !important;}
|
||||
```
|
||||
隐藏评论数
|
||||
|
||||
|
||||
- 2023.9.26更新提醒: memos升级到0.15.1后版本,本方法失效
|
||||
## 自定义脚本
|
||||
|
||||
```
|
||||
|
@ -50,7 +110,7 @@ function startArtalk() {
|
|||
el: '#Comments',
|
||||
pageKey: location.pathname,
|
||||
pageTitle: document.title,
|
||||
server: 'https://atim.fly.dev',
|
||||
server: 'https://artalk.loliko.cn',
|
||||
site: 'memos',
|
||||
darkMode: 'auto'
|
||||
});
|
||||
|
|
|
@ -11,7 +11,53 @@ title: 给Memos添加Twikoo评论
|
|||
updated: '2023-6-13T13:53:48.150+8:0'
|
||||
cover:
|
||||
---
|
||||
2023.9.26 更新.memos升级0.15.1版本后无法使用
|
||||
2023.10.17更新脚本
|
||||
## 自定义脚本
|
||||
适用于0.16版本
|
||||
|
||||
```
|
||||
//Memos v0.16 添加 Twikoo 评论 v2023.10.06
|
||||
var twikooENV = '' //你的 https://xxxx/
|
||||
function addTwikooJS() {
|
||||
var memosTwikoo = document.createElement("script");
|
||||
memosTwikoo.src = `https://cdn.staticfile.org/twikoo/1.6.22/twikoo.all.min.js`;
|
||||
var tws = document.getElementsByTagName("script")[0];
|
||||
tws.parentNode.insertBefore(memosTwikoo, tws);
|
||||
};
|
||||
function startTwikoo() {
|
||||
startTW = setInterval(function(){ //定时执行 1秒/次
|
||||
var nowHref = window.location.href;
|
||||
var twikooDom = document.querySelector('#twikoo') || '';
|
||||
if( nowHref.replace(/^.*\/(m)\/.*$/,'$1') == "m"){//单条页面
|
||||
if(!twikooDom){
|
||||
//console.log('评论未加载');
|
||||
addTwikooJS() //加载评论 js
|
||||
setTimeout(function() { //延迟 1秒 执行
|
||||
var memoTw = document.querySelector('.resource-wrapper') || '';
|
||||
memoTw.insertAdjacentHTML('afterend', '<div id="mtcomment"></div>');
|
||||
twikoo.init({
|
||||
envId: twikooENV,
|
||||
el: '#mtcomment',
|
||||
path: nowHref.replace(/^.*=?(http.*\/m\/[0-9]+).*$/,'$1'), //v2023.08.09 正则更新
|
||||
onCommentLoaded: function () {
|
||||
startTwikoo()
|
||||
//console.log('再次开启定时执行');
|
||||
}
|
||||
})
|
||||
}, 900)
|
||||
}else{
|
||||
//console.log('清除定时执行');
|
||||
clearInterval(startTW)
|
||||
}
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
startTwikoo();
|
||||
```
|
||||
|
||||
由于官方已经有评论图标所以CSS不再添加图标
|
||||
|
||||
2023.9.26 更新.memos升级0.15.1版本后以下无法使用
|
||||
|
||||
代码来自于@[林木木](https://immmmm.com/memos-with-twikoo/)
|
||||
|
||||
|
|
Loading…
Reference in New Issue