首页分类条美化

首页分类条美化

前言

教程基于清羽飞扬的教程和轻笑的样式进行魔改,感兴趣的可以去看。

教程开始

  1. BlogRoot\themes\butterfly\layout\includes中新建categoryBar.pug
PUG
.home-catalog-bar#catalog-bar
  i.fa-fw.fas.fa-shapes
  #catalog-list(class=is_home() ? 'home' : '')
    .category-bar-item.catalog-shouye-item(class=is_home() ? 'select' : '', id="home-catalog-item")
      a(href=url_for('/'))= __('博客')
    each item in site.categories.find({ parent: { $exists: false } }).data
      .category-bar-item(class=select ? (select === item.name ? 'select' : '') : '', id=item.name)
        a(href=url_for(item.path))= item.name
  a.category-bar-more(href=url_for('/categories/'))= __('更多分类')
  1. 然后将其添加到不同的位置,比如我这里实现了添加到分类页面等位置,配合上pjax可以做到无刷更新,效果很好,打开分类文件地址:BlogRoot\themes\butterfly\layout\category.pug和主页文件地址:BlogRoot\themes\butterfly\layout\index.pug,添加其中两行代码,去掉加号即为正常缩进。这个和原教程基本一样 {% tabs 分栏 %}

{% note warning flat %} 注意:修改后需要将配置文件中,分类页面的主题改成index,否则不会显示。 {% endnote %}

PUG
extends includes/layout.pug

block content
  include ./includes/mixins/post-ui.pug
  #recent-posts.recent-posts
+    #category-bar.category-bar
+      include includes/categoryBar.pug
    +postUI
    include includes/pagination.pug

{% endtabs %} 3. 在BlogRoot\source\css\custom.css自定义样式的文件中引入如下代码(这是我的,你可以自行微调):

卡片美化
轻笑风格背景

评论区

评论加载中...