惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
小众软件
小众软件
F
Fortinet All Blogs
爱范儿
爱范儿
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
C
Check Point Blog
博客园 - 聂微东
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
宝玉的分享
宝玉的分享
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Butterfly

Alternative Methods After Butterfly Removes Built-in APlayer / Meting Butterfly 5.6 Release Notes Butterfly 5.5 Release Notes Butterfly 5.4 Release Notes Butterfly 5.3 Release Notes Butterfly 5.2 Release Notes Butterfly 5.1 Release Notes Butterfly 5.0 Release Notes Butterfly 4.13 Release Notes Butterfly 4.12 Release Notes Butterfly 4.11 Release Notes Butterfly 4.10 Release Notes Butterfly Changelog Butterfly document - Advanced Tutorial Butterfly document - Q&A Butterfly document - Tag Plugins Butterfly document - Theme Configuration Butterfly document - Theme Pages Butterfly document - Get Started When Setting top_img to false Customize code coloring no cover Tag Plugins Markdown Style test
Custom Sidebar
Jerry · 2020-12-30 · via Butterfly

Applicable to >= 3.8.0

The sidebar now supports customization, allowing you to add your favorite widgets. You can add your own widgets or sort existing ones (the Blog Data and Announcement widgets are fixed, but others can be sorted).

You only need to configure the sort_order. (It uses the order property of the Flex layout. For specific details, you can refer to the Mozilla documentation. In simple terms, use numbers to specify the sorting order. If not configured, the default value is 0. The smaller the number, the higher the sorting order.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
aside:
...
card_recent_post:
sort_order:
card_categories:
sort_order:
card_tags:
sort_order:
card_archives:
sort_order:
card_webinfo:
sort_order:

newest_comments:
enable: true
sort_order:

If you want to add your own content to the sidebar, you can customize it.

Create widget.yml

Create a file widget.yml in the source/_data directory of your Hexo blog (if the _data folder doesn't exist, create it).

Format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
top:
- class_name:
id_name:
name:
icon:
html:

bottom:
- class_name:
id_name:
name:
icon:
order:
html:

Parameter Explanation

top: The created widget will appear in the non-sticky area (visible on all pages).

bottom: The created widget will appear in the sticky area (except for the article page).

ParameterExplanation
class_nameThe parent class name of the created widget (optional)
id_nameThe parent id name of the created widget (optional)
nameThe title of the created widget
iconThe icon of the created widget
orderThe sorting order of the created widget (optional)
htmlThe relevant code of the created widget

image-20201230223506507

The generated code will be:

1
2
3
4
5
6
7
8
9
<div class="card-widget Your_written_class_name" id="Your_written_id_name" style="order: Your_written_order">
<div class="item-headline">
<i class="Your_written_icon"></i>
<span>Your_written_name</span>
</div>
<div class="item-content">
Your_written_html
</div>
</div>

If you need to make UI adjustments to the added widgets, please add CSS to the inject.

Example

Let's take the Visitor Map as an example:

  1. Get the HTML code for the visitor map:

    1
    <script type="text/javascript" id="clstr_globe" src="//clustrmaps.com/globe.js?d=5V2tOKp8qAdRM-i8eu7ETTO9ugt5uKbbG-U7Yj8uMl8"></script>
  2. Create widget.yml:

    1
    2
    3
    4
    5
    6
    7
    bottom:
    - class_name: user-map
    id_name: user-map
    name: Visitor Map
    icon: fas fa-heartbeat
    order:
    html: '<script type="text/javascript" id="clstr_globe" src="//clustrmaps.com/globe.js?d=5V2tOKp8qAdRM-i8eu7ETTO9ugt5uKbbG-U7Yj8uMl8"></script>'
  3. Run Hexo

    image-20201230224442356

Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.

Buy Me a Coffee

  • Wechat

    Wechat

  • Alipay

    Alipay

  • Stripe

    Stripe

avatar

Jerry

A Simple and Card UI Design theme for Hexo

GitHub