Welcome to Hexo! 🧡🧡🧡

This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

图片排列


如何使用文档系统

Stellar 独创了其它 Hexo 主题所没有的 Wiki 系统,可以自动找到一个项目的所有文档分页,生成一个目录树,还可以手动指定顺序、标题、分组,而非依赖文件路径、文件名来排序和显示。

创建一个项目

blog/source/ 文件夹中创建一个 wiki 文件夹,在其中放入各个项目的文档。以 Stellar 项目为例:

1
blog/source/wiki/stellar/index.md

设置布局模板和项目名称:

blog/source/wiki/stellar/index.md
1
2
3
4
5
---
layout: wiki # 使用wiki布局模板
wiki: Stellar # 这是项目名
title: 这是分页标题
---

建议用这个文件作为项目的主页,并在文件夹内创建其它分页。Stellar 会把同一个项目的所有分页中 order 最小的一页作为项目的主页(其默认值为0)。

完善项目信息

在数据文件中创建项目文件,以 Stellar 为例:

blog/source/_data/projects.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Stellar:
name: Stellar
title: Stellar - 每个人的独立博客
subtitle: '每个人的独立博客 | Designed by xaoxuu'
tags: 博客主题
cover: true
logo:
src: /assets/wiki/stellar/icon.svg
small: 112px
large: 240px
description: Stellar 是一个内置 wiki 系统的 hexo 主题,适合综合型站点使用。同时也拥有简约而精美的视觉设计和丰富的标签插件,帮助您简单从容地应对各种场合。
repo: xaoxuu/hexo-theme-stellar
comment_title: '评论区仅供交流,有问题请提 [issue](https://github.com/xaoxuu/hexo-theme-stellar/issues) 反馈。'
giscus:
data-repo: xaoxuu/hexo-theme-stellar
data-mapping: number
data-term: 226

是否显示封面

项目可以显示一个全屏封面,封面占据一个屏幕的高度,会居中依次显示项目的 logo、标题、描述。开启项目封面方法如下:

blog/source/_data/projects.yml
1
2
3
4
5
6
Stellar:
cover: true
logo:
src: /assets/wiki/stellar/icon.svg
small: 120px
large: 240px

如果 logo 中已经包含了项目标题,可以这样设置不显示项目标题:

blog/source/_data/projects.yml
1
2
Stellar:
cover: [logo, description]

项目文档标签

如果您有很多项目,有些项目是有相关性的,可以相同的 tags 值:

blog/source/_data/projects.yml
1
2
Stellar:
tags: 博客主题

也可以设置多个 tags 值:

blog/source/_data/projects.yml
1
2
Stellar:
tags: [博客主题, 开源项目]

项目的 GitHub 仓库信息

设置了 repo 值就会在侧边栏显示项目仓库的相关链接:

blog/source/_data/projects.yml
1
2
Stellar:
repo: xaoxuu/hexo-theme-stellar

项目评论设置

如果希望项目的所有分页使用相同的评论数据,可以在这里覆盖评论配置:

blog/source/_data/projects.yml
1
2
3
4
5
6
7
Stellar:
comment_title: '评论区仅供交流,有问题请提 [issue](https://github.com/xaoxuu/hexo-theme-stellar/issues) 反馈。'
comments:
giscus:
data-repo: xaoxuu/hexo-theme-stellar
data-mapping: number
data-term: 226

是否需要被索引

如果您有些项目希望在项目列表中隐藏,可以设置 index 值:

blog/source/_data/projects.yml
1
2
Stellar:
index: false

文档排序

一个项目文档的多个分页之间以 order 的值作为排序依据,数字越小越靠前,最小的是项目主页。

侧边栏设置

侧边栏组件

如果您希望自定义某个项目的侧边栏组件,可以设置 sidebar 值:

blog/source/_data/projects.yml
1
2
Notes:
sidebar: [toc]

对目录树进行分组

如果您的项目文档分页较多,可以对目录树进行分组:

blog/source/_data/projects.yml
1
2
3
4
5
6
7
Stellar:
...
sections:
'快速开始': [0, 99]
'基本使用': [100, 199]
'文档系统': [200, 299]
'进阶设定': [900, 999]

左边是显示的标题,右边是 order 的区间,例如某页文档的 order150,那么这页文档将会显示在「日常问题解决方案」这个组中。

指定 wiki 路径

在根目录中添加 wiki_dir 指定 Wiki 主页的路径,若不指定路径,您在点击返回所有项目时会回到主页而非回到所有项目。

blog/_config.yml
1
wiki_dir: wiki

例如书籍类的“项目”可以改为:

blog/_config.yml
1
wiki_dir: books

例如商品/产品类的“项目”可以改为:

blog/_config.yml
1
wiki_dir: products

自定义小组件的配置与使用(8个)

实现并显示一个小组件需要两个步骤:

  1. 【配置】在组件库中声明组件
  2. 【使用】在需要的位置调用

组件库在 _data/widgets.yml 文件中,需要自己创建,内容形如:

1
2
3
'我的小组件1':
layout: 小组件布局模板
...(其它属性)

使用的地方有:【主题配置】、【项目配置】、【页面】,后者可以覆盖前者,例如:

blog/source/_posts/xxx.md
1
2
3
---
sidebar: ['我的小组件1', '我的小组件2']
---

组件库

在创建组件时,您可以使用以下这些 layout 布局:

toc

这是文章/文档的目录树组件,显示文章和文档的目录结构:

blog/source/_data/widgets.yml
1
2
3
4
5
6
toc:
layout: toc
list_number: false # 是否显示序号
min_depth: 2 # 建议不要低于 2 即从 H2 标签开始解析(H1标签用于文章大标题)
max_depth: 5 # 5 代表最多解析到 H5 标签
fallback: recent # Use a backup widget when toc does not exist.

tocfallback 默认是 recent,即一篇文章没有 TOC 的时候会显示一个 recent

recent

blog/source/_data/widgets.yml
1
2
3
4
recent:
layout: recent
rss: # /atom.xml # npm i hexo-generator-feed
limit: 5 # Count of posts

wiki 板块显示的是最近更新的 wiki 页面,其余地方显示最近更新的文章。

hexo 的覆盖规则是合并而不是替换,所以若不想使用 recent,除了在 _config.stellar.yml 中删除 recent 你还需要将此处的 recent 置空,即

blog/source/_data/widgets.yml
1
2
3
4
recent:
# layout: recent
# rss: # /atom.xml # npm i hexo-generator-feed
# limit: 5 # Count of posts

然后自己需要的地方用自己另建的一个 my_recent 组件

blog/source/_data/widgets.yml
1
2
3
my_recent:
layout: recent
...

相关文档组件,用于显示具有相同 tags 的其它项目列表,暂不支持自定义内容:

Stellar 1.12.0 已将 wiki_more,更名为 related

blog/source/_data/widgets.yml
1
2
related:
layout: related

markdown

这是一个自由度很高的标签,可以显示 markdown 文本内容:

blog/source/_data/widgets.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
welcome:
layout: markdown
title: 欢迎欢迎
content: |
欢迎使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar/) 主题,下面是您的入门指南,祝您使用愉快!
<br>
**第一步**
创建 `blog/_config.stellar.yml` 文件,在此文件中填写需要自定义的主题配置。
<br>
**第二步**
创建 `blog/source/_data/widgets.yml` 文件,此文件中填写需要自定义的侧边栏组件,例如 `welcome` 组件。
<br>
如果有任何疑问,请先查阅 [文档](https://xaoxuu.com/wiki/stellar/),如果文档中没有提供,请提 [issue](https://github.com/xaoxuu/hexo-theme-stellar/issues/) 向开发者询问。

tagcloud

标签云组件:

blog/source/_data/widgets.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
tagcloud:
layout: tagcloud
title: 标签云
# 标签云配置
min_font: 12
max_font: 24
amount: 100
orderby: name
order: 1 # 1, sac 升序;-1, desc 降序
color: false # 使用颜色
start_color: # 开始的颜色。您可使用十六进位值('#b700ff'),rgba(rgba(183, 0, 255, 1)),hsla(hsla(283, 100%, 50%, 1))或 颜色关键字。此变量仅在 color 参数开启时才有用。
end_color: # 结束的颜色。您可使用十六进位值('#b700ff'),rgba(rgba(183, 0, 255, 1)),hsla(hsla(283, 100%, 50%, 1))或 颜色关键字。此变量仅在 color 参数开启时才有用。
show_count: false # 显示每个标签的文章总数

ghuser

显示 GitHub 用户基础信息卡片:

blog/source/_data/widgets.yml
1
2
3
4
5
ghuser:
layout: ghuser
username: github # your github login username
avatar: true # show avatar or not
menu: true # show menu or not

因为它和侧边栏左上角默认的 header 功能存在重复,所以建议隐藏默认的 header 组件:

blog/source/_posts/xxx.md
1
2
3
4
5
---
title: 某一篇文章
sidebar: [ghuser, ...]
header: false # 不显示左上角的 logo 和 menu
---

ghrepo

显示 GitHub 仓库基础信息,需要搭配 repo 一起使用:

blog/source/_data/widgets.yml
1
2
ghrepo:
layout: ghrepo

需要在需要显示的文章页面的 front-matter 中按照如下格式写上仓库持有者和仓库名:

blog/source/_posts/xxx.md
1
2
3
---
repo: xaoxuu/hexo-theme-stellar
---

如果需要显示在 wiki 项目中,则在 _data/projects.yml 中填写到对应项目的信息中:

blog/source/_data/projects.yml
1
2
3
4
5
Stellar:
title: Stellar
subtitle: '每个人的独立博客 | Designed by xaoxuu'
repo: xaoxuu/hexo-theme-stellar
...

timeline

时间线组件,这个功能在 1.12.0 版本后开始支持:

动态数据是从 GitHub Issues 中拉取的,使用方法为:

widgets.yml 中新建配置

blog/source/_data/widgets.yml
1
2
3
4
5
6
timeline:
layout: timeline
title: 近期动态
api: https://api.github.com/repos/xaoxuu/hexo-theme-stellar/issues # 若你想限制数量,在api链接后面加上?per_page=1指限制为1条
user: # 是否过滤只显示某个人发布的内容,如果要筛选多人,用英文逗号隔开
hide: # title,footer # 隐藏标题或底部 # 此功能需要 Stellar v1.13.0

这个功能在 1.13.0 版本后开始支持。

https://xaoxuu.com/wiki/stellar/fcircle/

blog/source/_data/widgets.yml
1
2
3
4
5
6
7
# 愣着干啥,新建啊
'朋友圈':
layout: timeline
title: 近期动态
api: https://api.vlts.cc/output_data/v1/xaoxuu/friends-rss-generator # 你的朋友圈数据文件地址
type: fcircle
limit: # 可通过这个限制最大数量

这个功能在 1.18.0 版本后开始支持:

blog/source/_data/widgets.yml
1
2
3
4
5
6
weibo:
layout: timeline
title: 微博动态
api: https://raw.githubusercontent.com/GitHub用户名/仓库名/output/output/tweets.json # 你的微博爬取数据文件地址
type: weibo
limit: 20

无论是哪种动态数据,你都可以在 _config.stellar.yml 中设置引用

blog/_config.stellar.yml
1
2
3
4
sidebar:
...
widgets:
home: welcome, recent, 朋友圈, weibo

或者在你需要显示的页面引入,页面内引入优先于配置文件引入:

blog/source/_posts/xxx.md
1
2
3
---
sidebar: [ghuser, search, 朋友圈]
---

配置默认布局

主题配置中可以配置默认布局顺序,在这些页面中,侧边栏会按照指定的顺序从组件库中读取组件并显示:

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sidebar:
...
widgets:
#### 自动生成的页面 ####
# 主页
home: search, welcome, recent, timeline # for home
# 博客索引页
blog_index: search_blog, recent, timeline # for categories/tags/archives
# 文档索引页
wiki_index: search_docs, recent, timeline # for wiki
# 其它(404)
others: search, welcome, recent, timeline # for 404 and ...
#### 手动创建的页面 ####
# 文章内页
post: toc, ghrepo, search, ghissues # for pages using 'layout:post'
# 文档内页
wiki: search, ghrepo, toc, ghissues, related # for pages using 'layout:wiki'
# 其它 layout:page 的页面
page: welcome, toc, search # for custom pages using 'layout:page'

灵活用法

继承(覆盖)组件

适合有多个相似组件的情况,例如有多个时间线组件,显示规则相同,仅 api 地址不同:

blog/source/_data/widgets.yml
1
2
3
4
5
6
my_timeline_lite:
layout: timeline
title: 近期动态
user: xaoxuu
hide: title,footer
api:

在不同的页面设置不同的 api 地址:

blog/source/_posts/xxx.md
1
2
3
4
5
6
7
---
title: 某一篇文章
sidebar:
- toc # 只写一个字符串代表引用对应的通用组件
- override: my_timeline_lite
api: https://xxx
---

匿名组件:仅在使用时创建

适合仅在一个页面或项目中才需要用到的组件,例如在某个页面的侧边栏放一个公告:

blog/source/_posts/xxx.md
1
2
3
4
5
6
7
8
9
10
11
12
---
title: 某一篇文章
sidebar:
- toc # 只写一个字符串代表引用对应的通用组件
- layout: markdown
title: '重要通知 [NOTE.2022-09]'
content: |
请不要原封不动的把本站内容复制到贵站中使用,这样一方面不尊重原作者,另一方面也会因为存在大量重复内容影响贵站收录甚至降权。
从2022年9月起本站已不再开源,已经持有源码副本或`fork`的朋友请及时删除以防止被他人恶意搬运的情况继续发生。

[> 了解详情](https://github.com/xaoxuu/xaoxuu.github.io#readme)
---

又或者在项目的配置文件中创建专属于这个项目的组件:

blog/_data/projects.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
Stellar:
name: Stellar
title: Stellar - 每个人的独立博客
subtitle: '每个人的独立博客 | Designed by xaoxuu'
sidebar:
- search
- toc
- ghrepo
- layout: timeline
title: 最近更新
api: https://api.github.xaox.cc/repos/xaoxuu/hexo-theme-stellar/releases?per_page=1
hide: footer
...

网站和主题基本信息配置

站点信息

Stellar 会读取站点根目录下的 _config.yml 文件中的一些信息来生成您的网站,所以您需要修改以下值:

blog/_config.yml
1
2
3
4
5
6
7
8
title: 您的网站名称
avatar: 您的头像链接
favicon: 您的网站icon
subtitle: 您的网站副标题
# 多语言
language:
- zh-CN
- en

更多关于 Hexo 文件的配置请移步官方文档

官方文档

多语言设置

主题中的默认文案都支持多语言,以简体中文为例,您可以在 themes/stellar/languages/zh-CN.yml 中修改文案。

更改网站优先语言,需要在站点根目录下的配置文件中进行修改:

blog/_config.yml
1
2
3
4
language:
- zh-CN
- en
- zh-TW

创建主题配置文件

在博客根目录的 _config.yml 文件旁边新建一个文件: _config.stellar.yml ,在这个文件中的配置信息优先级高于主题文件夹中的配置文件。

头部标签自定义

Open Graph

默认生成 Open Graph 标签,如果您不希望生成它,可以在主题配置文件中关闭:

blog/_config.stellar.yml
1
2
3
open_graph:
enable: true
twitter_id: # for open_graph meta

容器类标签(7个)

box 普通块容器

note 标签就是使用 box 容器实现的,它们样式是相同的:

更名记录(Stellar 1.18.0)

因为原 noteblock 标签在升级到 hexo 6.0 之后跟官方库冲突了,官方一直没有解释原因,后不得不改名:
noteblock -> grid -> border -> box
详情见:#172

语法格式
1
2
3
{% box [title] [color:color] [child:codeblock/tabs] %}
...
{% endbox %}
写法如下
1
2
3
4
5
{% box Stellar v1.12.0 color:warning %}
因为原 noteblock 标签在升级到 hexo 6.0 之后跟官方库冲突了,官方一直没有解释原因,后不得不改名:
noteblock -> grid -> border
详情见:[#172](https://github.com/volantis-x/hexo-theme-volantis/issues/712)
{% endbox %}

彩色代码块

设置 child:codeblock 并设置 color:颜色枚举 可以实现 10 种不同颜色的代码块,彩色代码块一般可以用在代码正确与错误的示范对比场景。

推荐的写法

1
2
3
func test() {
// ...
}

不推荐的写法

1
2
3
func test() -> () {
// ...
}

嵌套其它标签

例如嵌套一个 tabs 标签:

个人电脑作为办公设备时,我们该如何保护隐私?
个人电脑作为办公设备时,我们该如何保护隐私?
公司一般都会强制安装安防软件,这些软件要求开机自启动,要求有屏幕录制权限、完全的磁盘访问权限包括相册图库。因此如果使用自己的 MacBook 作为办公设备,必须要把生活区和工作区完全独立开,安装在两个磁盘分区,并且对磁盘分区进行加密。

folding 折叠容器

折叠块标签的语法格式为:

1
2
3
{% folding title [codeblock:bool] [open:bool] [color:color] %}
content
{% endfolding %}
参数说明
1
2
3
codeblock: true/false
open: true/false
color: red/orange/yellow/green/cyan/blue/purple/light/dark

彩色可折叠代码块

备注标签相较于旧版进行了增强,可以实现更多种颜色,还可以通过设置 child:codeblock 来实现可折叠的代码块。以下是一个默认打开的代码折叠框:

默认打开的代码折叠框
1
2
3
func test() {
print("hello world")
}

代码如下:

1
2
3
{% folding child:codeblock open:true color:yellow 默认打开的代码折叠框 %}
代码块
{% endfolding %}
危险,请不要打开这个

通过设置颜色,以实现更醒目的作用,但不要滥用色彩哦~

警告,真的很危险

通过设置颜色,以实现更醒目的作用,但不要滥用色彩哦~

最后一次警告,千万不要打开这个

不要说我们没有警告过你,Windows 10 不是為所有人設計,而是為每個人設計。

folders 多个折叠容器聚合

样式相比 folding 简单一些,适用于多个折叠标签平铺显示的场景,例如题目列表:

题目1

这是答案1

题目2

这是答案2

题目3

这是答案3

代码如下:

1
2
3
4
5
6
7
8
{% folders %}
<!-- folder 题目1 -->
这是答案1
<!-- folder 题目2 -->
这是答案2
<!-- folder 题目3 -->
这是答案3
{% endfolders %}

tabs 分栏容器

这个标签移植自 NexT 主题,但做了以下修改:

  • 支持设置 align:center 来使内容居中
  • 设置默认激活的标签方式为 active:1 而非 , 1(使用默认格式降低学习成本,且显式声明可读性更强)
  • 不需要 <!-- endtab --> 来作为结束标识(因为 Stellar 会自动判断)
  • 不需要 tabs id 来保证唯一性(因为 Stellar 会设置唯一标识)
  • 不支持 @icon 方式设置图标(因为 Stellar 不再内置 fontawesome 图标库)
  • 轮廓样式简化,可以搭配其它容器类标签嵌套使用。
1
2
let x = 123
print("hello world")
a b c
a1 b1 c1
a2 b2 c2

grid 网格分区容器

这个功能在 1.12.0 版本后开始支持,目前只支持显示一行两列,且手机端因宽度较窄会恢复为单列显示。

Unsplash Photo

The Galactic Center is the rotational center of the Milky Way galaxy. Its central massive object is a supermassive black hole of about 4 million solar masses, which is called Sagittarius A*. Its mass is equal to four million suns. The center is located 25,800 light years away from Earth.

Ōwhiro Bay, Wellington, New Zealand
Published on May 31, 2022
SONY, ILCE-6000
Free to use under the Unsplash License

普通块样式:

左侧内容
右侧内容

卡片样式:

左侧内容
右侧内容

示例代码:

1
2
3
4
5
6
{% grid bg:block %}
<!-- cell -->
<center>左侧内容</center>
<!-- cell -->
<center>右侧内容</center>
{% endgrid %}

bg 为可选参数,默认没有背景,可设置为 block/card 两种样式

about 关于块容器

方便在关于页面显示一段图文信息,比普通块容器稍微有一点点不一样:

1
2
3
4
5
6
{% about avatar:/assets/xaoxuu/avatar/rect-256@2x.png height:80px %}
<img height="32px" alt="XAOXUU" src="/assets/xaoxuu/logo/[email protected]">
**如果宇宙中真有什么终极的逻辑,那就是我们终有一天会在舰桥上重逢,直到生命终结。**
XAOXUU 目前是一个 iOS 开发者,代表作品有:ProHUD、ValueX 等。在业余时间也开发了 Stellar 博客主题,更多的作品可以去项目主页查看,希望大家喜欢~
{% navbar [文章](/) [项目](/wiki/) [留言](#comments) [GitHub](https://github.com/xaoxuu/) %}
{% endabout %}
这个标签正在考虑重命名

请发表您的建议 #198

swiper 轮播容器

默认一张图片是 50% 宽度,通过设置 width:min 设置为 25% 宽度,width:max 设置为 100% 宽度。

写法如下
1
2
3
4
5
6
{% swiper effect:cards %}
![](https://images.unsplash.com/photo-1625171515821-1870deb2743b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80)
![](https://images.unsplash.com/photo-1528283648649-33347faa5d9e?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80)
![](https://images.unsplash.com/photo-1542272201-b1ca555f8505?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80)
![](https://images.unsplash.com/photo-1524797905120-92940d3a18d6?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80)
{% endswiper %}
写法如下
1
2
3
{% swiper width:min/max %}
...
{% endswiper %}
1
2
3
{% swiper effect:cards/coverflow %}
...
{% endswiper %}
注意

一个页面只能设置一次,第一个 swiper 容器的效果全局生效。

数据集合类标签(5个)

timeline 时间线

支持静态和动态时间线数据源,用法非常多,详见这篇文章:

https://xaoxuu.com/blog/20221029/

静态时间线

静态数据是写死在 md 源文件中的,在 deploy 时就已经确定了。

2021 年 2 月 16 日

主要部分功能已经开发的差不多了。

2021 年 2 月 11 日

今天除夕,也是生日,一个人在外地过年+过生日,熬夜开发新主题,尽量在假期结束前放出公测版。

写法如下
1
2
3
4
5
6
7
{% timeline %}
<!-- node 2021 年 2 月 16 日 -->
主要部分功能已经开发的差不多了。
{% image /assets/wiki/stellar/photos/[email protected] width:300px %}
<!-- node 2021 年 2 月 11 日 -->
今天除夕,也是生日,一个人在外地过年+过生日,熬夜开发新主题,尽量在假期结束前放出公测版。
{% endtimeline %}

动态时间线

动态数据是从 GitHub Issues 中拉取的,使用方法为:

  1. 建一个仓库
  2. 创建一个 issue 并添加一个 label 进行测试
  3. timeline 标签时加上 api:https://api.github.com/repos/your-name/your-repo/issues

例如:

_posts/xxx.md
1
{% timeline api:https://api.github.com/repos/xaoxuu/blog-timeline/issues?direction=asc&per_page=3 %}{% endtimeline %}
1
2
效果如下:
{% timeline api:https://api.github.com/repos/xaoxuu/blog-timeline/issues?direction=asc&per_page=3 %}{% endtimeline %}

https://xaoxuu.com/wiki/stellar/fcircle/

_posts/xxx.md
1
2
{% timeline type:fcircle api:https://raw.githubusercontent.com/xaoxuu/friends-rss-generator/output/data.json %}
{% endtimeline %}
  1. fork 爬虫 仓库 ,修改自己的仓库名
  2. 修改 .github/workflows/main.yml 中的微博ID为你想爬取的ID,修改完后每天会自动爬取你的微博,存储为 json 文件,输出文件在 output 分支
_posts/xxx.md
1
{% timeline limit:20 type:weibo api:你的json文件地址 %}{% endtimeline %}

静态 + 动态

用法同静态和动态单独使用时一样,例如:

1
2
3
4
{% timeline reversed:true api:https://api.github.com/repos/xaoxuu/blog-timeline/issues?per_page=2 %}
<!-- node 这条内容为静态数据 -->
这条内容为静态数据,静态数据在 `deploy` 时就已经确定了。
{% endtimeline %}

数据筛选

只显示某个人的数据
筛选最近3条todo
筛选评论最多的3条建议

上述示例代码如下:

1
2
3
4
5
6
7
8
{% folders %}
<!-- 只显示某个人的数据 -->
{% timeline user:xaoxuu api:https://api.github.com/repos/volantis-x/hexo-theme-volantis/issues %}{% endtimeline %}
<!-- 筛选最近3条todo -->
{% timeline api:https://api.github.com/repos/xaoxuu/hexo-theme-stellar/issues?labels=todo&per_page=3 %}{% endtimeline %}
<!-- 筛选评论最多的3条建议 -->
{% timeline api:https://api.github.com/repos/volantis-x/hexo-theme-volantis/issues?labels=feature-request&per_page=3&sort=comments %}{% endtimeline %}
{% endfolders %}

更多用法详见:

https://docs.github.com/en/rest/issues/issues#list-issues-assigned-to-the-authenticated-user

friends 友链

您可以在任何位置插入友链组,支持静态数据和动态数据,静态数据需要写在数据文件中:

blog/source/_data/links.yml
1
2
3
4
5
6
'开源大佬':
- title: 某某某
url: https://
screenshot:
avatar:
description:

在需要的位置这样写:

1
{% friends 开源大佬 %}

实现动态友链

xaoxuu/issues-json-generator 作为模板克隆或者 fork 仓库

修改 config.yml 并打开 github action 的运行权限

config.yml
1
2
3
4
5
# 要抓取的 issues 配置
issues:
repo: xaoxuu/friends # 仓库持有者/仓库名(改成自己的)
label: active # 筛选具有 active 标签的 issue ,取消此项则会提取所有 open 状态的 issue
sort: # updated-desc # 排序,按最近更新,取消此项则按创建时间排序

不出意外的话,仓库中已经配置好了 issue 模板,只需要在模板中指定的位置填写信息就可以了。然后在自己的仓库里提交一个 issue 并将 Label 设置为 active 进行测试。

提交完 issue 一分钟左右,如果仓库中出现了 output 分支提交,可以点击查看一下文件内容是否已经包含了刚刚提交的 issue 中的数据,如果包含,那么前端页面就可以使用友链数据了:

1
{% friends api:https://raw.githubusercontent.com/xaoxuu/friends/output/v2/data.json %}

数据托管与加速

特别感谢

特别感谢小冰博客的加速访问方案,解决了直接请求 GitHub API 速度过慢的问题,详见 小冰博客 的教程。

支持把数据托管到任何其他地方来使用,例如:

1
{% friends api:https://api.vlts.cc/output_data/v2/xaoxuu/friends %}
Stellar 1.13.0

动态数据 API 升级至 v2 版本,原使用 issue-api 仓库的需要将友链仓库同步更新。
v1 版本已经停止维护。

你可以有 N 种办法加速访问 GitHub 仓库里的文件。

sites 网站卡片

您可以在任何位置插入网站卡片组,支持静态数据和动态数据,静态数据需要写在数据文件中:

blog/source/_data/links.yml
1
2
3
4
5
6
'分组名':
- title: 某某某
url: https://
screenshot:
avatar:
description:

在需要的位置这样写:

1
{% sites 分组名 %}
Stellar v1.13.0

原 friends 和 sites 标签数据合并至 links.yml 文件,动态数据使用方法同友链,数据源格式相同,与友链共享数据,仅样式不同,也可以用 sites 标签做友链。

ghcard 卡片

写法如下
1
2
{% ghcard xaoxuu %}
{% ghcard xaoxuu/hexo-theme-stellar theme:dark %}

https://github.com/anuraghazra/github-readme-stats

toc 文档目录树

1
{% toc wiki:xxx [open:true] [display:mobile] title %}

表达类标签(14+个)

emoji 表情

内置了可配置的表情标签 使用方法如下:

1
2
3
4
{% emoji 爱你 %}
{% emoji blobcat ablobcatrainbow %}
{% emoji blobcat ablobcatattentionreverse %}
{% emoji tieba 滑稽 %}
1
{% emoji [source] name [height:1.75em] %}

其中 source 可省略,默认为配置中的第一个 source(详见「引入表情包」部分)

如果对高度有特别要求,可以指定高度,例如:

1
{% emoji blobcat ablobcatrainbow height:4em %}

表情速查表1:stellar表情标签索引
表情速查表2:Stellar内嵌blobcat小表情

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
tag_plugins:
...
emoji:
default: https://gcore.jsdelivr.net/gh/cdn-x/emoji/qq/${name}.gif
twemoji: https://gcore.jsdelivr.net/gh/twitter/twemoji/assets/svg/${name}.svg
qq: https://gcore.jsdelivr.net/gh/cdn-x/emoji/qq/${name}.gif
aru: https://gcore.jsdelivr.net/gh/cdn-x/emoji/aru-l/${name}.gif
tieba: https://gcore.jsdelivr.net/gh/cdn-x/emoji/tieba/${name}.png

在配置文件中,文件名用 ${name} 代替。

mark 行内文本标记

支持多彩标记,包括:默认 绿 警告 错误 一共 12 种颜色。

1
支持多彩标记,包括:{% mark 默认 %} {% markcolor:red %} {% markcolor:orange %} {% markcolor:yellow %} {% mark 绿 color:green %} {% markcolor:cyan %} {% markcolor:blue %} {% markcolor:purple %} {% markcolor:light %} {% markcolor:dark %} {% mark 警告 color:warning %} {% mark 错误 color:error %} 一共 12 种颜色。
Stellar Hexo GitHub Gitea

image 图片标签

图片标签是一个精心设计的应对各种尺寸插图的标签,对于大图,可以放置一个「下载」按钮,语法格式如下:

1
{% image src [description] [download:bool/string] [width:px] [padding:px] [bg:hex] %}
参数说明
1
2
3
4
5
6
src: 图片地址
description: 图片描述
download: href # 下载地址,设置此值后鼠标放在图片上会显示下载地址,如果下载地址为图片地址,可以设置为 true
width: 200px # 图片宽度
padding: 16px # 图片四周填充宽度
bg: '#ffffff' # 图片区域背景颜色,16进制

大尺寸图片

无论在什么宽度的设备上都希望横向铺满的图片,一般不需要额外操作。可以在链接后面写上图片描述,如有必要,可以通过设置 download:true 使其显示一个「下载」按钮链接指向图片地址,如果下载链接与显示的图片地址不同,可以 download:下载链接 来使其能够下载原图。

来自印度的 Rohit Vohra 使用 iPhone 12 Pro Max 拍摄。
来自印度的 Rohit Vohra 使用 iPhone 12 Pro Max 拍摄。
来自澳大利亚的 Pieter de Vries 使用 iPhone 12 Pro Max 拍摄。
来自澳大利亚的 Pieter de Vries 使用 iPhone 12 Pro Max 拍摄。
写法如下
1
2
{% image /assets/wiki/stellar/photos/183e71e0ad995.jpg 来自印度的 Rohit Vohra 使用 iPhone 12 Pro Max 拍摄。 download:https://www.apple.com.cn/newsroom/images/product/iphone/lifestyle/Apple_ShotoniPhone-rohit_vohra_12172020.zip %}
{% image /assets/wiki/stellar/photos/bc7bda18328da.jpg 来自澳大利亚的 Pieter de Vries 使用 iPhone 12 Pro Max 拍摄。 download:https://www.apple.com.cn/newsroom/images/product/iphone/lifestyle/Apple_ShotoniPhone_pieter_de_vries_011221.zip %}

小尺寸图片优化

宽度较小而高度较大的图片,可以设置宽、高、填充间距、背景色等对其布局进行优化,使得它在不同宽度的屏幕下都能获得不错的视觉体验:

有底色的图片,可以填充图片底色:

1
{% image /assets/xaoxuu/mirror/apple/documentation/watchkit/06d45110-1dd7-49a4-a413-9f5159ecdd0e.png width:200px padding:16px bg:white %}
提示

鼠标拖拽一下图片可以看看原图

如果不进行约束,在宽屏设备上阅读体验很糟糕

没有底色的图片,可以填充 bg:var(--card) 动态颜色,能够适配暗黑模式:

1
{% image /assets/wiki/stellar/icon.svg bg:var(--card) padding:16px %}

支持 Fancybox 插件点击放大

由于 Stellar 主题的插件具有按需加载的特性,所以 Fancybox 插件默认也是已经配置好了的,在任意 image 标签中增加 fancybox:true 参数即可为特定图片开启缩放功能。如果一个页面没有任何地方使用,则不会加载 Fancybox 插件。

图片来自 Apple 官网
图片来自 Apple 官网

如果您希望全站所有的 image 标签都开启此功能,可在主题配置文件中修改以下参数:

1
2
3
4
5
######## Tag Plugins ########
tag_plugins:
# {% image %}
image:
fancybox: true

quot 引用

适合居中且醒目的引用:

Stellar 是最好用的主题

支持自定义引号:

热门话题

其中自定义引号素材在主题配置文件的 tag_plugins.quot 中配置:

1
2
3
4
5
6
7
8
9
tag_plugins:
...
# {% quot %}
quot:
default: # 可以自行配置多种图标方案
prefix: https://bu.dusays.com/2022/10/24/63567d3e092ff.png
suffix: https://bu.dusays.com/2022/10/24/63567d3e0ab55.png
hashtag:
prefix: https://bu.dusays.com/2022/10/24/63567d3e07da3.png
写法如下
1
2
适合居中且醒目的引用:{% quot Stellar 是最好用的主题 %}
支持自定义引号:{% quot 热门话题 icon:hashtag %}

特别引用

此外,加上 el:h2/h3/h4/h5/h6 可以作为标题使用

poetry 诗词

游山西村
陆游

莫笑农家腊酒浑,丰年留客足鸡豚。
山重水复疑无路,柳暗花明又一村。
箫鼓追随春社近,衣冠简朴古风存。
从今若许闲乘月,拄杖无时夜叩门。

1
2
3
4
5
6
{% poetry 游山西村 author:陆游 footer:诗词节选 %}
莫笑农家腊酒浑,丰年留客足鸡豚。
**山重水复疑无路,柳暗花明又一村。**
箫鼓追随春社近,衣冠简朴古风存。
从今若许闲乘月,拄杖无时夜叩门。
{% endpoetry %}

note 备注块

1
{% note [title] content [color:color] %}
1
2
3
title: 标题(可选)
content: 内容
color: red/orange/yellow/green/cyan/blue/purple/light/dark/warning/error

具有标题的备注块

直接写备注内容,默认是和代码块一样的样式,第一个空格前面的是标题,后面的是正文,如果标题中需要显示空格,请使用 &nbsp; 代替。

这 是标题

这是正文 哈哈。

1
{% note 这&nbsp;是标题 这是正文 哈哈。 %}

彩色备注块

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

一共支持12种颜色,可以满足几乎所有的需求了。

color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。

1
2
{% note 一共支持12种颜色,可以满足几乎所有的需求了。 color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。 %}
{% note color:cyan 一共支持12种颜色,可以满足几乎所有的需求了。 color 可设置 red、orange、yellow、green、cyan、blue、purple、light、dark、warning、error 几种取值。 %}

。。。。

外链卡片标签的语法格式为:

1
{% link href [title] [icon:src] [desc:true/false] %}

参数含义:

1
2
3
4
href: 链接
title: 可选,手动设置标题(为空时会自动抓取页面标题)
icon: 可选,手动设置图标(为空时会自动抓取页面图标)
desc: 可选,是否显示摘要描述,为true时将会显示页面描述
1
2
3
4
不带摘要的样式:
{% link https://xaoxuu.com/blog/20221029/ %}
带摘要的样式:
{% link https://xaoxuu.com/blog/20221029/ desc:true %}

copy 复制行

对于单行内容,可以使用 copy 标签来实现复制功能:

您可以设置 git:https 或者 git:ssh 或者 git:gh 来快速放置一个 git 仓库链接:

1
2
3
4
5
{% copy curl -s https://sh.xaox.cc/install | sh %}
{% copy width:max curl -s https://sh.xaox.cc/install | sh %}
{% copy git:https xaoxuu.com/hexo-theme-stellar %}
{% copy git:ssh xaoxuu.com/hexo-theme-stellar %}
{% copy git:gh xaoxuu.com/hexo-theme-stellar %}

radio 单选

没有勾选的单选框
已勾选的单选框
1
2
{% radio 没有勾选的单选框 %}
{% radio checked:true 已勾选的单选框 %}
支持的参数
1
2
checked: true/false
color: red/orange/yellow/green/cyan/blue/purple

checkbox 复选

普通的没有勾选的复选框
普通的已勾选的复选框
显示为加号的绿色的已勾选的复选框
显示为减号的黄色的已勾选的复选框
显示为乘号的红色的已勾选的复选框
1
2
3
4
5
{% checkbox 普通的没有勾选的复选框 %}
{% checkbox checked:true 普通的已勾选的复选框 %}
{% checkbox symbol:plus color:green checked:true 显示为加号的绿色的已勾选的复选框 %}
{% checkbox symbol:minus color:yellow checked:true 显示为减号的黄色的已勾选的复选框 %}
{% checkbox symbol:times color:red checked:true 显示为乘号的红色的已勾选的复选框 %}
支持的参数
1
2
3
checked: true/false
color: red/orange/yellow/green/cyan/blue/purple
symbol: plus/minus/times

文章内也可以插入一个导航栏:

1
{% navbar active:1 [文章](/) [项目](/wiki/) [留言](#comments) [GitHub](https://github.com/xaoxuu/) %}

frame 设备框架

1
{% frame iphone11 img:/assets/wiki/prohud/toast/demo-loading.png video:/assets/wiki/prohud/toast/demo-loading.mp4 focus:top %}

文本修饰标签集

  • 这是 密码 标签
  • 这是 下划线 标签
  • 这是 着重号 标签
  • 这是 波浪线 标签
  • 这是 删除线 标签
  • 这是 上角标 标签
  • 这是 下角标 标签
  • 这是 键盘样式 标签,试一试: + D
写法如下
1
2
3
4
5
6
7
8
- 这是 {% psw 密码 %} 标签
- 这是 {% u 下划线 %} 标签
- 这是 {% emp 着重号 %} 标签
- 这是 {% wavy 波浪线 %} 标签
- 这是 {% del 删除线 %} 标签
- 这是 {% sup 上角标 color:red %} 标签
- 这是 {% sub 下角标 %} 标签
- 这是 {% kbd 键盘样式 %} 标签,试一试:{% kbd ⌘ %} + {% kbd D %}

侧边栏配置

左上角的 logo 和标题取自站点根目录的配置文件:

blog/_config.yml
1
2
title: 网站名称
avatar: 头像

设置鼠标指上 subtitle 后翻转另一行字(您可以将鼠标移至左上角的Stellar查看效果)

blog/_config.yml
1
subtitle:  标题1 | 标题2

如果您想用一个图片作为 logo,可以直接在主题配置文件 sidebar.logo.title 中设置:

blog/_config.stellar.yml
1
2
3
sidebar:
logo:
title: '[<img no-lazy height="32px" src="xxx"/>](/)'
blog/_config.stellar.yml
1
2
3
4
5
6
sidebar:
menu:
post: '[btn.blog](/)'
wiki: '[btn.wiki](/wiki/)'
notes: '[笔记](/notes/)'
more: '[更多](/more/)'

侧边栏宽度有限,如何在不影响观感的情况下设置更多的主导航栏按钮呢?建议设置一个「更多」按钮,然后在「更多」页面的侧边栏放上列表组件。

Search(搜索)

1.17.1 版本后开始支持,无需安装插件,默认开启。

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
# 文章搜索
search:
service: local_search # local_search, todo...
local_search: # 在 front-matter 中设置 indexing:false 来避免被搜索索引
field: all # post, page, all
path: /search.json # 搜索文件存放位置
content: true # 是否搜索内容
codeblock: true # 是否搜索代码块(需要content: true)

请提交PR…

_config.stellar.yml 中设置搜索选项并配置你想在侧边栏中显示的位置

然后在 widgets.yml 文件中配置侧边栏搜索组件

blog/source/_data/widgets.yml
1
2
3
4
5
6
7
8
9
10
11
12
search:
layout: search
filter: auto # auto or '/path'
placeholder: 文章搜索 # 搜索框处显示的文字
search_blog:
layout: search
filter: /blog/ # or /posts/ ...
placeholder: 文章搜索
search_docs:
layout: search
filter: /wiki/
placeholder: 文档搜索

您可以设置 filter 按地址过滤搜索结果,默认 auto 是智能选择,规则如下:

  • layout: wiki:只在 /wiki/当前项目 中搜索
  • 其它:站内搜索

你可以在某些页面中通过覆盖 search 组件的 filter 参数来定制化搜索范围,例如:

1
2
3
4
5
sidebar:
- toc
- layout: search
override: search
filter: /path/to/some

如果想始终进行不加过滤的站内搜索,那么设置为 filter: '' 即可。

Footer(页脚)

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
footer:
social:
github:
icon: '<img src="/assets/placeholder/social/08a41b181ce68.svg"/>'
url: https://
music:
icon: '<img src="/assets/placeholder/social/3845874.svg"/>'
url: https://
unsplash:
icon: '<img src="/assets/placeholder/social/3616429.svg"/>'
url: https://
comments:
icon: '<img src="/assets/placeholder/social/942ebbf1a4b91.svg"/>'
url: https://

自定义组件

Stellar 支持丰富的自定义小组件,详见这篇文档:

https://xaoxuu.com/wiki/stellar/widgets/

编写文章以及独立页面

文章封面

在文章列表页面或者其他位置显示的文章摘要卡片上面的图片称之为「文章封面」

自动生成封面

根据 tags 作为关键词为每一篇文章在线搜索封面:

blog/_config.stellar.yml
1
2
article:
auto_cover: true

引用外部图片

在文章的 front-matter 中写上 cover: xxx 即可。例如:

blog/source/_posts/xxx.md
1
2
3
4
5
---
# 本地图片路径为 blog/source/assets/xaoxuu/blog/[email protected]
# 也可以直接引用图片直链 https://xxx.jpg
cover: /assets/xaoxuu/blog/[email protected]
---
显示效果

上面这种方式会显示title与description或者摘要,若你想要图片全显示,可以加入如下参数:

blog/source/_posts/xxx.md
1
2
3
4
5
6
7
8
---
cover: /assets/xaoxuu/blog/[email protected] # 必选
poster: # 海报(可选,全图封面卡片)
topic: 标题上方的小字 # 可选
headline: 大标题 # 必选
caption: 标题下方的小字 # 可选
color: 标题颜色 # 可选,默认为跟随主题的动态颜色 # white,red...
---

Stellar v1.14.0 更换 cover-title cover-cat cover-subtitle cover-text-colorposter

为了显示美观,建议 topiccaption 选择其一与 headline 搭配使用。

显示效果

填写 topicheadline 时大标题位于上方

只填写 headline 或填写 headlinecaption 时大标题位于下方

如果您想使用 Unsplash 搜索图片作为封面,可以在 cover 设置搜索关键词(用英文逗号隔开):

blog/source/_posts/xxx.md
1
2
3
---
cover: workout,strava
---

内容摘要

自动生成摘要

建议您通过 description 或者 excerpt 方式生成摘要,但如果您希望自动从文章内容截取一定字数的文字作为摘要,可以这样设置:

blog/_config.stellar.yml
1
2
article:
auto_excerpt: 200

手动设置摘要

一篇文章开头一段文字描述就是摘要,摘要和正文用 <!-- more --> 隔开,前后一定要有空行。例如:

blog/source/_posts/xxx.md
1
2
3
4
5
6
---
cover: /assets/xaoxuu/blog/[email protected]
---
在心率管家默默无闻地上线了一年多之后,现在终于打算来好好聊聊关于手机摄像头测量心率的那些事。本文参考了很多前辈的文章,将在文末列出。
<!-- more -->
后面是正文部分,在主页看不到。

文章模板

使用 Hexo 自带模板实现命令行创建新文章时自动生成相关信息。

根目录下 scaffolds 文件夹中编辑 post.mdfont-matter

blog/scaffolds/post.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
title: {{ title }}
date: {{ date }}
tags: []
categories: []
description:
cover:
banner:
poster: # 海报(可选,全图封面卡片)
topic: 标题上方的小字 # 可选
headline: 大标题 # 必选
caption: 标题下方的小字 # 可选
color: 标题颜色 # 可选
---

文章页

横幅图片

文章页面顶部区域可以显示长长的横幅图片,设置方法如下:

blog/source/_posts/xxx.md
1
banner: /assets/xaoxuu/blog/[email protected]

如果您想使用 Unsplash 搜索图片作为横幅,可以在 banner 中设置搜索关键词(用英文逗号隔开):

blog/source/_posts/xxx.md
1
2
3
---
banner: workout,strava
---

指定一级标题

默认的一级标题是文章的 title,如果希望使用别的文字作为一级标题,可以指定 h1,例如:

blog/source/_posts/xxx.md
1
2
3
---
h1: 快速开始
---

文章索引与推荐

文章如果有分类和标签就会自动在主页出现「分类」、「标签」选项卡实现分类浏览,不需要手动添加页面。

文章分类

在文章列表页面会显示文章所属的第一级分类,例如:

blog/source/_posts/xxx.md
1
2
3
---
categories: [设计开发, iOS开发]
---

这样写就只会显示「设计开发」一级分类,而在文章页面顶部则会显示完整的面包屑导航。

文章标签

文章标签目前不可见,用于关键词、搜索、按标签检索、相关文章推荐等功能,例如:

blog/source/_posts/xxx.md
1
2
3
---
tags: [iOS, 心率]
---

相关文章推荐

要实现相关文章推荐功能,您需要安装插件:

然后在主题配置文件中开启:

blog/_config.stellar.yml
1
2
3
4
5
article:
# npm i hexo-related-popular-posts
related_posts:
enable: true
title: 您可能感兴趣的文章

开启后会在每篇文章的下方推荐相同类型的文章。

参考资料

填写引用文章的标题和链接:

1
2
3
4
5
6
7
8
---
references:
- title: '心跳之旅—💗—iOS用手机摄像头检测心率(PPG)'
url: https://punmy.cn/2016/07/28/15231176397746.html
- title: 'PPG光电容积脉搏波描记法技术概况'
url: https://www.jianshu.com/p/695c131abfa5
...
---

效果见这篇文章:

https://xaoxuu.com/blog/20200927/#references

更多的独立页面

Stellar 同时具有博客和 Wiki 两个大模块,为了能够正确进行导航栏高亮,引入了 menu_id 来进行区分,通常情况下,layout: postlayout: wiki 两种布局模板可以自动为 sidebar.menu.postsidebar.menu.wiki 的导航栏按钮高亮。自己创建的独立页面也可以在 front-matter 中指定 menu_id 来使某个按钮处于选中状态。

例如您有关于、友链两个页面,都希望高亮「更多」按钮:

blog/source/about/index.md
1
2
3
4
---
menu_id: more
title: 关于
---
blog/source/friends/index.md
1
2
3
4
---
menu_id: more
title: 友链
---

在主题配置文件中设置导航栏:

blog/_config.stellar.yml
1
2
3
4
sidebar:
menu:
...
more: '[更多](/more/)'

友链页面

友链被设计成标签,您可以在任何页面任何位置插入友链,详见:

#友链标签

关于页面

没有单独的关于页面布局,您可以自由组合丰富的标签来实现个性化的关于页面,例如:abouttabsnavbarquottimeline 标签。

实现「笔记」页面

创建一个项目,设置为不索引:

blog/source/_data/projects.yml
1
2
3
4
5
6
7
8
9
10
11
12
Notes:
name: 笔记
title: 笔记
description: 一个隐藏项目:笔记
index: false
# sidebar: [toc]
tags: 知识库
sections:
'日常问题解决方案': [100, 199]
'移动端开发笔记': [200, 299]
'前端学习笔记': [300, 399]
'在线工具': [400, 499]

然后笔记页面的 front-matter 中指定要高亮的 menu_id

blog/source/notes/index.md
1
2
3
4
5
---
layout: wiki
wiki: Notes
menu_id: notes
---

这样就可以啦~

使用「友链朋友圈」极简版

特别感谢

主题内置版本数据服务由 友链朋友圈 极简版提供。
这个功能在 1.13.0 版本后开始支持。

第一步:fork repo
第二步:设置自己的友链页面地址和主题类型

修改 hexo_circle_of_friends/fc_settings.yaml 文件:

1
- {link: "https://xaoxuu.com/friends/", theme: "stellar"}  # 友链页地址1,修改为你的友链页地址
第三步:打开 Issues 友链抓取功能

修改 hexo_circle_of_friends/fc_settings.yaml 文件:

1
2
3
4
5
6
7
GITHUB_FRIENDS_LINKS: {
enable: true, # true 开启github issue兼容
type: "volantis", # volantis/stellar用户请在这里填写volantis
owner: "xaoxuu", # 填写你的github用户名
repo: "friends", # 填写你的github仓库名
state: "open", # 填写抓取的issue状态(open/closed)
}
第四步:打开 Actions 运行权限

见官方教程 #simplemode

第五步:放置在博客中

支持首页文章导航栏、文章任意位置,创建一个文件,以本站 friends/rss/index.md 为例:

1
2
3
4
5
6
7
8
9
10
---
seo_title: 朋友文章
robots: noindex,nofollow
menu_id: post
comments: false
post_list: true # 这就意味着页面会显示首页文章导航栏
sidebar: [welcome, recent]
---
{% timeline type:fcircle api:https://raw.githubusercontent.com/xaoxuu/friends-rss-generator/output/data.json %}
{% endtimeline %}

其中,api 部分替换为自己仓库地址及其对应的 data.json 文件真实路径。

其中,post_list: true 意味着页面会显示首页文章导航栏,搭配主题配置文件中的:

1
2
post-index:
'朋友文章': /friends/rss/

即可实现在首页增加一个「朋友文章」栏目的效果。

  • 你依然可以按照官方教程使用完整版。
  • 本站示例仓库:@xaoxuu/friends-rss-generator
    如果把 data.json 输出到 output 分支,可以直接使用下面的 API 来访问文件:
1
https://api.vlts.cc/output_data/v1/xaoxuu/friends-rss-generator

使用 Stellar 主题的博客

小提示

如果您也使用了 Stellar 并希望显示在这里,可以在 hexo-theme-stellar-examples 中提交 issue 告知您的站点信息,在您提交后的大约 3 分钟内生效。

评论插件配置(6个)

Beaudar

Beaudar 是 Utterances 的中文版本,相比 Utterances 有更多的体验优化,可以按时间倒序排序。

blog/_config.stellar.yml
1
2
3
4
comments:
service: beaudar
beaudar:
repo: xaoxuu/blog-comments

Beaudar 的配置方法很简单,创建一个仓库,在仓库中创建一个 域名白名单文件,然后在 此处 授权安装即可。

utterances

A lightweight comments widget built on GitHub issues. Use GitHub issues for blog comments, wiki pages and more!

blog/_config.stellar.yml
1
2
3
4
comments:
service: utterances
utterances:
repo: xaoxuu/blog-comments

utterances 的配置方法很简单,创建一个仓库,在仓库中创建一个 域名白名单文件,然后在 此处 授权安装即可。

giscus

giscus 是由 GitHub Discussions 驱动的评论系统。让访客借助 GitHub 在你的网站上留下评论和反应吧!本项目受 utterances 强烈启发。

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
comments:
service: giscus
# giscus
# https://giscus.app/zh-CN
giscus:
data-repo: xxx/xxx # [在此输入仓库]
data-repo-id: # [在此输入仓库 ID]
data-category: # [在此输入分类名]
data-category-id:
data-mapping: pathname
data-strict: 0
data-reactions-enabled: 1
data-emit-metadata: 0
data-input-position: top # top, bottom
data-theme: preferred_color_scheme
data-lang: zh-CN
data-loading: lazy
crossorigin: anonymous

Twikoo

blog/_config.stellar.yml
1
2
3
4
comments:
service: twikoo
twikoo:
envId: https://xxx # vercel函数

https://twikoo.js.org

Waline

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
comments:
service: waline
waline:
js: https://unpkg.com/@waline/client@v2/dist/waline.js
css: https://unpkg.com/@waline/client@v2/dist/waline.css
# Waline server address url, you should set this to your own link
serverURL: https://xxx # waline 地址
# If false, comment count will only be displayed in post page, not in home page
commentCount: true
# Pageviews count, Note: You should not enable both `waline.pageview` and `leancloud_visitors`.
pageview: false
# Custom locales
locale:
placeholder: # 输入框内提示文字
# Custom emoji
emoji:
- https://gcore.jsdelivr.net/gh/norevi/[email protected]/blobs
# - https://unpkg.com/@waline/[email protected]/weibo
# - https://unpkg.com/@waline/[email protected]/alus
# - https://unpkg.com/@waline/[email protected]/bilibili
# - https://unpkg.com/@waline/[email protected]/qq
# - https://unpkg.com/@waline/[email protected]/tieba
# - https://unpkg.com/@waline/[email protected]/tw-emoji
# - https://unpkg.com/@waline/[email protected]/bmoji

https://waline.js.org

Artalk

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
comments:
service: artalk
# Artalk
# https://artalk.js.org/
artalk:
css: https://unpkg.com/[email protected]/dist/Artalk.css
js: https://unpkg.com/[email protected]/dist/Artalk.js
server: # 后端服务地址
placeholder: ''
darkMode: auto

https://artalk.js.org

评论的灵活用法

共用评论数据

如果您有多个页面需要共用评论数据,可以在 front-matter 中覆盖评论参数,例如:

blog/source/about/index.md
1
2
3
title: 关于
beaudar:
'issue-term': '留言板'
blog/source/friends/index.md
1
2
3
title: 友链
beaudar:
'issue-term': '留言板'

使用其它评论数据

如果您有多个页面需要另外一个数据库的评论数据,以 Beaudar 为例,您可以这样:

blog/source/wiki/stellar/index.md
1
2
3
4
5
title: 快速开始您的博客之旅
giscus:
data-repo: xaoxuu/hexo-theme-stellar
data-mapping: number
data-term: 226

探索号专题教程分享

小提示

如果您也有与 Stellar 相关的文章并希望显示在这里,可以直接在 hexo-theme-stellar 中选择【文章分享】模板按照格式提交即可,立即生效。

探索个性化配置

主题色

支持 HEX & HSL 表示颜色

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
style:
...
color:
# 动态颜色(会根据明暗主题重设明度值,只用关心色相和饱和度即可)
background: 'hsl(212 16% 98%)' # 浅色背景颜色
block: 'hsl(212 8% 95%)' # 块背景颜色
code: 'hsl(14 100% 48%)' # 行内代码颜色
text: 'hsl(0 0% 20%)' # 文本颜色
# 主题色配置(不会根据明暗动态调整,请设置为通用的颜色)
theme: 'hsl(192 98% 55%)' # 主题色
accent: 'hsl(14 100% 57%)' # 强调色
link: 'hsl(207 90% 54%)' # 超链接颜色
button: 'hsl(192 98% 55%)' # 按钮颜色
hover: 'hsl(14 100% 57%)' # 按钮高亮颜色

字体

系统字体

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
9
10
11
style:
font-size:
root: 16px
body: .9375rem # 15px
code: 85% # 14px
codeblock: 0.8125rem # 13px
font-family:
logo: 'system-ui, "Microsoft Yahei", "Segoe UI", -apple-system, Roboto, Ubuntu, "Helvetica Neue", Arial, "WenQuanYi Micro Hei", sans-serif'
body: 'system-ui, "Microsoft Yahei", "Segoe UI", -apple-system, Roboto, Ubuntu, "Helvetica Neue", Arial, "WenQuanYi Micro Hei", sans-serif'
code: 'Menlo, Monaco, Consolas, system-ui, "Courier New", monospace, sans-serif'
codeblock: 'Menlo, Monaco, Consolas, system-ui, "Courier New", monospace, sans-serif'

外部字体

要想引用外部字体,你需要先在 _config.ymlinject 引入

举例,引用 Noto Serif SC_config.yml 中写入

blog/_config.yml
1
2
3
4
inject:
head:
- <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC&display=swap" rel="stylesheet">
script:

并在 _config.stellar.yml 中填写你引入的字体名称

blog/_config.stellar.yml
1
2
3
style:
font-family:
body: '"Noto Serif SC", "Microsoft Yahei",..., sans-serif'

选择在线字体:

https://www.googlefonts.cn/

本地字体

若您想引用本地字体,举例,引用得意黑(SmileySans-Oblique.ttf)这个字体,先将字体放置于 blog/source/font/ 目录下,然后改动一下主题文件

Blog/themes/stellar/source/css/_custom.styl
1
2
3
4
5
@font-face
font-family: 'Smiley Sans'
src: url('/font/SmileySans-Oblique.ttf')
font-weight: normal
font-style: normal

font-family 是你引入的字体家族名,src 中填写字体文件相对于 source 文件夹的路径

同样,你需要在 _config.stellar.yml 中填写你引入的字体名称(font-family

blog/_config.stellar.yml
1
2
3
style:
font-family:
body: '"Smiley Sans", "Microsoft Yahei",..., sans-serif'

但是我个人并不推荐引用本地字体,相比于英文字体,中文字体囊括了众多的字符,这也无法避免地导致字体文件体积的增加,拿 Noto Serif SC 来说,单个ttf文件就有9mb之大,这对于您的站点而言加载速度可想而知。

文本对齐方向

blog/_config.stellar.yml
1
2
3
style:
...
text-align: left # justify/left/center/right

圆角大小

这个功能在 1.18.1 版本后开始支持。

blog/_config.stellar.yml
1
2
3
4
5
6
7
style:
...
border-radius:
card: 12px # 卡片圆角
block: 12px # 块圆角
bar: 6px # 导航栏圆角
image: 6px # 图片圆角

页面缓入效果

blog/_config.stellar.yml
1
2
3
4
5
6
7
8
# 默认关闭
scrollreveal:
enable: false
js: https://gcore.jsdelivr.net/npm/[email protected]/dist/scrollreveal.min.js
distance: 4px # 执行距离
duration: 400 # ms # 执行时长
interval: 100 # ms # 执行间隔(时间)
scale: 0.1 # 0.1~1 # 执行方式(缩放)

此效果会和图片懒加载插件冲突,导致部分卡片和footer可能加载不出来

图片懒加载

blog/_config.stellar.yml
1
2
3
4
5
# 默认打开
lazyload:
enable: true # [hexo clean && hexo s] is required after changing this value.
js: https://gcore.jsdelivr.net/npm/[email protected]/dist/lazyload.min.js
transition: blur # blur, fade

加载提示

加载动态时间线、动态友链等显示提示

blog/_config.stellar.yml
1
2
3
4
# 默认打开
loading:
loading: 正在加载
error: 加载失败,请稍后重试。

渐变色

这个功能在 1.18.2 版本后开始支持。

您可以在搜索框与 wiki 项目的封面开始按钮处设置渐变色 CSS 代码

blog/_config.stellar.yml
1
2
3
4
5
style:
...
gradient: # https://webgradients.com/
start: 'linear-gradient(to right, #92fe9d 0%, #00c9ff 50%, #92fe9d 100%)'
search: 'linear-gradient(to right, #04F3FF, #08FFC6, #DDF730, #FFBD19, #FF1FE0, #C418FF, #04F3FF)'

您可以在下面网站中寻找中意的渐变色

https://webgradients.com/

当然,如果只想设置纯色的话可以直接设置单色,支持 HEX 和 HSL,例如 search: 'hsl(212 16% 98%)'

顶部检索栏

这个功能在 1.13.0 版本后开始支持。

blog/_config.stellar.yml
1
2
3
######## Index ########
post-index: # 近期发布 分类 标签 归档 and ...
'朋友文章': /friends/rss/ # 这里填写的链接要与对应页面一致,否则可能无法正确高亮

站点地图

页面底部的站点导航,你也可以在 content 中自定义一些文字信息,支持 Markdown 格式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sitemap:
'博客':
- '[近期](/)'
- '[分类](/categories/)'
- '[标签](/tags/)'
- '[归档](/archives/)'
'项目':
# - '[开源库](/)'
'社交':
# - '[友链](/)'
# - '[留言板](/)'
'更多':
# - '[关于本站](/)'
# - '[GitHub](/)'
content: | # 支持 Markdown 格式
本站由 [@anonymity](/) 使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 主题创建。
本博客所有文章除特别声明外,均采用 [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) 许可协议,转载请注明出处。
# 主题用户越多,开发者维护和更新的积极性就越高,如果您喜欢本主题,请在适当的位置显示主题信息和仓库链接以表支持。

自定义样式

如果要修改样式,您需要删掉主题的样式文件的 CDN 链接,使用本地文件,然后在 themes/stellar/source/css/_custom.styl 中进行修改。

使用其它 highlight.js 代码高亮主题

Hexo 官方有文档:https://hexo.io/docs/syntax-highlight.html#hljs

Tip: When line_number is set to false, wrap is set to false and hljs is set to true, you can then use highlight.js theme directly in your site.
atom-one-dark 主题为例,翻译过来就是 _config.yml 找到 highlight 并修改为:

1
2
3
4
5
6
7
highlight:
enable: true
line_number: false
auto_detect: false
tab_replace: ' '
wrap: false
hljs: true

然后再找到 inject 新增一个 css 链接:

1
2
3
inject:
head:
- <link rel="stylesheet" href="https://gcore.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css">

外部文件注入

在站点根目录下的配置文件中进行修改 inject.head 以在 <head> 标签末尾处注入代码,修改 inject.script 以在 <body> 标签末尾处注入代码。

blog/_config.yml
1
2
3
4
5
6
7
inject:
head:
- <meta name="msapplication-TileColor" content="#2d89ef">
- <meta name="msapplication-config" content="/assets/favicon/browserconfig.xml">
- <meta name="theme-color" content="#ffffff">
script:
- https://gcore.jsdelivr.net/npm/[email protected]/dist/jquery.min.js