hexo-generator-plus
v0.2.3
Published
A package that generates index, archive, categories and tags pages for Hexo
Downloads
2
Readme
hexo-generator-plus
中文文档
A package that generates index, archive, categories and tags pages for Hexo. It supports i18n and index pages for categories and tags.
Installation
$ npm uninstall hexo-generator-index hexo-generator-archive hexo-generator-category hexo-generator-tag
$ npm install hexo-generator-plus --save
Usage
If your site contains only one language, there's no additional actions required. This package will generate files as normal.
i18n
Please follow these steps for internationalization
- Create a new folder for each language, and put all posts and pages in the corresponding folder. For example:
sources/
en/
post1.md
post2.md
zh/
post3.md
post4.md
- Add the following to _config.yml:
generator_plus:
language: ['first language', 'second language']
- Change
new_post_name
variable in _config.yml tonew_post_name: :lang/:title.md
- Change
permalink
variable in _config.ymlpermalink: :lang/{what was here before}
Helpers
url_for_lang()
returns a proper i18n url. You should only use this for categories and tags, but not for posts.
get_posts()
returns all posts written in current language.
get_categories()
returns all categories that contain at least a post in current language.
get_tags()
returns all tags that contain at least one post in current language.
Note: The current language refers to the language of the page from which the function is called
Options
Add or modify the following section to your root _config.yml file
generator_plus:
language: 'default'
pagination_dir: 'page'
generator: ["index", "archive", "category", "tag"]
index_generator:
per_page: 10
order_by: -date
archive_generator:
per_page: 10
order_by: -date
category_generator:
per_page: 10
order_by: -date
enable_index_page: false
tag_generator:
per_page: 10
order_by: -date
enable_index_page: false
Overall Options:
- language: Languages in site
- default: language in original config, if not defined then
default
.
- default: language in original config, if not defined then
- pagination_dir: Pagination dir
- default: pagination_dir in original config, if not defined then
page
.
- default: pagination_dir in original config, if not defined then
- generator: Generators wanted
- default: ["index", "archive", "category", "tag"]
For all generators:
- per_page: Posts displayed per page.
- default: per_page in original config, then
10
. 0
disables pagination
- default: per_page in original config, then
- order_by: Posts order.
- default: date descending
For category_generator
and tag_generator
only:
- enable_index_page: Whether to generate the index page.
- default: false
Layout:
Layout files are not configurable, but here are the orders of layout files used:
- Index: index.ejs
- Archive: archive.ejs, index.ejs
- Category: categories.ejs, index.ejs
- Category (index page): categories-index.ejs, 'categories.ejs, index.ejs
- Tag: tags, index.ejs
- Tag (index page): tags-index, tags.ejs, index.ejs
Note
For how to incooperate this plugin into a site, please visit hexo-theme-world.