Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update themes, plugins #2042

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions source/docs/plugins.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Plugins
---

Hexo has a powerful plugin system, which makes it easy to extend functions without modifying the source code of the core module. There are two kinds of plugins in Hexo:

### Script
Expand All @@ -13,15 +14,15 @@ If your code is complicated or if you want to publish it to the NPM registry, we

Your new folder must contain at least two files: one containing the actual JavaScript code and one `package.json` file that describes the purpose of the plugin and sets its dependencies.

``` plain
```plain
.
├── index.js
└── package.json
```

At the very least, you should set the `name`, `version` and `main` entries in `package.json`. For example:

``` json package.json
```json package.json
{
"name": "hexo-my-plugin",
"version": "0.0.1",
Expand All @@ -47,26 +48,27 @@ When your plugin is ready, you may consider publishing it to the [plugin list](/
1. Fork [hexojs/site]
2. Clone the repository to your computer and install dependencies.

{% code %}
$ git clone https://github.com/<username>/site.git
$ cd site
$ npm install
{% endcode %}

3. Edit `source/_data/plugins.yml` and add your plugin. For example:

{% code %}
- name: hexo-server
description: Server module for Hexo.
link: https://github.com/hexojs/hexo-server
tags:
- official
- server
- console
{% endcode %}

4. Push the branch.
5. Create a pull request and describe the change.
```shell
$ git clone https://github.com/<username>/site.git
$ cd site
$ npm install
```

3. Create a new yaml file in `source/_data/plugins/`, use your plugin name as the file name

4. Edit `source/_data/plugins/<your-plugin-name>.yml` and add your plugin. For example:

```yaml
description: Server module for Hexo.
link: https://github.com/hexojs/hexo-server
tags:
- official
- server
- console
```

5. Push the branch.
6. Create a pull request and describe the change.

[hexo-fs]: https://github.com/hexojs/hexo-fs
[hexo-util]: https://github.com/hexojs/hexo-util
Expand Down
57 changes: 29 additions & 28 deletions source/docs/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Themes

It's easy to build a Hexo theme - you just have to create a new folder. To start using your theme, modify the `theme` setting in your site's `_config.yml`. A theme should have the following structure:

``` plain
```plain
.
├── _config.yml
├── languages
Expand All @@ -15,7 +15,7 @@ It's easy to build a Hexo theme - you just have to create a new folder. To start
└── source
```

### _config.yml
### \_config.yml

Theme configuration file. Unlike the site's primary configuration file, modifying this doesn't require a server restart.

Expand All @@ -27,7 +27,7 @@ Language folder. See [internationalization (i18n)](internationalization.html) fo

Layout folder. This folder contains the theme's template files, which define the appearance of your website. Hexo provides the [Nunjucks] template engine by default, but you can easily install additional plugins to support alternative engines such as [EJS], [Haml], [Jade], or [Pug]. Hexo chooses the template engine based on the file extension of the template (just like the posts). For example:

``` plain
```plain
layout.ejs - uses EJS
layout.njk - uses Nunjucks
```
Expand All @@ -51,34 +51,35 @@ When you have finished building your theme, you can publish it to the [theme lis
1. Fork [hexojs/site]
2. Clone the repository to your computer and install dependencies.

```shell
$ git clone https://github.com/<username>/site.git
$ cd site
$ npm install
```

3. Edit `source/_data/themes.yml` and add your theme. For example:

```yaml
- name: landscape
description: A brand new default theme for Hexo.
link: https://github.com/hexojs/hexo-theme-landscape
preview: http://hexo.io/hexo-theme-landscape
tags:
- official
- responsive
- widget
- two_column
- one_column
```

4. Add a screenshot (with the same name as the theme) to `source/themes/screenshots`. It must be a 800*500px PNG.
5. Push the branch.
6. Create a pull request and describe the change.
```shell
$ git clone https://github.com/<username>/site.git
$ cd site
$ npm install
```

3. Create a new yaml file in `source/_data/themes/`, use your theme name as the file name

4. Edit `source/_data/themes/<your-theme-name>.yml` and add your theme. For example:

```yaml
description: A brand new default theme for Hexo.
link: https://github.com/hexojs/hexo-theme-landscape
preview: http://hexo.io/hexo-theme-landscape
tags:
- official
- responsive
- widget
- two_column
- one_column
```

5. Add a screenshot (with the same name as the theme) to `source/themes/screenshots`. It must be a 800\*500px PNG.
6. Push the branch.
7. Create a pull request and describe the change.

[EJS]: https://github.com/hexojs/hexo-renderer-ejs
[Haml]: https://github.com/hexojs/hexo-renderer-haml
[Jade]: https://github.com/hexojs/hexo-renderer-jade
[Pug]: https://github.com/maxknee/hexo-render-pug
[hexojs/site]: https://github.com/hexojs/site
[Nunjucks]: https://mozilla.github.io/nunjucks/
[Nunjucks]: https://mozilla.github.io/nunjucks/