flomo之前有用,但是发现限制蛮多的,后来在obsidian里面看到了这个memo,然后看到了木木大佬的部署教程,然鹅开始并不懂,一脸蒙圈。后来又兜兜转转看到了阿杰大佬的详细教程,于是决定自己试试。记录一下,方便后面玩儿崩了可以再来一次。
前期准备
- 在宝塔中添加站点,绑定一个子域名,再把SSL证书给申请了加上,
- 加上反向代理,地址是https://ip:5230(也记得在防火墙里面把5230的端口给加上)
- 在宝塔中安装,docker和Docker-compose。Docker-compose可以在终端安,docker可以直接在应用商店找。
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- 在站点目录内新建一个
docker-compose.yaml
的文件,并在里面增加以下内容
version: "3.0"
services:
memos:
image: neosmemo/memos:latest
container_name: memos
volumes:
- ${PWD}/.memos/:/var/opt/memos
ports:
- 5230:5230
安装部分
- 打开终端,输入cd /www/wwwroot/m.sicza.com 进入站点目录。
- 输入代码即可安装:
docker-compose up -d
- 版本更新代码:
docker-compose pull && docker-compose up -d --force-recreate
WORDPRESS部分
新建页面,添加自定义HTML区块,增加以下代码:
<div id="bber"></div>
<style>
.bb-timeline ul li .datacont img{max-width: 20rem;cursor: pointer;border-radius: 0.25rem;}
</style>
<script>
// 以下信息改掉
var bbMemos = {
memos : 'https://m.sicza.com/', //填入memos网站域名,末尾需带斜杠
limit : '20', //填入需要展示的memos数量
creatorId:'1' , //自己部署的话默认为1,不用修改
domId: '#bber', //可以不修改
username:"sicza", //修改为你自己的昵称
useravatar:"https://img.sicza.com/wp-content/uploads/2023/07/20230704214355646.png", //修改为自己的头像链接
userlink:"https://sicza.com", //修改为你的域名
tags:"",
commentsShow:true, //没有评论功能可修改为false
commentsUrl:"https://m.sicza.com/m/", //修改为你的Memos域名,但保留包含m的尾巴部分
commentsTitle:"🤣逼逼叨" //可以不修改
}
var artalkInit = {
site: "SICZA", //填入前面artalk设置中的站点名,没有评论功能可以不管
server:'https://t.sicza.com' //填入前面artalk的网站域名,没有评论功能可以不管
}
</script>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/Artalk.css">
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/Artalk.js"></script>
<script src="https://sicza.com/js/shuoshuo.js"></script>
<script src="https://npm.elemecdn.com/marked/marked.min.js"></script>
<script src="https://jsd.onmicrosoft.cn/gh/Tokinx/ViewImage/view-image.min.js"></script>
<script src="https://jsd.onmicrosoft.cn/gh/Tokinx/Lately/lately.min.js"></script>
基本上完成以上就没有问题,但需要注意的是,发布的memo需要是公开状态,其他状态不可见。
MEMO嵌入Artalk评论系统
部署与memo一致,需要注意的是,在添加完可信站点之后需要重启artalk,否则会出现问题。
在自定义脚本中输入(v0.16.0以前):
// Artalk comments
// 用 JS 向页面中插入 JS
function addArtalkJS() {
var memosArtalk = document.createElement("script");
memosArtalk.src = `https://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/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('.memo-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://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/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://t.sicza.com', //填入自己artalk的网站域名
site: 'SICZA', //填入前面artalk设置中的域名
darkMode: 'auto'
});
Artalk.on('list-loaded', function() {
// console.log('评论加载完成');
memoLoading.innerHTML = ''
startArtalk();
});
}, 1000);
}
}
//console.log(window.location.href);
}, 1000)
}
startArtalk();
v0.17.0:(代码来自木木大佬)
// Memos v0.16.1 单条页面插入 Artalk 评论
var artalkServer = '改改改'
function addArtalkJSCSS() {
var memosArtalk = document.createElement("script");
memosArtalk.src = `https://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/Artalk.js`;
var artakPos = document.getElementsByTagName("script")[0];
artakPos.parentNode.insertBefore(memosArtalk, artakPos);
var cssLink = document.createElement("link");
cssLink.rel = "stylesheet";
cssLink.href = "https://cdn.bootcdn.net/ajax/libs/artalk/2.5.5/Artalk.css";
document.head.appendChild(cssLink);
};
function addArtalkDom() {
startAK = setInterval(function(){
var nowHref = window.location.href;
var artalkDom = document.querySelector('#artalk') || '';
if( nowHref.replace(/^.*\/(m)\/.*$/,'$1') == "m"){
if(!artalkDom){
addArtalkJSCSS()
var memoAK = document.querySelector('.gap-2') || '';
memoAK.insertAdjacentHTML('afterend', '<div id="artalk" style="margin:2rem 0;"></div>');
setTimeout(function() {
Artalk.init({
el: '#artalk',
pageKey: location.pathname,
pageTitle: document.title,
server: artalkServer,
site: '改改改',
darkMode: 'auto'
});
addArtalkDom();
}, 1500)
}else{
clearInterval(startAK)
}
}
}, 2000)
}
addArtalkDom();
相关文章参考
阿杰大佬完整流程步骤参考:https://veryjack.com/technique/docker-memos-shuoshuo/
木木大佬的细节设置参考:https://immmmm.com/hi-memos/
近期MEMO显示:https://immmmm.com/hugo-shortcodes-recently-by-memos/
评论 (0)