Update for Hexo 5.0 (#58)

* Remove next_tagcloud helper

* Update docs for Hexo 5.0
This commit is contained in:
Mimi 2020-07-29 10:37:36 +08:00 committed by GitHub
parent d871eedbb6
commit e02e104ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 78 deletions

View File

@ -31,14 +31,29 @@
## Installation
The simplest way to install is to clone the entire repository:
If you're using Hexo 5.0 or later, the simplest way to install is through npm:
```sh
$ cd hexo
$ cd hexo-site
$ npm install hexo-theme-next
```
Or you can clone the entire repository:
```sh
$ cd hexo-site
$ git clone https://github.com/next-theme/hexo-theme-next themes/next
```
Or you can see [detailed installation instructions][docs-installation-url] if you want any other variant.
See [detailed installation instructions][docs-installation-url] if you want any other variant.
## Configuration
At present, NexT encourages users to use the [Alternate Theme Config][docs-configuration-url] to configure NexT. And it's easy to customize the layout or style of NexT using [Custom Files][docs-custom-files-url].
It is not recommended to directly modify any files in the NexT theme. Because this may cause errors (e.g. merge conflicts), and the modified files may be discarded when upgrading the theme.
However, you can bypass merge conflicts (error message like **«Commit your changes or stash them before you can merge»**) by using the `Commit`, `Stash` or `Reset` commands for local changes. See [here](https://stackoverflow.com/a/15745424/5861495) how to do it.
## Plugins
@ -68,16 +83,22 @@ vendors:
## Update
NexT releases new versions every month. You can update to latest master branch by the following command:
A new version of NexT will be released every month. You can update NexT by the following command.
Install the latest version throuth npm:
```sh
$ cd hexo-site
$ npm update hexo-theme-next
```
Or update to latest master branch:
```sh
$ cd themes/next
$ git pull
```
And if you see any error message during update (something like **«Commit your changes or stash them before you can merge»**), recommended to learn [Alternate Theme Config][docs-data-files-url] feature.\
However, you can bypass update errors by using the `Commit`, `Stash` or `Reset` commands for local changes. See [here](https://stackoverflow.com/a/15745424/5861495) how to do it.
**If you want to update from v5.x / v7.x to the latest version, read [this][docs-update-5-1-x-url].**
## Feedback
@ -120,7 +141,8 @@ Also, we welcome Issue or PR to our [official-plugins][official-plugins-url].
> Thanks jsDelivr for providing public CDN service.
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-data-files-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next

View File

@ -31,14 +31,29 @@
## Установка
Простейший вариант установки — склонировать весь репозиторий:
If you're using Hexo 5.0 or later, the simplest way to install is through npm:
```sh
$ cd hexo
$ cd hexo-site
$ npm install hexo-theme-next
```
Or you can clone the entire repository:
```sh
$ cd hexo-site
$ git clone https://github.com/next-theme/hexo-theme-next themes/next
```
Или предлагаю почитать [детальные инструкции по установке][docs-installation-url], если вариант выше не устраивает.
See [detailed installation instructions][docs-installation-url] if you want any other variant.
## Configuration
At present, NexT encourages users to use the [Alternate Theme Config][docs-configuration-url] to configure NexT. And it's easy to customize the layout or style of NexT using [Custom Files][docs-custom-files-url].
It is not recommended to directly modify any files in the NexT theme. Because this may cause errors (e.g. merge conflicts), and the modified files may be discarded when upgrading the theme.
However, you can bypass merge conflicts (error message like **«Commit your changes or stash them before you can merge»**) by using the `Commit`, `Stash` or `Reset` commands for local changes. See [here](https://stackoverflow.com/a/15745424/5861495) how to do it.
## Плагины
@ -68,14 +83,23 @@ vendors:
## Обновление
NexT выпускает новые версии каждый месяц. Можно обновить до последней мастер-ветки следующей командой:
NexT выпускает новые версии каждый месяц. You can update NexT by the following command.
Install the latest version throuth npm:
```sh
$ cd hexo-site
$ npm update hexo-theme-next
```
Or update to latest master branch:
```sh
$ cd themes/next
$ git pull
```
А если всплывают ошибки во время обновления (что-то наподобии **«Commit your changes or stash them before you can merge»**), рекомендуется ознакомиться с особенностью хранения [Alternate Theme Config][docs-data-files-url].\
А если всплывают ошибки во время обновления (что-то наподобии **«Commit your changes or stash them before you can merge»**), рекомендуется ознакомиться с особенностью хранения [Alternate Theme Config][docs-configuration-url].\
Как бы то ни было, можно обойти ошибки при обновлении если «Закомитить», «Стэшнуть» или «Откатить» локальные изменения. Смотрим [здесь](https://stackoverflow.com/a/15745424/5861495) как это сделать.
**Если нужно обновиться с версии v5.x / v7.x на последней версиями, читаем [здесь][docs-update-5-1-x-url].**
@ -120,7 +144,8 @@ Also, we welcome Issue or PR to our [official-plugins][official-plugins-url].
> Thanks jsDelivr for providing public CDN service.
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-data-files-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next

View File

@ -31,14 +31,29 @@
## 安装
最简单的安装方式是直接克隆整个仓库
如果你在使用 Hexo 5.0 或更新版本,最简单的安装方式是通过 npm
```sh
$ cd hexo
$ cd hexo-site
$ npm install hexo-theme-next
```
你也可以直接克隆整个仓库:
```sh
$ cd hexo-site
$ git clone https://github.com/next-theme/hexo-theme-next themes/next
```
此外,如果你想要使用其他方式,你也可以参见[详细安装步骤][docs-installation-url]。
此外,如果你想要使用其他方式,请参见[详细安装步骤][docs-installation-url]。
## 配置
目前 NexT 鼓励用户使用 [Alternate Theme Config][docs-configuration-url] 进行配置。并且可以轻松地通过 [Custom Files][docs-custom-files-url] 自定义主题的布局和样式。
不推荐直接修改 NexT 主题的文件。因为这可能导致错误(例如 git merge 冲突),并且在升级主题时修改的文件可能丢失。
然而你也可以通过提交(`Commit`)、贮藏(`Stash`)或忽视(`Discard`)本地更改以绕过这种更新错误 (例如 **«Commit your changes or stash them before you can merge»**)。具体方法请参考[这里](https://stackoverflow.com/a/15745424/5861495)。
## 插件
@ -68,16 +83,22 @@ vendors:
## 更新
NexT 每个月都会发布新版本。你可以通过如下命令更新到最新的 master 分支:
NexT 每个月都会发布新版本。你可以通过如下命令更新 NexT。
通过 npm 安装最新版本:
```sh
$ cd hexo-site
$ npm update hexo-theme-next
```
或者通过 git 更新到最新的 master 分支:
```sh
$ cd themes/next
$ git pull
```
如果你在此过程中收到了任何错误报告 (例如 **«Commit your changes or stash them before you can merge»**),我们推荐你使用 [Alternate Theme Config][docs-data-files-url] 特性。\
然而你也可以通过提交(`Commit`)、贮藏(`Stash`)或忽视(`Discard`)本地更改以绕过这种更新错误。具体方法请参考[这里](https://stackoverflow.com/a/15745424/5861495)。
**如果你想要从 v5.x / v7.x 更新到最新版本,阅读[这篇文档][docs-update-5-1-x-url]。**
## 反馈
@ -120,7 +141,8 @@ $ git pull
> jsDelivr 提供了 CDN 服务。
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-data-files-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next

View File

@ -34,12 +34,13 @@
{{ _p('counter.tag_cloud', site.tags.length) }}
</div>
<div class="tag-cloud-tags">
{{ next_tagcloud({
{{ tagcloud({
min_font: theme.tagcloud.min,
max_font: theme.tagcloud.max,
amount : theme.tagcloud.amount,
orderby : theme.tagcloud.orderby,
order : theme.tagcloud.order
order : theme.tagcloud.order,
class : 'tag-cloud'
})
}}
</div>

View File

@ -1,54 +0,0 @@
/* global hexo */
'use strict';
hexo.extend.helper.register('next_tagcloud', function(options) {
let tags = this.site.tags;
if (!tags || !tags.length) return '';
options = options || {};
const min = options.min_font || 10;
const max = options.max_font || 20;
const orderby = options.orderby || 'name';
const order = options.order || 1;
const unit = options.unit || 'px';
const { transform } = options;
const separator = options.separator || ' ';
const result = [];
// Sort the tags
if (orderby === 'random' || orderby === 'rand') {
tags = tags.random();
} else {
tags = tags.sort(orderby, order);
}
// Limit the number of tags
if (options.amount) {
tags = tags.limit(options.amount);
}
const sizes = [];
tags.sort('length').forEach(tag => {
const { length } = tag;
if (sizes.includes(length)) return;
sizes.push(length);
});
const length = sizes.length - 1;
tags.forEach(tag => {
const ratio = length ? sizes.indexOf(tag.length) / length : 0;
const size = min + ((max - min) * ratio);
const style = `font-size: ${parseFloat(size.toFixed(2))}${unit};`;
result.push(
`<a href="${this.url_for(tag.path)}" style="${style}" class="tag-cloud-${Math.round(ratio * 10)}">${transform ? transform(tag.name) : tag.name}</a>`
);
});
return result.join(separator);
});