快速搭建博客:美化主题

本文详述如何使用Hexo快速搭建并美化个人博客,包括添加博客图标、鼠标点击特效、设置头像、社交图标、文章标签、访问量统计、站内搜索、文章顶置、版权信息等多个方面,让你的博客焕然一新。
摘要由CSDN通过智能技术生成

其他搭建

请先观看前几篇博客
hexo4快速搭建博客(一)快速搭建一个博客
hexo4快速搭建博客(二)更换主题
其他博文:
hexo4快速搭建博客(四)写作技巧包含图床和自动变图床的插件
hexo4搭建博客系列(五)优化博客(无坑) 部署到阿里云
hexo4搭建博客系列(六)百度,必应,谷歌收录(无坑)

然后下面这篇博文的美化几乎很全,我自己也在用,如果有错评论指出,写得多自己脑子乱乱的。
我用的版本是 hexo4.0 + NexT7.6版本。我的个人博客

1. 添加博客图标

如:1

在主题目录下_config.yml文件查询 favicon,只需要修改前两个:small和medium,图片的像素得为16像素和32像素

favicon:
  small: /images/favicon-16x16-next.png
  medium: /images/favicon-32x32-next.png
  apple_touch_icon: /images/apple-touch-icon-next.png
  safari_pinned_tab: /images/logo.svg
  #android_manifest: /images/manifest.json
  #ms_browserconfig: /images/browserconfig.xml

你可以看到这两个属性的值,/images其实完整的路径为:themes/next/source/images 这条路径来定位的。

也可以定义外部URI。

可以去图标素材:iconfonteasyicon。中下载16x16和32x32大小的PNG格式图片,然后放到themes/next/source/images下。

可以得出,要在主题某处添加什么图片都可以放在这个目录下。

2. 鼠标点击特效(二选一)

2.1 红心特效

刚刚说了主题图片可以放在themes\next\source\images,而themes\next\source有一个js文件,我们在themes\next\source\js\src(如果没有就自己创建) 下新建文件clicklove.js,然后把下面的代码copy到该文件中。

!function(e,t,a){
   function n(){
   c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),o(),r()}function r(){
   for(var e=0;e<d.length;e++)d[e].alpha<=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText="left:"+d[e].x+"px;top:"+d[e].y+"px;opacity:"+d[e].alpha+";transform:scale("+d[e].scale+","+d[e].scale+") rotate(45deg);background:"+d[e].color+";z-index:99999");requestAnimationFrame(r)}function o(){
   var t="function"==typeof e.onclick&&e.onclick;e.onclick=function(e){
   t&&t(),i(e)}}function i(e){
   var a=t.createElement("div");a.className="heart",d.push({
   el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()}),t.body.appendChild(a)}function c(e){
   var a=t.createElement("style");a.type="text/css";try{
   a.appendChild(t.createTextNode(e))}catch(t){
   a.styleSheet.cssText=e}t.getElementsByTagName("head")[0].appendChild(a)}function s(){
   return"rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"}var d=[];e.requestAnimationFrame=function(){
   return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e){
   setTimeout(e,1e3/60)}}(),n()}(window,document);

然后在\themes\next\layout_layout.swig文件末尾添加:

<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>

2.2 爆炸烟花

在themes\next\source\js\src(如果没有就自己创建) 下新建文件firework.js,然后把下面的代码copy到该文件中。

"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(
  • 7
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
这是一款多功能的WordPress主题cosy主题,丰富的布局以及令人赞叹的文章样式,无论是视频、文字、图片,都能得到淋漓尽致的展示;跨屏响应式布局,自动适应手机、平板、电脑等设备。直接进入主题今天给大家带来的是WordPress主题号称漂亮得不像实力派的Cosy主题,这个的破解花了小编团队很久的时间,但是到最后终于有了成效,给有需要的人,最后小编说一句这个源码真的是良心所做,非常的好看。主题全开源无加密,请放心下载! 响应和视网膜 适用于所有设备,支持高质量的图像和文字。 出色的SEO优化 内置经过长期验证的、强大的SEO策略,可自动获取也可自定义的SEO机制 Bigger share-社交分享2.0 nicetheme独创功能,每篇文章可生成一张封面图片,让文章在微博、朋友圈更有范。 专题归纳 列表页可插入文章专题栏目,网站干货一目了然 列表自动加载 后台可选择AJAX加载和分页加载列表文章,AJAX加载自动加载前2页 6种文章样式 多达6种文章样式,视频、文章、相册、图片都能得到淋漓尽致的展示 评论支持AJAX回复及加载 重置WP评论机制,支持添加表情/图片/链接。有邮件提醒、验证码反垃圾评论机制 多样的广告位 文章列表及文章页内置广告位,PC和WAP单独设置 数十个WP优化 针对WordPress进行数十种本地化优化,拒绝龟速加载速度 十多个小工具 重新设计默认小工具、新增广告、文章(按评论、浏览、点赞等排序)小工具 好用的主题配置后台 强大的后台配置框架,清晰有序的设置模块,小白也能快速配置
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值