Hexo
约 386 字大约 1 分钟
记录一下搭建博客
1. 配置
# 安装:node.js、git
# 创建博客文件夹
- hexo init
# 安装依赖包
- npm install
# 本地调试 浏览器中输入 localhost:4000
- hexo generate
- hexo server
# 创建 用户名.github.io 仓库
# 编辑本地Hexo目录下文件_config.yml,在最后添加如下代码
deploy:
type: git
repository: http://github.com/用户名/用户名.github.io.git
branch: master
# 部署到github
- hexo generate
- hexo deploy
# 生成SSH
ssh-keygen -t rsa -C "1105128664@qq.com",一路回车
找到本用户下的C:\Users\${username}\.ssh\id_rsa把里面的内容复制
在github上面对应的仓库点击Setting,然后点击Deploy Keys
黏贴刚才的内容,Allow write access 打钩,点击Add Key
# 测试上传
ssh -T git@github.com,即使报错也一路点yes,至此配置成功
git config --global user.name "yourusername"
git config --golbal user.email "youremail"
配置以上两个去掉很多警告
2. VSCode配置
ctrl+shift+P 找到 Markdown Preview Enhanced: Extend Parser,打开 parser.js
修改其中 onWillParseMarkdown 方法为:
onWillParseMarkdown: async function(markdown) {
return new Promise((resolve, reject)=> {
/** 处理 {% asset_img xxx%}**/
// markdown = markdown.replace(
// /\{%\s*asset_img\s*(.*)\s*%\}/g,
// (whole, content) => (`![](/source/_posts/${markdown.match(/title\: (\S*)/)[1]}/${content})`)
// )
/** 处理 [](xxx.html/xxx)**/
// markdown = markdown.replace(
// /\[.*]\(.*\.html\/.*\)/g,
// (whole, content) => (`${whole}`.replace(/\.html\//g,'.md/'))
// )
/** 处理 [](xxx/xxxx.png)**/
// markdown = markdown.replace(
// /!\[.*]\(.*\.(png|jpg|gif)\)/g,
// (whole, content) => (`${whole}`.replace(/]\(/g,'](/docs/.vuepress/public/'))
// )
/** 处理 [](xxxx.png)**/
markdown = markdown.replace(
/!\[.*]\(.*\.(png|jpg|gif)\)/g,
(whole, content) => (`${whole}`.replace(/]\(/g,`](./${markdown.match(/title\: (\S*)/)[1]}/`))
)
return resolve(markdown)
})
},