一个干净且优雅的 Hexo 主题 | Yoga

yoga logo

一个干净且优雅的 Hexo 主题

npm
npm version


预览(LeoHao’s Blog · GitHub Pages ) | 中文使用说明 | GitHub | Gitee

🧘 Yoga is a nice and graceful theme for Hexo, also fast, powerful and responsive. It contains many awesome features, It’s perfect for your blog, “Yoga” means “Peaceful”, it also the name of a singer from Taiwan, China.

Create an issue if you have any queries or advice during the process of using.

hexo-theme-yoga

版权声明

Hexo-theme-yogahexo-theme-ayer 的优化和定制化版本,原主题的作者是 ShenYu,本项目的全部版权归原作者所有。

hexo-theme-ayer 主题的基础上,Yoga 主题进行了以下更改:

  • 修复原主题引用的 js 文件存在的 CDN 服务器无法连通的问题

  • 增加对 LeanCloud API 的自定义服务器 URL 的支持,提升评论功能的稳定性

  • 修复字数统计对于加密文章无效的问题

  • 修复用户首次通过加密页面的身份验证后,ToC 目录不显示的问题

  • 为较为久远的文章添加时效性提醒

  • 在文章元数据中添加 hidden 属性,使文章不在主页显示

  • 限制 image_viewer 图片放大功能只对 post 生效,而对 page 无效

新增功能演示

久远文章时效性提醒

对于发布时间较为久远的文章,Yoga 主题为期添加了时效性提醒(200 天为橙色提示,400天为红色提示),样式定义在 outdate.js 中,主题使用者可自行更改。

时效性提醒样式 A-橙色 时效性提醒样式 B-红色

使用说明

完整的使用说明可参考原主题:Ayer 中文说明 ,本文只对 Yoga 提供的新支持进行说明。

1. 切换加密插件修复 ToC 目录对于加密文章无效的问题

  • hexo-blog-encrypt-anotherhexo-blog-encrypt 的修改版本,它会在用户通过验证时刷新当前页面,这将帮助页面重新生成 ToC。

    1
    $ npm install hexo-blog-encrypt-another --save

    如果您想加密某个 post 或 page,请参考以下内容在元数据中添加 password: your_password

    1
    2
    3
    4
    5
    6
    7
    ---
    title: 加密文章示例
    date: 2023-03-01 19:46:02
    tags: [Share,Hexo, Encry]
    category: [tutorial]
    password: your_password
    ---

2. 自定义 LeanCloud API 请求地址

由于 LeanCloud 通用版域名失效,导致依赖于 LeanCloud 服务的 Valine 评论功能无法正常使用。针对该问题,用户可在 LeanCloud 【控制台 → 设置 → 域名绑定】 中绑定自定义 API 域名,并将域名填入 _config.yoga.yml 配置文件中 leancloudserverURLs 字段。

1
2
3
4
5
6
7
8
9
10
11
# leancloud API can be replaced via ${serverURLs}
leancloud:
enable: true
app_id: # LeanCloud AppId
app_key: # LeanCloud AppKey
serverURLs: https://your-domain-name # LeanCloud API URL
# Valine Setting
valine:
enable: true
avatar: robohash # (https://valine.js.org/avatar.html)
placeholder: Add some comments to my article~ # placeholder

3. 使用 hidden 属性将文章从主页隐藏

有时我们希望部分文章不在主页显示,例如你的日记或其他不希望公开的内容。你可以使用 password 为文章添加密码,但这种方式不太好,因为别人还是能够在主页上看到这篇文章的入口。

对于以上需求,用户可以在文章元数据中添加 hidden: true 字段,如下所示:

1
2
3
4
5
6
7
---
title: 主页隐藏文章示例
date: 2023-03-01 19:46:02
tags: [Share,Hexo, Hidden]
category: [tutorial]
hidden: true
---

需要说明的是,以上方式不会删除文章的访问入口,只是不在主页的文章列表中显示,文章仍会被 timeline(archives), tags, categories 收录。