MaLuns / hexo-theme-async

一个简单而轻量级的 Hexo 主题。 | A simple, lightweight Hexo theme.
https://hexo-theme-async.imalun.com
MIT License
328 stars 40 forks source link

能适配下gitalk吗QwQ #14

Closed XuanYuSLF closed 1 year ago

MaLuns commented 1 year ago

没用过这个,你可以先 参考这里 尝试自己添加一下😂,有问题可以找我

XuanYuSLF commented 1 year ago

我不知道JavaScript放哪😅

XuanYuSLF commented 1 year ago

https://github.com/gitalk/gitalk

MaLuns commented 1 year ago

简单添加的话参考下面 (🤣盲写的没有实际测试,你可以试试),如果你需要动态加载啥的,可以参考文档里评论集成操作。

添加 CDN 文件

cdn: 
  css:  [//unpkg.com/gitalk/dist/gitalk.css]
  js:
    base: [//unpkg.com/gitalk/dist/gitalk.min.js]

swup: false # 关闭 Pjax

然后修改 themes\async\layout_widget\comment.ejs 文件 添加

<div id="gitalk-container"></div>

<script>
const gitalk = new Gitalk({
  clientID: 'GitHub Application Client ID',
  clientSecret: 'GitHub Application Client Secret',
  repo: 'GitHub repo',      // The repository of store comments,
  owner: 'GitHub repo owner',
  admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],
  id: location.pathname,      // Ensure uniqueness and length less than 50
  distractionFreeMode: false  // Facebook-like distraction free mode
})

gitalk.render('gitalk-container')
</script>

然后就是样式适配了,这个就看个人要求了