【教程】Hexo+Coding搭建自己的博客网站系列5-Next6.7版本主题深度美化

news/2024/5/20 20:10:31/文章来源:https://blog.csdn.net/Fitz1318/article/details/86575488

在我进行主题优化的时候,参考了网上很多文章,但是随着Next版本的变迁,越来越多个性化设置已经被集成到Next中。所以我写了这篇关于Next6.7版本主题优化的方案。有时间和精力的话,这篇文章也会随着Next版本变迁持续更新.欢迎浏览我的博客https://fitz1318.top

主题优化

本文中介绍的主题优化主要是以下14种

  • 添加动态背景
  • 修改文章内链接文本样式
  • 文章不展示全文显示摘要
  • 修改文章底部的那个带#号的标签
  • 在每篇文章末尾统一添加“本文结束”标记
  • 修改作者头像并旋转
  • 修改``代码块自定义样式
  • 侧边栏社交设置和友情链接
  • 增加页面阅读统计,字数统计,阅读时长
  • 设置网站的图标Favicon
  • 在文章底部增加版权信息
  • 添加Valine评论系统
  • 点击爆炸效果
  • 内容页里的代码块新增复制按钮

1 添加动态背景

在主题配置文件中找到

canvas_nest:enable: trueonmobile: true # display on mobile or notcolor: '0,0,255' # RGB values, use ',' to separateopacity: 0.5 # the opacity of line: 0~1zIndex: -1 # z-index property of the backgroundcount: 90 # the number of lines

将enable改为true即可。
如果还想要实现波浪的等背景,首先需要在站点目录下打开Git bash,键入命令git clone https://github.com/theme-next/theme-next-three source/lib/three
然后还是在主题配置文件next/_config.yml中找到

# JavaScript 3D library.
# Dependencies: https://github.com/theme-next/theme-next-three
# three_waves
# 点点波浪(像海面)cpu占用极高
three_waves: true
# canvas_lines
# 点线几何体,占用最低(还是高)
canvas_lines: false
# canvas_sphere
# 球上凸点(柱?)占用高
canvas_sphere: false

想用哪一个就将其设置为true即可。

2 修改文章内链接文本样式

具体方法是修改文件themes\next\source\css\_common\components\post\post.styl,在末尾添加

// 文章内链接文本样式
.post-body p a{color: #0593d3;border-bottom: none;border-bottom: 1px solid #0593d3;&:hover {color: #fc6423;border-bottom: none;border-bottom: 1px solid #fc6423;}
}

其中选择.post-body是为了不影响标题,a是为了不影响”阅读全文“的显示样式。

3 文章不展示全文显示摘要

修改/themes/next/_config.yml

scroll_to_more: true        #如果文章有摘要,会自动滚动到摘要下面
save_scroll: true           #通过cookies来缓存阅读进度
excerpt_description: true   #自动摘录描述作为序言
auto_excerpt:               #设置阅读全文enable: truelength: 150               #摘要次数
read_more_btn: true         #阅读全文按钮

4 修改文章底部的那个带#号的标签

修改模板/themes/next/layout/_macro/post.swig,搜索rel="tag">#,将 # 换成<i class="fa fa-tag"></i>,tag的更多设置在themes/next/source/css/_common/components/tag-cloud.styl中可以修改样式

.tag-cloud {   //设置标签text-align: center;     //展示位置,左、中、右a {display: inline-block;margin: 10px;         //字体大小}a:hover {color: $link-hover-color !important;}
}

5 在每篇文章末尾统一添加“本文结束”标记

在路径 \themes\next\layout\_macro 中新建 passage-end-tag.swig 文件,并添加以下内容:

<div>{% if not is_index %}<div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>{% endif %}
</div>

接着打开\themes\next\layout\_macro\post.swig文件,在post-body 之后, post-footer 之前添加如下画红色部分代码(post-footer之前两个DIV):
在这里插入图片描述

6 修改作者头像并旋转

位置在/themes/next/_config.yml

avatar:url: /images/avatar.png  #这里设置自己的头像rounded: falseopacity: 1  #不透明度rotated: false  #true为开启旋转

7 修改``代码块自定义样式

打开\themes\next\source\css\_custom\custom.styl,向里面加入:(颜色可以自己定义)

// Custom styles.
code {color: #ff7600;background: #fbf7f8;margin: 2px;
}
// 大代码块的自定义样式
.highlight, pre {margin: 5px 0;padding: 5px;border-radius: 3px;
}
.highlight, code, pre {border: 1px solid #d6d6d6;
}

8 侧边栏社交设置和友情链接

修改/themes/next/_config.yml

site_state: true# Social Links
# Usage: `Key: permalink || icon`
# Key is the link label showing to end users.
# Value before `||` delimeter is the target permalink.
# Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, globe icon will be loaded.
social:CSDN: https://blog.csdn.net/Fitz1318 || copyrightGitHub: https://github.com/Fitz1318 || githubZhihu: https://www.zhihu.com/people/fitz-99/activitiessocial_icons:  #这里是上面社交链接的对应图标enable: trueCSDN: copyrightGithub: githubZhihu: zhihuicons_only: falsetransition: true# Follow me on GitHub banner in right-top corner.
# Usage: `permalink || title`
# Value before `||` delimeter is the target permalink.
# Value after `||` delimeter is the title and aria-label name.
#github_banner: https://github.com/Fitz1318 || Follow me on GitHub# Blog rolls  #这里时设置一些相关链接 我这里设置了一些推荐阅读的网站
#links_icon: link
links_title: 实用网站
#links_layout: block
links_layout: inline
links:W3Cschool: http://www.w3school.com.cn/改图宝: http://www.gaitubao.com/程序员的工具箱: https://tool.lu/

9 增加页面阅读统计,字数统计,阅读时长

在站点目录下键入命令npm install hexo-symbols-count-time --save,然后打开主题配置文件/themes/next/_config.yml搜索busuanzi_count并修改

busuanzi_count:enable: false                #设true 开启total_visitors: true         #总阅读人数 uv数total_visitors_icon: user    #阅读总人数的图标total_views: true            #总阅读次数 pv数total_views_icon: eye        #阅读总次数的图标post_views: true             #开启内容阅读次数post_views_icon: eye         #内容页阅读数的图标

同时搜索并修改symbols_count_time

symbols_count_time:        #字数与阅读时间统计设置separated_meta: true     # false 会显示一行item_text_post: true     # 显示属性名称,设为false后只显示图标和统计数字,不显示属性的文字item_text_total: true    #底部footer是否显示字数统计属性文字awl: 4                   #计算字数的一个设置,没设置过wpm: 275                 #一分钟阅读的字数

最后在站点配置文件_config.yml中新增如下代码

#显示阅读时间
symbols_count_time:
#文章内是否显示
symbols: true
time: true
# 网页底部是否显示
total_symbols: true
total_time: true

10 设置网站的图标Favicon

favicon:       #这里配置站点的站标
small: /images/plane.png
medium: /images/plane.png
rss:
footer:        #网站的页脚设置
since: 2019    #网站的开始运行时间
# Icon between year and copyright info.
icon:name: heart  #年份和版权之间的图标# If you want to animate the icon, set it to true.animated: true# Change the color of icon, using Hex Code.color: "ff0000"``````

11 在文章底部增加版权信息

/themes/next/_config.yml中搜索并修改

creative_commons:      #设置版权原创声明的地方license: by-ncsidebar: falsepost: true

12 添加Valine评论系统

点击官网leancloud注册账号,获取自己的appid,appkey,再看valine官网设置下自己的leancloud
在祖逖配置文件中/themes/next/_config.yml修改

valine:enable: true # 开启评论appid:  ~~~  # 你的 leancloud 的 appidappkey:  ~~~ # 你的 leancloud 的 appkeynotify: false # 是否邮件推送 详情看 https://github.com/xCss/Valine/wikiverify: false # placeholder: Just go go # 评论框里的placeholder信息avatar: mm # gravatar styleguest_info: nick,mail,link # custom comment headerpageSize: 10 # 一页显示的评论条数visitor: false # 

13 点击爆炸效果

首先在themes/next/source/js/src里面建一个叫fireworks.js的文件,代码如下:

"use strict";function updateCoords(e){pointerX=(e.clientX||e.touches[0].clientX)-canvasEl.getBoundingClientRect().left,pointerY=e.clientY||e.touches[0].clientY-canvasEl.getBoundingClientRect().top}function setParticuleDirection(e){var t=anime.random(0,360)*Math.PI/180,a=anime.random(50,180),n=[-1,1][anime.random(0,1)]*a;return{x:e.x+n*Math.cos(t),y:e.y+n*Math.sin(t)}}function createParticule(e,t){var a={};return a.x=e,a.y=t,a.color=colors[anime.random(0,colors.length-1)],a.radius=anime.random(16,32),a.endPos=setParticuleDirection(a),a.draw=function(){ctx.beginPath(),ctx.arc(a.x,a.y,a.radius,0,2*Math.PI,!0),ctx.fillStyle=a.color,ctx.fill()},a}function createCircle(e,t){var a={};return a.x=e,a.y=t,a.color="#F00",a.radius=0.1,a.alpha=0.5,a.lineWidth=6,a.draw=function(){ctx.globalAlpha=a.alpha,ctx.beginPath(),ctx.arc(a.x,a.y,a.radius,0,2*Math.PI,!0),ctx.lineWidth=a.lineWidth,ctx.strokeStyle=a.color,ctx.stroke(),ctx.globalAlpha=1},a}function renderParticule(e){for(var t=0;t<e.animatables.length;t++){e.animatables[t].target.draw()}}function animateParticules(e,t){for(var a=createCircle(e,t),n=[],i=0;i<numberOfParticules;i++){n.push(createParticule(e,t))}anime.timeline().add({targets:n,x:function(e){return e.endPos.x},y:function(e){return e.endPos.y},radius:0.1,duration:anime.random(1200,1800),easing:"easeOutExpo",update:renderParticule}).add({targets:a,radius:anime.random(80,160),lineWidth:0,alpha:{value:0,easing:"linear",duration:anime.random(600,800)},duration:anime.random(1200,1800),easing:"easeOutExpo",update:renderParticule,offset:0})}function debounce(e,t){var a;return function(){var n=this,i=arguments;clearTimeout(a),a=setTimeout(function(){e.apply(n,i)},t)}}var canvasEl=document.querySelector(".fireworks");if(canvasEl){var ctx=canvasEl.getContext("2d"),numberOfParticules=30,pointerX=0,pointerY=0,tap="mousedown",colors=["#FF1461","#18FF92","#5A87FF","#FBF38C"],setCanvasSize=debounce(function(){canvasEl.width=2*window.innerWidth,canvasEl.height=2*window.innerHeight,canvasEl.style.width=window.innerWidth+"px",canvasEl.style.height=window.innerHeight+"px",canvasEl.getContext("2d").scale(2,2)},500),render=anime({duration:1/0,update:function(){ctx.clearRect(0,0,canvasEl.width,canvasEl.height)}});document.addEventListener(tap,function(e){"sidebar"!==e.target.id&&"toggle-sidebar"!==e.target.id&&"A"!==e.target.nodeName&&"IMG"!==e.target.nodeName&&(render.play(),updateCoords(e),animateParticules(pointerX,pointerY))},!1),setCanvasSize(),window.addEventListener("resize",setCanvasSize,!1)}"use strict";function updateCoords(e){pointerX=(e.clientX||e.touches[0].clientX)-canvasEl.getBoundingClientRect().left,pointerY=e.clientY||e.touches[0].clientY-canvasEl.getBoundingClientRect().top}function setParticuleDirection(e){var t=anime.random(0,360)*Math.PI/180,a=anime.random(50,180),n=[-1,1][anime.random(0,1)]*a;return{x:e.x+n*Math.cos(t),y:e.y+n*Math.sin(t)}}function createParticule(e,t){var a={};return a.x=e,a.y=t,a.color=colors[anime.random(0,colors.length-1)],a.radius=anime.random(16,32),a.endPos=setParticuleDirection(a),a.draw=function(){ctx.beginPath(),ctx.arc(a.x,a.y,a.radius,0,2*Math.PI,!0),ctx.fillStyle=a.color,ctx.fill()},a}function createCircle(e,t){var a={};return a.x=e,a.y=t,a.color="#F00",a.radius=0.1,a.alpha=0.5,a.lineWidth=6,a.draw=function(){ctx.globalAlpha=a.alpha,ctx.beginPath(),ctx.arc(a.x,a.y,a.radius,0,2*Math.PI,!0),ctx.lineWidth=a.lineWidth,ctx.strokeStyle=a.color,ctx.stroke(),ctx.globalAlpha=1},a}function renderParticule(e){for(var t=0;t<e.animatables.length;t++){e.animatables[t].target.draw()}}function animateParticules(e,t){for(var a=createCircle(e,t),n=[],i=0;i<numberOfParticules;i++){n.push(createParticule(e,t))}anime.timeline().add({targets:n,x:function(e){return e.endPos.x},y:function(e){return e.endPos.y},radius:0.1,duration:anime.random(1200,1800),easing:"easeOutExpo",update:renderParticule}).add({targets:a,radius:anime.random(80,160),lineWidth:0,alpha:{value:0,easing:"linear",duration:anime.random(600,800)},duration:anime.random(1200,1800),easing:"easeOutExpo",update:renderParticule,offset:0})}function debounce(e,t){var a;return function(){var n=this,i=arguments;clearTimeout(a),a=setTimeout(function(){e.apply(n,i)},t)}}var canvasEl=document.querySelector(".fireworks");if(canvasEl){var ctx=canvasEl.getContext("2d"),numberOfParticules=30,pointerX=0,pointerY=0,tap="mousedown",colors=["#FF1461","#18FF92","#5A87FF","#FBF38C"],setCanvasSize=debounce(function(){canvasEl.width=2*window.innerWidth,canvasEl.height=2*window.innerHeight,canvasEl.style.width=window.innerWidth+"px",canvasEl.style.height=window.innerHeight+"px",canvasEl.getContext("2d").scale(2,2)},500),render=anime({duration:1/0,update:function(){ctx.clearRect(0,0,canvasEl.width,canvasEl.height)}});document.addEventListener(tap,function(e){"sidebar"!==e.target.id&&"toggle-sidebar"!==e.target.id&&"A"!==e.target.nodeName&&"IMG"!==e.target.nodeName&&(render.play(),updateCoords(e),animateParticules(pointerX,pointerY))},!1),setCanvasSize(),window.addEventListener("resize",setCanvasSize,!1)};

打开themes/next/layout/_layout.swig,在上面写下如下代码:

{% if theme.fireworks %}<canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas> <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> <script type="text/javascript" src="/js/src/fireworks.js"></script>
{% endif %}

打开主题配置文件,在里面最后写下:fireworks: true

14 内容页里的代码块新增复制按钮

打开主题配置文件,在里面搜索,并作适当修改

codeblock:# Manual define the border radius in codeblock# Leave it empty for the default 1border_radius:# Add copy button on codeblockcopy_button:     #增加复制按钮开关enable: true# Show text copy resultshow_result: true

参考文章:
https://blog.csdn.net/marvinboy/article/details/83350437
http://shenzekun.cn/hexo的next主题个性化配置教程.html
https://www.simon96.online/2018/10/12/hexo-tutorial/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_850814.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端开发值得收藏的网站

工作空闲时间&#xff0c;作为前端开发人员&#xff0c;还是希望利用好这段宝贵的时间多学习一些前端资源&#xff0c;了解当前前端知识体系&#xff0c;从整体上对当前行业有一个由浅入深的了解和掌握。后续还会慢慢更新好用的前端相关网站&#xff0c;加油&#xff01; 1.Co…

服务器电脑无限重启,win10电脑蓝屏无限重启_网站服务器运行维护

win10电脑锁屏时间设置_网站服务器运行维护win10电脑锁屏时间设置方法是&#xff1a;1、首先点击【windows】&#xff0c;点击【设置】&#xff1b;2、然后点击【系统】选项&#xff0c;选择【电源和睡眠】选项&#xff1b;3、最后设置锁屏时间即可。第一步&#xff1a;进入Win…

设计响应式网站-Bootstrap(1)

1.Bootstra介绍 2011年&#xff0c;twitter的“一小撮”工程师为了提高他们内部的分析和管理能力&#xff0c;用业余时间为他们的产品构建了一套易用、优雅、灵活、可扩展的前端工具集--BootStrap。Bootstrap由MARK OTTO和Jacob Thornton所设计和建立&#xff0c;在github上开…

财经资讯网站--某联社参数破解

本文仅供学习&#xff0c;如有侵权或问题联系博主&#xff0c;感谢阅读 目标链接&#xff1a;aHR0cHM6Ly93d3cuY2xzLmNuL2RlcHRoP2lkPTEwMDA 抓包分析&#xff1a; 可以看到加密参数只有一个sign&#xff0c;像这种sign的一搜肯定一堆。所以我拿sv去搜了&#xff0c;看着像m…

源码或学习网站

网站 项目管理网站 开源中国&#xff1a;码云 CSDN: Coding GitHub 阅读 教程 |Android Studio 发布开源项目到JCenter 源码 1&#xff1a;APKBUS:使用MVP模式简单地展示知乎日报主页及内容, Github:AZhiHu 2 高仿知乎日报 3 ZhihuDailyPurify - 知乎日报净化 4 菜…

网站开发预备知识

1.网络系统开发模式 &#xff08;1&#xff09;B/S&#xff1a;brower/server 浏览器/服务器 &#xff08;2&#xff09;C/S: client/server 客户端/服务器 2.URL &#xff08;1&#xff09;全称&#xff1a;Uniform Resource Locator 统一资源定位符&#xff08;网址&#xf…

网站收集

一、生活类 1. 蛙蛙工具——找工具 这是一个便捷的在线工具集合网站&#xff0c;集合了数百种实用工具。它的工具查询是非常便捷的&#xff0c;在便民查询中&#xff0c;我们可以查询电话号码的归属地&#xff0c;身份证的所在地&#xff0c;邮政编码的查询等等&#xff0c;蛙…

去除手机浏览器访问CSDN网站的提示

文章目录前言一、烦人的提示二、寻找解决方法三、编写脚本1.去除打开APP提示2.自动展开3.复制代码四、完整代码五、效果展示总结前言 有时候想用手机查查程序问题&#xff0c;用手机浏览器访问总是弹出打开App、登录烦人的提示 一、烦人的提示 用手机看几篇文章&#xff0c;打…

XUESQL-自学SQL网站上的练习题

SQL学习及习题答案( XUESQL) 1.SELECT 查询 请列出所有电影的ID&#xff0c;名称和出版国 SELECT title,id,美国 as country FROM moviesSQL Lesson 7: 外连接&#xff08;OUTER JOINs&#xff09; INNER JOIN 只会保留两个表都存在的数据&#xff08;还记得之前的交集吗&a…

SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎

前两天看到了一个中国新闻网&#xff0c;这个网站的搜索form的action是 http://search.chinanews.com/search.do 便知道是struts1的产物&#xff0c;现在都用struts2了&#xff0c;所以给自己的任务是实现Struts2 SSH分页浏览新闻、Lucene分页高亮排序搜索新闻这个两个功能。…

个人搭建网站的服务器选择

关于这方面之前一直准备分享一下心得&#xff0c;由于一直比较忙&#xff0c;各种想写的就各种耽搁了&#xff0c;今天给大家总结一下个人或小型企业站该如何选择网站服务器 首先&#xff0c;先弄清楚自己的需求和用途&#xff1a; 1、是建立一个静态页面还是动态页面&#xff…

Hexo+GitHub搭建个人网站全网最详细教程

前言 这个故事很长&#xff0c;还要从一只蝙蝠说起&#xff01; 大二寒假在家闲来无事一直想做一个网站但是苦于没有门路&#xff0c;于是我去各大论坛搜索关于搭建网站的资料&#xff0c;这一搜还真给搜到了&#xff0c;于是这一套HexoGitHub搭建个人博客网站的方略就加入了…

教你快速搭建个人网站

一、搭建环境&#xff1a; 云主机华为云操作系统centos 7.x源码GitHub - wyt1215819315/autoplan: 这是一个自动化的托管系统&#xff0c;目前支持网易云&#xff0c;bilibili&#xff0c;米游社原神签到&#xff0c;测试地址https://auto.oldwu.top协助软件宝塔面板 二、网站…

(入门级)安利学习网站

作为初学者&#xff0c;如何快速入门学习并保持学习的兴趣&#xff0c;好的学习工具必不可少。无论你是跟着老师学习还是自学&#xff0c;菜鸟教程都是比较好的。当然你也可以在网上百度&#xff0c;但是信息比较杂并不建议初学者&#xff08;主要是看不懂和打击学习兴趣&#…

使用 Nginx 提升网站访问速度

Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器&#xff0c;也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的&#xff0c;它已经在该站点运行超过两年半了。 Igor 将源代码以类 BSD 许可证的…

网站的基本内容

简史 编辑 语音 因特网起源于美国国防部高级研究计划管理局建立的阿帕网。 [1] 阿帕网于1968年开始组建 &#xff0c;1969 年第一期工程投入使用。开始时只有4个节点。1970年的ARPANET&#xff08;阿帕网&#xff09;已初具雏形&#xff0c;并且开始向非军用部门开放&#x…

Burp Suite暴力破解网站密码

一、准备&#xff1a; 1&#xff0c;靶场&#xff1a;个人选择DVWA。 2&#xff0c;工具&#xff1a;Burp Suite。 3&#xff0c;密码字典。二、开搞&#xff01;&#xff1a; 注&#xff1a;任何未经授权的渗透测试皆为违法&#xff0c;本文仅供学习&#xff0c;维护网络安全…

[Python]工具网站

正则表达式转换&#xff1a;RegExr: Learn, Build, & Test RegExRegular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.https://regexr.com/ Regex正则表达式…

高性能网站实用技巧之消息队列

什么是消息队列&#xff1f; 消息队列&#xff08; Message Queue &#xff09;是一种进程间通信或同一进程的不同线程间的通信方式。进程或者线程之间通过 消息 进行通信&#xff0c;消息发送后可以立即返回&#xff0c;由消息系统来确保信息的可靠传递&#xff0c;消息发布者…

阿里大牛详解分布式系统,大型网站分布式系统实战解析

分布式系统 分布式系统从当初的CORBA 到EJB&#xff0c;Web和SOA&#xff0c;从集群到现在的NoSQL 云计算和大数据Hadoop等分布式系统&#xff0c;横向水平扩展Scala out/in是分布式系统设计的一个特点&#xff0c;可靠性 容错性是两个质量指标。 什么是分布式系统&#xff1…