tags: [转载,gitlab]
categories: [CICD]


前言

折腾还是折腾,orz, 早晚得改,受不了了每天就是改博客样式,文章没写几篇!没错,我就是在喷我自己!
现在将之前NEXT主题替换为icarus,本来准备使用inside主题的,奈何生态实在不是很好,一想到之后还要修改,还是果断换了

更换主题

主题下载

下载地址:https://github.com/ppoffice/hexo-theme-icarus/releases
也能使用git clone

  1. git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus

建议还是使用下载,快啊,完毕后,放到主题文件夹中

安装依赖

icarus的依赖非常多,需要提前安装好

  1. npm install bulma-stylus
  2. npm install hexo-component-inferno
  3. npm install hexo-renderer-inferno
  4. npm install inferno
  5. npm install inferno-create-element
  6. npm install --save bulma-stylus@0.8.0

发布测试

切换到blog目录下
配置文件添加

  1. # Deployment
  2. deploy:
  3. type: git
  4. repo: git@github.com:xxxx/github.blog.git
  5. branch: master

接着执行以下脚本

  1. # 清理
  2. hexo clean
  3. # 生成文件
  4. hexo g
  5. # 部署
  6. hexo d

观察到出现以下界面表示发布成功image.png

版本回退

有点突兀,但是最新版本3.x有两点我不好处理,就退回了2.8.2,第一个就是新版本不支持Valine评论,第二点就是网络上很多配置尤其是文章栏目的调整,只有旧版本,我对前端也不是很了解,所以干脆退回了之前版本,省心

主题优化

基本配置

主要修改默认信息,主要包括

  • 作者信息
  • 菜单栏的值替换
  • 头像的替换
  • 社交链接填写
  • Valine评论功能
  • 捐赠信息

具体可以参照以下

  1. # Version of the Icarus theme that is currently used
  2. version: 2.8.1
  3. # Path or URL to the website's icon
  4. favicon: /images/favicon.svg
  5. # Additional HTML meta tags in an array.
  6. meta:
  7. # Path or URL to RSS atom.xml
  8. rss:
  9. # Path or URL to the website's logo to be shown on the left of the navigation bar or footer
  10. logo: /images/logo.svg
  11. # Open Graph metadata
  12. # https://hexo.io/docs/helpers.html#open-graph
  13. open_graph:
  14. # Facebook App ID
  15. fb_app_id:
  16. # Facebook Admin ID
  17. fb_admins:
  18. # Twitter ID
  19. twitter_id:
  20. # Twitter site
  21. twitter_site:
  22. # Google+ profile link
  23. google_plus:
  24. # Navigation bar link settings
  25. navbar:
  26. # Navigation bar menu links
  27. menu:
  28. # 首页
  29. 首页: /
  30. # 归档
  31. 归档: /archives
  32. # 分类
  33. 分类: /categories
  34. # 标签
  35. 标签: /tags
  36. #友链
  37. #友链: /friends/
  38. # 关于
  39. #关于: /about/
  40. # Navigation bar links to be shown on the right
  41. # links:
  42. # Download on GitHub:
  43. # icon: fab fa-github
  44. # url: 'https://github.com/ppoffice/hexo-theme-icarus'
  45. # Footer section link settings
  46. footer:
  47. # Links to be shown on the right of the footer section
  48. links:
  49. Creative Commons:
  50. icon: fab fa-creative-commons
  51. url: 'https://creativecommons.org/'
  52. Attribution 4.0 International:
  53. icon: fab fa-creative-commons-by
  54. url: 'https://creativecommons.org/licenses/by/4.0/'
  55. # Download on GitHub:
  56. # icon: fab fa-github
  57. # url: 'https://github.com/ppoffice/hexo-theme-icarus'
  58. # Article display settings
  59. article:
  60. # Code highlight settings
  61. highlight:
  62. # Code highlight themes
  63. # https://github.com/highlightjs/highlight.js/tree/master/src/styles
  64. theme: atom-one-light
  65. # Show code copying button
  66. clipboard: true
  67. # Default folding status of the code blocks. Can be "", "folded", "unfolded"
  68. fold: unfolded
  69. # Whether to show article thumbnail images
  70. thumbnail: true
  71. # Whether to show estimate article reading time
  72. readtime: true
  73. # Search plugin settings
  74. # https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Search
  75. search:
  76. # Name of the search plugin
  77. type: insight
  78. # Comment plugin settings
  79. # https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Comment
  80. comment:
  81. type: valine
  82. enable: true
  83. shortname: 孙博文
  84. app_id: 你的app_id
  85. app_key: 你的app_key
  86. notify: true # mail notifier , https://github.com/xCss/Valine/wiki
  87. verify: true # Verification code
  88. placeholder: 说点什么吧... # comment box placeholder
  89. avatar: retro # gravatar style
  90. guest_info: nick,mail,link # custom comment header
  91. pageSize: 10 # pagination size
  92. # Donation entries
  93. # https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Donation
  94. donate:
  95. -
  96. type: alipay
  97. # Alipay qrcode image URL
  98. qrcode: 'images/alipay.jpg'
  99. -
  100. type: wechat
  101. # Wechat qrcode image URL
  102. qrcode: 'images/wechat.png'
  103. # Share plugin settings
  104. # https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Share
  105. share:
  106. # Share plugin name
  107. type: sharejs
  108. # Sidebar settings.
  109. # Please be noted that a sidebar is only visible when it has at least one widget
  110. sidebar:
  111. # left sidebar settings
  112. left:
  113. # Whether the left sidebar is sticky when page scrolls
  114. # https://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/make-a-sidebar-sticky-when-page-scrolls/
  115. sticky: false
  116. # right sidebar settings
  117. right:
  118. # Whether the right sidebar is sticky when page scrolls
  119. # https://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/make-a-sidebar-sticky-when-page-scrolls/
  120. sticky: false
  121. # Sidebar widget settings
  122. # https://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/
  123. widgets:
  124. -
  125. # Widget name
  126. type: profile
  127. # Where should the widget be placed, left or right
  128. position: left
  129. # Author name to be shown in the profile widget
  130. author: 孙博文
  131. # Author title
  132. author_title: 我胖虎好TM想打人
  133. # Author's current location
  134. location: 中国 安徽
  135. # URL or path to the avatar image
  136. avatar: images/avatar.jpg
  137. # 头像显示为圆还是方
  138. avatar_rounded: false
  139. # Email address for the Gravatar
  140. gravatar:
  141. # URL or path for the follow button
  142. follow_link: 'https://github.com/bwensun'
  143. # Links to be shown on the bottom of the profile widget
  144. social_links:
  145. Github:
  146. icon: fab fa-github
  147. url: 'https://github.com/bwensun'
  148. 网易云:
  149. icon: fa fa-music
  150. url: 'https://music.163.com/#/user/home?id=73195716'
  151. 豆瓣:
  152. icon: fa fa-film
  153. url: 'https://www.douban.com/people/176248529/'
  154. RSS:
  155. icon: fas fa-rss
  156. url: /
  157. -
  158. # Widget name
  159. type: toc
  160. # Where should the widget be placed, left or right
  161. position: left
  162. -
  163. # Widget name
  164. type: links
  165. # Where should the widget be placed, left or right
  166. position: left
  167. # Links to be shown in the links widget
  168. links:
  169. daiwenzh5: 'https://daiwenzh5.github.io'
  170. zoombar: 'http://139.224.224.177/'
  171. -
  172. # Widget name
  173. type: category
  174. # Where should the widget be placed, left or right
  175. position: left
  176. -
  177. # Widget name
  178. type: tagcloud
  179. # Where should the widget be placed, left or right
  180. position: left
  181. -
  182. # Widget name
  183. type: recent_posts
  184. # Where should the widget be placed, left or right
  185. position: left
  186. # -
  187. # # Widget name
  188. # type: archive
  189. # # Where should the widget be placed, left or right
  190. # position: right
  191. # -
  192. # # Widget name
  193. # type: tag
  194. # # Where should the widget be placed, left or right
  195. # position: right
  196. # Other plugin settings
  197. plugins:
  198. # Enable page animations
  199. animejs: true
  200. # Enable the lightGallery and Justified Gallery plugins
  201. # https://ppoffice.github.io/hexo-theme-icarus/Plugins/General/gallery-plugin/
  202. gallery: true
  203. # Enable the Outdated Browser plugin
  204. # http://outdatedbrowser.com/
  205. outdated-browser: true
  206. # Enable the MathJax plugin
  207. # https://ppoffice.github.io/hexo-theme-icarus/Plugins/General/mathjax-plugin/
  208. mathjax: true
  209. # Show the back to top button on mobile devices
  210. back-to-top: true
  211. # Google Analytics plugin settings
  212. # https://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Google-Analytics
  213. google-analytics:
  214. # Google Analytics tracking id
  215. tracking_id:
  216. # Baidu Analytics plugin settings
  217. # https://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Baidu-Analytics
  218. baidu-analytics:
  219. # Baidu Analytics tracking id
  220. tracking_id:
  221. # Hotjar user feedback plugin
  222. # https://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Hotjar
  223. hotjar:
  224. # Hotjar site id
  225. site_id:
  226. # Show a loading progress bar at top of the page
  227. progressbar: true
  228. # BuSuanZi site/page view counter
  229. # https://busuanzi.ibruce.info
  230. busuanzi: false
  231. # 51计数
  232. tj51la: true
  233. # CDN provider settings
  234. # https://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/speed-up-your-site-with-custom-cdn/
  235. providers:
  236. # Name or URL of the JavaScript and/or stylesheet CDN provider
  237. cdn: jsdelivr
  238. # Name or URL of the webfont CDN provider
  239. fontcdn: google
  240. # Name or URL of the webfont Icon CDN provider
  241. iconcdn: fontawesome

其他功能

网站三栏变两栏

这个项目被提及最多的就是这个文章内容的布局,它的内容宽度过少,导致看起来很不舒服,作者也提到了关于这个问题的解决方案,有关这个问题的讨论可见https://github.com/ppoffice/hexo-theme-icarus/issues/434,这里只说下具体措施

  1. 修改source/css/style.styl文件中的media样式

    1. @media screen and (min-width: screen-widescreen)
    2. .is-1-column .container
    3. .is-2-column .container
    4. max-width: screen-widescreen - 2 * gap
    5. width: screen-widescreen - 2 * gap
    6. @media screen and (min-width: screen-fullhd)
    7. .is-2-column .container
    8. max-width: screen-fullhd - 2 * gap
    9. width: screen-fullhd - 2 * gap
    10. .is-1-column .container
    11. max-width: screen-desktop - 2 * gap
    12. width: screen-desktop - 2 * gap
  2. 修改一下layout/layout.ejslayout/common/widget.ejs的文件内容

    1. <% function main_column_class() {
    2. switch (column_count()) {
    3. case 1:
    4. return 'is-12';
    5. case 2:
    6. return 'is-8-tablet is-9-desktop is-9-widescreen';
    7. case 3:
    8. return 'is-8-tablet is-8-desktop is-6-widescreen'
    9. }
    10. return '';
    11. } %>
    1. <% function side_column_class() {
    2. switch (column_count()) {
    3. case 2:
    4. return 'is-4-tablet is-3-desktop is-3-widescreen';
    5. case 3:
    6. return 'is-4-tablet is-4-desktop is-3-widescreen';
    7. }
    8. return '';
    9. } %>

    Hexo拉取语雀文档到博客

    语雀的博客我一直在写,它对于markdown的语法支持,以及干净的界面让你可以关注于内容,而不是花里胡哨的界面,界面如下image.png
    所以以后也会一直把首要更新放到语雀上面来,后拉取语雀文档刷新博客,关于这一点,语雀已经做了
    官方的文档:
    我想了下,还是写上具体的步骤

  3. NMP安装插件

    1. npm i -g yuque-hexo
  4. 获取自己的Token

头像 -> 账户设置 -> Token

  1. 在blog目录下package.json中添加红线标注内容 ```json { “name”: “hexo-site”, “version”: “0.0.0”, “private”: true, “scripts”: { “build”: “hexo generate”, “clean”: “hexo clean”, “deploy”: “hexo deploy”, “server”: “hexo server” }, “hexo”: { “version”: “4.2.1” }, ————————————add start———————————————————————————— “yuqueConfig”: { “postPath”: “source/_posts/yuque”, “token”: “你的TOKEN”, “cachePath”: “yuque.json”, “mdNameFormat”: “title”, “adapter”: “hexo”, “concurrency”: 5, “baseUrl”: “https://www.yuque.com/api/v2“, “login”: “guyuefangyuan”, “repo”: “blog”, “onlyPublished”: false, “onlyPublic”: false }, ————————————-add end————————————————————————————- “dependencies”: { “bulma-stylus”: “^0.8.0”, “cheerio”: “^1.0.0-rc.3”, “hexo”: “^4.2.1”, “hexo-component-inferno”: “^0.2.7”, “hexo-deployer-git”: “^2.1.0”, “hexo-generator-archive”: “^1.0.0”, “hexo-generator-category”: “^1.0.0”, “hexo-generator-index”: “^1.0.0”, “hexo-generator-tag”: “^1.0.0”, “hexo-permalink-pinyin”: “^1.1.0”, “hexo-renderer-ejs”: “^1.0.0”, “hexo-renderer-inferno”: “^0.1.3”, “hexo-renderer-marked”: “^2.0.0”, “hexo-renderer-stylus”: “^1.1.0”, “hexo-server”: “^1.0.0”, “inferno”: “^7.4.2”, “inferno-create-element”: “^7.4.2”, “social-share.js”: “^1.0.16” } }
  1. 4. blog目录下新建yuque.json,这个文件不用写,是用来做语雀相关的缓存的,但必须得有
  2. 4. 执行命令拉取语雀文档
  3. ```shell
  4. yuque-hexo sync

可以观看到日志上的拉取内容,在post文件夹中也会多出来yuque文件夹,里面是语雀文档申城的md文件

设置语雀模板来简化标签分类以及more操作

为了文档的美观和使用方便,都会添加上文章的分类和标签,并且会将文章前言部分之后内容做隐藏,一般完成的文章会像这样
image.png
可以在语雀中自定义一个模板,将这些默认项都添加上去

  1. # 博客标题
  2. tags: [tag1,tag2]<br />categories: [分类]
  3. ---
  4. <a name="iOsWy"></a>
  5. ## 前言
  6. <br />
  7. <br />
  8. <br /><-- more -->

总结

博客弄起来是真的很折腾,我之后也不会再改这个样式了,会将注意力转到内容上来,另外我发现很多网上的东西写的没头没尾,浪费我很多的时间,写的人总是站在自己的角度考虑问题,一些自己走过的坑会下意识的忽略掉,这可能就是为什么网络上教程都是成功的,按着来都是错误的原因吧,写东西毕竟是给人看的,我如果看不明白,那就是有问题的。