diff --git a/_config.yml b/_config.yml index c6214a41ce..0e253918a9 100644 --- a/_config.yml +++ b/_config.yml @@ -43,8 +43,7 @@ disqus_shortname: # Extensions plugins: -- hexo-generator-sitemap -theme: hexo +theme: hexo2 exclude_generator: - category - tag @@ -57,7 +56,6 @@ auto_spacing: false titlecase: false highlight: enable: true - backtick_code_block: true line_number: false tab_replace: ' ' diff --git a/package.json b/package.json index 0e659811a0..107bdbc1ea 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,10 @@ { "name": "hexo", - "version": "1.1.1", + "version": "2.0.0-beta2", "private": true, "engines": { "node": ">0.6.0", "npm": ">1.1.0" }, - "dependencies": { - "hexo-generator-sitemap": "*" - } + "dependencies": {} } \ No newline at end of file diff --git a/scripts/note.js b/scripts/note.js new file mode 100644 index 0000000000..aad3721640 --- /dev/null +++ b/scripts/note.js @@ -0,0 +1,13 @@ +var extend = hexo.extend, + renderSync = hexo.render.renderSync; + +extend.tag.register('note', function(args, content){ + var className = args.shift(), + header = ''; + + if (args.length){ + header += '' + args.join(' ') + ''; + } + + return '
' + header + renderSync({text: content, engine: 'markdown'}) + '
'; +}, true); \ No newline at end of file diff --git a/source/docs/cli.md b/source/docs/cli.md deleted file mode 100644 index c00af47c08..0000000000 --- a/source/docs/cli.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -layout: page -title: Command-line Interface (CLI) -date: 2012-11-01 18:13:30 ---- - -Display current version of Hexo - -``` plain -hexo version -``` - -Setup website. If `folder` is not defined, Hexo will setup website at current directory. - -``` plain -hexo init [folder] -``` - -Create a new article - -``` plain -hexo new [layout] -``` - -Generate static files. - -- -d/--deploy: Deploy automatically after generate -- -w/--watch: Watch file changes - -``` plain -hexo generate -``` - -Start server. Press `Ctrl+C` to stop it. - -- -p/--port: Port setting -- -s/--static: Only serve static files - -``` plain -hexo server -``` - -Display configuration of the site - -``` plain -hexo config -``` - -Deploy - -- --setup: Setup without deployment -- --generate: Generate before deployment - -``` plain -hexo deploy -``` - -Render - -- -o/--output: Output path - -``` plain -hexo render -``` - -Safe mode. Plugins will not be loaded in this mode. - -``` plain -hexo --safe -``` - -Debug mode. - -``` plain -hexo --debug -``` \ No newline at end of file diff --git a/source/docs/collection.md b/source/docs/collection.md deleted file mode 100644 index d76866d05f..0000000000 --- a/source/docs/collection.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -layout: page -title: Collection -date: 2012-11-01 18:13:30 ---- - -Since 1.0, Hexo records all data with [Warehouse][1]. [Warehouse][1] inherits some parts of old features and adds searching, improves performance, more powerful than before. - -<a name="model>"></a> -## Model - -Model is a collection of data. - -#### get(id1[, id2, ..., idN]) - -Gets data of specific id. Returns an array when multiple id. - -#### each(iterator) - -Iterates over all items in the model, executing `iterator(data, id)`. - -#### toArray() - -Transforms the model into an array. - -#### count() - -Returns the number of elements. Equals to `length`. - -#### insert(data, callback) - -Inserts data to the model. `data` can be an object or an array. Once the insertion is complete, executing `callback(data, id)`. - -#### update([id, ]data) - -Updates data. `id` can be a number or an array. If `id` is undefined, updates all items in the model. - -Operators: - -- **$push** - Appends elements to an array -- **$pull** - Remove elements from an array -- **$shift** - Removed the first elements from an array -- **$pop** - Removed the last elements from an array -- **$addToSet** - Appends elements to an array (only if the elements not exists) -- **$inc** - Increase number -- **$dec** - Decrease number - -#### replace([id, ]data) - -Replaces data. `id` can be a number or an array. If `id` is undefined, replaces all items in the model. - -#### remove([id1, id2, ..., idN]) - -Removes data. If `id` is undefined, removes all items in the model. - -#### destroy() - -Removes all data of the model from the database. - -#### first() - -Gets the first item. - -#### last() - -Gets the last item. - -#### eq(num) - -Gets the specific position of the item. - -#### slice(start[, end]) - -Gets the specific part of the model. `start` and `end` can be a negative number. - -#### limit(num) - -Limits the number of items in the model. - -#### skip(num) - -Skips the first items of the model. - -#### reverse() - -Reversed the order of the model. - -#### sort(orderby[, order]) - -Sorts the items in the model. Descending when `order` equals to `1` or `desc`, otherwise ascending. - -#### random() - -Sorts data randomly. - -#### find(query) - -Finds data. - -Operators: - -- **$lt** - Less than -- **$lte** - Less than equal -- **$gt** - Greater than -- **$gte** - Greater than equal -- **$length** - Number of elements in an array -- **$in** - An array contains the element -- **$nin** - An array doesn't contain the element -- **$all** - n array contains all elements -- **$exists** - Item exists or not -- **$ne** - Not equal - -#### findRaw(query) - -Finds data based on raw data. - -#### findOne(query) - -Finds data and returns the first matched item. - -[1]: https://github.com/tommy351/warehouse \ No newline at end of file diff --git a/source/docs/commands.md b/source/docs/commands.md new file mode 100644 index 0000000000..e2a9a4bec6 --- /dev/null +++ b/source/docs/commands.md @@ -0,0 +1,119 @@ +title: Commands +prev: configuration +next: migration +--- +## init + +``` bash +$ hexo init [folder] +``` + +Setup a website. If `folder` isn't defined, Hexo will setup the website at the current directory. + +## new + +``` bash +$ hexo new [layout] <title> +``` + +Create a new article. If `layout` isn't defined, it'll be `default_layout` setting. If the title is more than one word, wrap it with quotation marks. + +## generate + +``` bash +$ hexo generate +``` + +Generate static files. + +Option | Description +--- | --- +`-d`<br>`--deploy` | Deploy after generate done +`-w`<br>`--watch` | Watch file changes + +## server + +``` bash +$ hexo server +``` + +Start server. + +Option | Description +--- | --- +`-p`<br>`--port` | Override default port +`-s`<br>`--static` | Only serve static files +`-l`<br>`--log` | Enable logger. Override logger format. + +## deploy + +``` bash +$ hexo deploy +``` + +Deploy your website. + +Option | Description +--- | --- +`--setup` | Setup without deployment +`--generate` | Generate before deployment + +## render + +``` bash +$ hexo render <file1> [file2] ... +``` + +Option | Description +--- | --- +`-o`<br>`--output` | Output destination + +## migrate + +``` bash +$ hexo migrate <type> +``` + +Migrate from other blog systems. + +## clean + +``` bash +$ hexo clean +``` + +Clean the cache file (`db.json`). + +## list + +``` bash +$ hexo list <type> +``` + +List all categories/pages/posts/routes/tags. + +## version + +``` bash +$ hexo version +``` + +Display version information. + +## Others + +### Safe mode + +``` bash +$ hexo --safe +``` + +Plugins and scripts won't be loaded in safe mode. You can try this when you encounter some problems after installing a new plugin. + +### Debug mode + +``` bash +$ hexo --debug +``` + +Display verbose messages in console directly. When you encounter some problems, run Hexo again in the debug mode and submit the messages on GitHub. \ No newline at end of file diff --git a/source/docs/configuration.md b/source/docs/configuration.md new file mode 100644 index 0000000000..1c6dc5f7d2 --- /dev/null +++ b/source/docs/configuration.md @@ -0,0 +1,162 @@ +title: Configuration +prev: setup +next: commands +--- +You can modify most of options in `_config.yml`. + +## Configuration + +### Site + +Setting | Description +--- | --- +`title` | The title of your website +`subtitle` | The subtitle of your website +`desciprtion` | The description of your website +`author` | Your name +`email` | Your email address +`language` | The language used in your website. Use [IETF format](http://www.w3.org/International/articles/language-tags/). (e.g. Traditional Chinese: `zh-TW`) + +### URL + +Setting | Description | Default +--- | --- | --- +`url` | The URL of your website | +`root` | The root directory of your website | +`permalink` | The [permalink](permalinks.html) format of articles | :year/:month/:day/:title/ +`tag_dir` | Tag directory | tags +`archive_dir` | Archive directory | archives +`category_dir` | Category directory | categories +`code_dir` | Include code directory | downloads/code + +{% note info Website in subdirectory %} +If your website is put in subdirectory such as `http://yoursite.com/blog`. Set `url` as `http://yoursite.com/blog` and `root` as `/blog/`. +{% endnote %} + +### Writing + +Setting | Description | Default +--- | --- | --- +`new_post_name` | The filename of the new post | :title.md +`default_layout` | Default layout | post +`auto_spacing` | Add a space between eastern and western characters | false +`titlecase` | Transform title into proper title case | false +`external_link` | Open external links in new tab | true +`max_open_file` | Maximum synchronous I/O when generating files | 100 +`multi_thread` | Enable multi-thread generating | true +`filename_case` | Transform filename into (1) lower case or (2) upper case | 0 +`highlight` | Code block settings | + +### Category & Tag + +Setting | Description | Default +--- | --- | --- +`default_category` | Default category | uncategorized +`category_map` | Category slugs | +`tag_map` | Tag slugs | + +### Archives + +Setting | Description | Default +--- | --- | --- +`archive` | 2: Enable pagination, 1: Disable pagination, 0: Fully disable | 2 +`category` | 2: Enable pagination, 1: Disable pagination, 0: Fully disable | 2 +`tag` | 2: Enable pagination, 1: Disable pagination, 0: Fully disable | 2 + +### Server + +Setting | Description | Default +--- | --- | --- +`port` | Server port | 4000 +`logger` | Display request info on the console. Always enabled in debug mode. | false +`logger_format` | Logger format | + +### Date / Time format + +Hexo uses [Moment.js](http://momentjs.com/) to parse and display date. + +Setting | Description | Default +--- | --- | --- +`date_format` | Date format | MMM D YYYY +`time_format` | Time format | H:mm:ss + +### Pagination + +Setting | Description | Default +--- | --- | --- +`per_page` | The amount of the posts displayed in a single page (0 = Disable pagination) | 10 +`pagination_dir` | Pagination directory | page + +### Comment + +Setting | Description +--- | --- +`disqus_shortname` | [Disqus](http://disqus.com/) shortname + +### Extensions + +Setting | Description +--- | --- +`theme` | Current theme +`exclude_generator` | Disabled generators (archive, category, home, page, post, tag) + +{% note warn Configuration files is YAML files %} +Don't use tabs in configuration files, use spaces instead. Also, add a space after colons. Configuration files parsing error may cause Hexo can't run properly. +{% endnote %} + +## Default Configuration + +``` yaml +title: Hexo +subtitle: +description: +author: John Doe +email: +language: + +url: http://yoursite.com +root: / +permalink: :year/:month/:day/:title/ +tag_dir: tags +archive_dir: archives +category_dir: categories +code_dir: downloads/code + +new_post_name: :title.md +default_layout: post +auto_spacing: false +titlecase: false +max_open_file: 100 +multi_thread: true +filename_case: 0 +highlight: + enable: true + line_number: true + tab_replace: + +default_category: uncategorized +category_map: +tag_map: + +archive: 2 +category: 2 +tag: 2 + +port: 4000 +logger: false +logger_format: + +date_format: MMM D YYYY +time_format: H:mm:ss + +per_page: 10 +pagination_dir: page + +disqus_shortname: + +theme: light +exclude_generator: + +deploy: + type: +``` \ No newline at end of file diff --git a/source/docs/configure.md b/source/docs/configure.md deleted file mode 100644 index 790b56612f..0000000000 --- a/source/docs/configure.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -layout: page -title: Configure -date: 2012-11-01 18:13:30 ---- - -The global configuration file is saved at `_config.yml` in the root directory of the website. - -## Configure - -### Site - -- **title** - Website title -- **subtitle** - Website subtitle -- **description** - Website description -- **author** - The author of the website -- **email** - Email address of the author -- **language** - The language used in the website ([IETF format][1]. e.g. Traditional Chinese is `zh-TW`) - -### URL - -- **url** - Website URL -- **root** - The root directory of the website. For example, given `url` is `http://yoursite.com/child`, then `root` is `/child/`. -- **permalink** - The URL format of articles ([Configure][2]) -- **tag_dir** - Tag directory -- **archive_dir** - Archive directory -- **category_dir** - Category directory - -### Writing - -- **new_post_name** - Filename of new post ([Configure][7]) -- **default_layout** - Default layout -- **auto_spacing** - Add spaces between eastern and wastern characters -- **titlecase** - Transform title into title case -- **max_open_file** - Synchronous I/O maximum -- **filename_case** - Transform file name into (1) lower case (2) uppercase -- **highlight** - Code block settings - - **enable** - Enable code highlight - - **backtick_code_block** - Enable [Backtick Code Block][6] - - **line_number** - Display line numbers - - **tab_replace** - Tab replacement - -### Category & Tag - -- **default_category** - Default category -- **category_map** - Category slugs -- **tag_map** - Tag slugs - -### Archive - -`2` - Enable pagination -`1` - Disable pagination -`0` - Fully disable - -- **archive** -- **category** -- **tag** - -### Server - -- **port** - Server port -- **logger** - Enable logger for server -- **logger_format** - The format of logger ([Connect][3]) - -### Date / Time Format - -Hexo uses Moment.js to parse and display date. ([Moment.js][4]) - -- **date_format** - Date format -- **time_format** - Time format - -### Pagination - -- **per_page** - The amount of the posts displayed in a single page(0 = Disable) -- **pagination_dir** - Pagination directory - -### Disqus - -- **disqus_shortname** - [Disqus][5] shortname - -### Extensions - -- **themes** - Current theme -- **exclude_generator** - The generators to disable(archive, category, home, page, post, tag) - -### Deployment - -- **type** - Deployment type - -Configure settings according to the deployment plugin you used. - -## Default - -``` yaml -# Hexo Configuration -## Docs: http://zespia.tw/hexo/docs/configure.html -## Source: https://github.com/tommy351/hexo/ - -# Site -title: Hexo -subtitle: -description: -author: John Doe -email: -language: - -# URL -## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' -url: http://yoursite.com -root: / -permalink: :year/:month/:day/:title/ -tag_dir: tags -archive_dir: archives -category_dir: categories - -# Writing -new_post_name: :title.md # File name of new posts -default_layout: post -auto_spacing: false # Add spaces between asian characters and western characters -titlecase: false # Transform title into titlecase -max_open_file: 100 -filename_case: 0 -highlight: - enable: true - backtick_code_block: true - line_number: true - tab_replace: - -# Category & Tag -default_category: uncategorized -category_map: -tag_map: - -# Archives -## 2: Enable pagination -## 1: Disable pagination -## 0: Fully Disable -archive: 2 -category: 2 -tag: 2 - -# Server -## Hexo uses Connect as a server -## You can customize the logger format as defined in -## http://www.senchalabs.org/connect/logger.html -port: 4000 -logger: false -logger_format: - -# Date / Time format -## Hexo uses Moment.js to parse and display date -## You can customize the date format as defined in -## http://momentjs.com/docs/#/displaying/format/ -date_format: MMM D YYYY -time_format: H:mm:ss - -# Pagination -## Set per_page to 0 to disable pagination -per_page: 10 -pagination_dir: page - -# Disqus -disqus_shortname: - -# Extensions -## Plugins: https://github.com/tommy351/hexo/wiki/Plugins -## Themes: https://github.com/tommy351/hexo/wiki/Themes -theme: light -exclude_generator: - -# Deployment -## Docs: http://zespia.tw/hexo/docs/deploy.html -deploy: - type:``` - -[1]: http://www.w3.org/International/articles/language-tags/ -[2]: permalink.html -[3]: http://www.senchalabs.org/connect/logger.html -[4]: http://momentjs.com/docs/#/displaying/format/ -[5]: http://disqus.com/ -[6]: tag-plugins.html -[7]: writing.html \ No newline at end of file diff --git a/source/docs/contribute.md b/source/docs/contribute.md deleted file mode 100644 index 3b8ff72944..0000000000 --- a/source/docs/contribute.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -layout: page -title: Contribute -date: 2012-11-01 18:13:30 ---- - -## Report Issues - -You may have found some bugs when using Hexo, or have some questions and recommendations. Feel free to submit them on GitHub. - -You can clone the **dev** branch on GitHub to try the new features. It's updated everyday! - -``` -npm install -g https://github.com/tommy351/hexo/archive/dev.tar.gz -``` - -[Report an issue][1] - -## Write Docs - -If you found there's an error in the docs, you can: - -1. Fork this project -2. Create a new branch based on **site** branch -3. Edit the docs -4. Submit a pull request to **site** branch - -If you want to help translate the docs, create a new folder in `source` folder and copy source files into it. For example: - -``` plain -zh-TW -|-- docs -|-- index.md -|-- plugins -|-- themes -``` - -And add language setting in every posts like this: - -``` plain ---- -layout: page -title: 貢獻 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- -``` - -Please follow the [IETF format][3]. - -[Source code][2] - -## Participate - -If you want to participate in the development, you can: - -1. Fork this project -2. Create a new branch -3. Submit a pull request to **dev** branch after the new feature is done - -If you make an awesome plugin, you can submit a pull request, too. The plugin you developed may be a part of the main program! - -[Source code][4] - -[1]: https://github.com/tommy351/hexo/issues -[2]: https://github.com/tommy351/hexo/tree/site -[3]: http://www.w3.org/International/articles/language-tags/ -[4]: https://github.com/tommy351/hexo \ No newline at end of file diff --git a/source/docs/contributing.md b/source/docs/contributing.md new file mode 100644 index 0000000000..60d3709825 --- /dev/null +++ b/source/docs/contributing.md @@ -0,0 +1,54 @@ +title: Contributing +prev: troubleshooting +--- +It's great to hear you'd like to make Hexo more awesome! When modifying JavaScript code, please keep the following in your mind. + +- Please follow the [Google JavaScript Style Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml). +- Comment in [JSDoc](http://usejsdoc.org/) format. + +## Development + +1. Fork the Hexo repository. +2. Clone the repository to your computer. + + ``` bash + $ git clone git://github.com/<username>/hexo.git + ``` + +3. Install dependencies. + + ``` bash + $ make install + ``` + +4. Create a new branch and start hacking. +5. Push the branch. +6. Create a pull request on GitHub. + +{% note warn Don't change version in package.json %} +When making changes on Hexo, don't change version number in `package.json`. +{% endnote %} + +## Updating Documentation + +The Hexo documentation is open-source and you can find it on `site` branch of Hexo repository. Here's how you can make the documentation better: + +1. Fork the Hexo repository. +2. Clone the repository to your computer. + + ``` bash + $ git clone -b site git://github.com/<username>/hexo.git + ``` + +3. Create a new branch and start editing. +4. See live changes with `hexo server`. +5. Push the branch. +6. Create a pull request on GitHub. + +## Reporting an Issue + +When you come across problems, try to find the solution [here](troubleshooting.html). If the problem still exists, please do the following: + +1. Run it again in debug mode. +2. Run `hexo version` to check the version info +3. Post both debug message and version info on GitHub. \ No newline at end of file diff --git a/source/docs/deploy.md b/source/docs/deploy.md deleted file mode 100644 index 585d0e755c..0000000000 --- a/source/docs/deploy.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -layout: page -title: Deploy -date: 2012-11-01 18:13:30 ---- - -It's easy to deploy with Hexo. It just needs 1 command to complete all the settings. - -## GitHub - -### Configure - -Edit `_config.yml`. Fill `repository` with GitHub repository. If repository is like `username.github.io`, fill `branch` with `master`, otherwise `gh-pages`. - -``` yaml -deploy: - type: github - repository: - branch: -``` - -- **repository** - GitHub repository -- **branch** - If repository is like `username.github.io`, fill it with `master`, otherwise `gh-pages` - -### Deploy - -After the static files are generated, execute the following to deploy. You can add `--generate` option to generate automatically before deploy. - -``` bash -hexo deploy -hexo deploy --generate -``` - -### Remove - -Execute the following command to remove deployment. - -``` bash -rm -rf .deploy -``` - -### Custom Domain - -Create a file name `CNAME` in `source` folder with the following content. - -``` -example.com -``` - -Configure DNS according to the type of domain. - -#### Top-level Domain - -If the domain is like `example.com`, add A record `204.232.175.78`. - -#### Subdomain - -If the domain is like `username.example.com`, add CNAME record `username.github.io`. - -Check [GitHub Pages][1] for more info. - -## Heroku - -### Configure - -Edit `_config.yml`. - -``` yaml -deploy: - type: heroku - repository: -``` - -- **repository** - Heroku repository - -### Deploy - -After the static files are generated, execute the following to deploy. You can add `--generate` option to generate automatically before deploy. - -``` bash -hexo deploy -hexo deploy --generate -``` - -Check [Heroku][2] for more info. - -### Remove - -Remove `.git`, `app.js` and `Procfile`. - -## Rsync - -### Configure - -Edit`_config.yml`. - -``` yaml -deploy: - type: rsync - host: - user: - root: - port: - delete: -``` - -- **host** - Address of remote host -- **user** - Username -- **root** - Root directory of remote host -- **port** - Port (Default is `22`) -- **delete** - Delete old files on remote host (Default is `true`) - -### Deploy - -After the static files are generated, execute the following to deploy. You can add `--generate` option to generate automatically before deploy. - -``` bash -hexo deploy -hexo deploy --generate -``` - -[1]: https://help.github.com/articles/setting-up-a-custom-domain-with-pages -[2]: https://devcenter.heroku.com/ diff --git a/source/docs/deployment.md b/source/docs/deployment.md new file mode 100644 index 0000000000..d2dfd0102b --- /dev/null +++ b/source/docs/deployment.md @@ -0,0 +1,90 @@ +title: Deployment +prev: server +next: permalinks +--- +To deploy your site with Hexo, you only need one command. + +``` bash +$ hexo deploy +``` + +## GitHub + +Edit `_config.yml`. + +``` yaml +deploy: + type: github + repository: + branch: +``` + +Option | Description +--- | --- +`repository` | GitHub repository URL (It's better to use HTTPS) +`branch` | Target branch. If your repository name is `username.github.io` or `username.github.com`, this value will be `master`, `gh-pages` otherwise. + +### Remove + +Remove `.deploy` folder. + +``` bash +$ rm -rf .deploy +``` + +### Custom Domain + +Create a file named `CNAME` in `source` folder with the following content. + +``` +example.com +``` + +- **Top-level Domain:** Add A record `204.232.175.78` +- **Subdomain**: Add CNAME record `blog.example.com`. + +Check [GitHub Pages](https://help.github.com/articles/setting-up-a-custom-domain-with-pages) for more info. + +## Heroku + +Edit `_config.yml`. + +``` yaml +deploy: + type: heroku + repository: +``` + +Option | Description +--- | --- +`repository` | Heroku repository URL + +### Remove + +Remove `.git`, `app.js` & `Procfile`. + +## Rsync + +Edit `_config.yml`. + +``` yaml +deploy: + type: rsync + host: + user: + root: + port: + delete: +``` + +Option | Description | Default +--- | --- | --- +`host` | Address of remote host | +`user` | Username | +`root` | Root directory of remote host | +`port` | Port | 22 +`delete` | Delete old files on remote host | true + +## Other Methods + +All generated files are saved in `public` folder. You can copy it to wherever you like. \ No newline at end of file diff --git a/source/docs/events.md b/source/docs/events.md index 172e3852aa..427169fea8 100644 --- a/source/docs/events.md +++ b/source/docs/events.md @@ -1,34 +1,45 @@ ---- -layout: page title: Events -date: 2012-11-01 18:13:30 +prev: models +next: plugins --- +Hexo inherits EventEmitter of Node.js. You can subscribe or publish specified events. For example: -[Global variable][1] `hexo` itself is a [EventEmitter][2] object. You can listen or emit events. - -## Usage - -Listen an event: - -``` +``` js hexo.on('ready', function(){ - ... + console.log('Hexo is ready to go!'); }); ``` -Emit an event: +## Methods -``` -hexo.emit('event', [arg1], [arg2], [….]); -``` +All methods except `emit` returns the emitter itself, so calls can be chained. + +### addListener(event, listener) +### on(event, listener) + +Listens to the specific event. -[Reference][2] +### once(event, listener) -## Default events +Listens to the specified event **only once**. After the event is fired, the listener will be removed. + +### removeListener(event, listener) + +Removes a listener from the specified event. + +### removeAllListeners([event]) + +Removes all listeners. + +### emit(event, [arg1], [arg2], […]) + +Fires the specified event. Returns `true` if event had listener, `false` otherwise. + +## Events ### ready -Called after all configurations and plugins loaded completely. +Called once Hexo is initialized. ### generateBefore @@ -48,15 +59,16 @@ Called after processing. ### new -Called after a new article created. Return an argument `target` which means the absolute path of the new file. +Called after a new post file is created. -### server +Argument | Description +--- | --- +`target` | Absolute path of the post file -Called after the server is on. +### server -### Exit +Called after server is on. -Called when process exits. +### exit -[1]: global-variables.html -[2]: http://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file +Called when Hexo exits. \ No newline at end of file diff --git a/source/docs/generating.md b/source/docs/generating.md new file mode 100644 index 0000000000..3e70f0ec0c --- /dev/null +++ b/source/docs/generating.md @@ -0,0 +1,40 @@ +title: Generating +prev: writing +next: tag-plugins +--- +Generate static files with Hexo is quite easy and fast. + +``` bash +$ hexo generate +``` + +### Watch for File Changes + +Hexo can watch for file changes and regenerate files immediately. + +``` bash +$ hexo generate --watch +``` + +{% note info Restart Hexo after configuration changed %} +Hexo doesn't watch for configuration file changes. You have to restart Hexo to make the new configurations take effects. +{% endnote %} + +### Multi-thread Generating + +Hexo supports multi-thread generating since 2.0. To enable this feature, edit `_config.yml`. + +``` yaml +multi_thread: true +``` + +You can change how many threads to use. Just edit `multi_thread` with the number of threads. The number of threads is the number of CPU cores by default. It's not recommended to set any value higher than it. + +### Deploy After Generating + +To deploy after generating, you can run one of the following commands. Both of them are equaled. + +``` bash +$ hexo generate --deploy +$ hexo deploy --generate +``` \ No newline at end of file diff --git a/source/docs/global-variables.md b/source/docs/global-variables.md deleted file mode 100644 index 88d045dc90..0000000000 --- a/source/docs/global-variables.md +++ /dev/null @@ -1,215 +0,0 @@ ---- -layout: page -title: Global Variables -date: 2012-11-01 18:13:30 ---- - -Hexo creates a namespace `hexo` when initializing with the following read-only variables. - -- **base_dir** - Root directory -- **public_dir** - Static files directory (public) -- **source_dir** - Source files directory (source) -- **theme_dir** - Theme directory (theme/theme_name) -- **plugin_dir** - Plugin directory (node_modules) -- **script_dir** - Script directory (scripts) -- **scaffold_dir** - Scaffold directory (scaffolds) -- **core_dir** - Program root directory (hexo) -- **lib_dir** - Program library directory (hexo/lib) -- **version** - Version of Hexo -- **env** - Environment -- **safe** - Safe mode -- **debug** - Debug mode -- **config** - [Global configuration][1], the content of `_config.yml` -- **render** - [Render][5] -- **[extend](#extend)** - Extensions -- **[util](#util)** - Utilities -- **[i18n](#i18n)** - Internationalization (i18n) module -- **[route](#route)** - Route module -- **[call](#call)** - Call other console -- **[db](#db)** - Database - -<a name="extend"></a> -### extend - -**extend** is the module handling all extensions. Each extension has two method: **list** & **register**. The former lists all extensions that the object handling; the letter registers a new extension to the object. - -#### generator - -- **list** - Returns an array. -- **register(fn)** - Registers a extension. - -#### renderer - -- **list** - Returns an object. The element in the object has `output` property. -- **register(name, output, fn, sync)** - Registers a extension. `name` is the name of the extension. `output` is the extension of output files. `sync` is sync mode. (Default is `false`) - -#### tag - -- **list** - Returns an object. -- **register(name, fn, ends)** - Registers a extension. `name` is the name of the extension. `ends` is end tag. (Default is `false`) - -#### deployer - -- **list** - Returns an object. -- **register(name, fn)** - Registers a extension. `name` is the name of the extension. - -#### processor - -- **list** - Returns an array. -- **register(fn)** - Registers a extension. - -#### helper - -- **list** - Returns an array. -- **register(name, fn)** - Registers a extension. `name` is the name of the extension. - -#### console - -- **list** - Return an object. The element in the object has `description` property. -- **register(name, desc, fn)** - Registers a extension. `name` is the name of the extension. `desc` is the description of the extension. - -#### migrator - -- **list** - Returns an object. -- **register(name, fn)** - Registers a extension. `name` is the name of the extension. - -Check [plugin development][2] for more info. - -<a name="util"></a> -### util - -**util** is the utilities, including the following module: - -#### file - -Operates file I/O, owning the following method: - -- **mkdir(dest, callback)** -- **write(dest, content, callback)** -- **copy(src, dest, callback)** -- **dir(src, callback)** -- **read(src, callback)** -- **readSync(src, callback)** -- **empty(target, exclude, callback)** - -#### highlight(string, options) - -Exports highlighted code block. The following is the options: - -- **gutter** - Display line numbers -- **first_line** - The first line number -- **lang** - Language -- **caption** - Caption - -#### titlecase(string) - -Transforms a string into proper title capitalization. - -#### yfm(string) - -Parses [YAML Front Matter][3]. Exports an object. The content is `_content` property. - -<a name="i18n"></a> -### i18n - -**i18n** is internationalization (i18n) module. Here's how to use: - -``` js -var i18n = new hexo.i18n(); -``` - -A i18n object owns the following methods: - -#### get - -The first argument must be the key value. The other arguments will be processed by [util.format][4]. - -When the first argument is an array, it will detect the second argument to process plural nouns. - -- 2 elements in the 1st argument: - - n > 1: Use the 2nd element - - n <= 1: Use the 1st element -- 3 elements in the 1st argument: - - n > 1: Use the 3rd element - - 0 < n <= 1: Use the 2nd element - - n == 0: Use the 1st element - -#### set(key, value) - -- **key** - Key value -- **value** - Value - -#### list([obj]) - -Returns all elements of the object if `obj` undefined. Replaces the object with the argument if `obj` is an object. - -#### load(path, callback) - -Loads language files automatically. `path` is the language file directory. Hexo will based on `language` setting in `_config.yml`. If the language file is not found, it will load `default.yml` instead. So the directory must have `default.yml` at least. - -<a name="route"></a> -### route - -Hexo has started using route module to handle all paths of the website since version 0.3. - -#### get(path) - -Gets the content of the path. - -``` js -route.get(path, function(err, result){ - ... -}); -``` - -#### set(path, content) - -Sets the content of the path. `content` can be a function or else. If it is a function, it must pass a callback with two arguments: `(err, result)`. - -``` js -route.set(path, content); - -route.set(path, function(fn){ - fn(null, 'content'); -}); -``` - -#### format(path) - -Formats the path. Adds `index.html` if the path is empty or ended with `/`. - -#### remove(path) - -Deletes a path. - -#### list() - -Returns an object. - -<a name="call"></a> -### call - -#### call(name, [args], callback) - -- **name** - Console name -- **args** - Arguments -- **callback** - Callback function - -`call` is used to call other console plugins. For example: - -``` js -hexo.call('generate', function(){ - // ... -}); -``` - -<a name="db"></a> -### db - -Database. - -[1]: configure.html -[2]: plugin-development.html -[3]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[4]: http://nodejs.org/api/util.html#util_util_format_format -[5]: render.html \ No newline at end of file diff --git a/source/docs/helpers.md b/source/docs/helpers.md index f358b88b32..2fdd8e260c 100644 --- a/source/docs/helpers.md +++ b/source/docs/helpers.md @@ -1,55 +1,68 @@ ---- -layout: page title: Helpers -date: 2012-11-01 18:13:30 +prev: pagination +next: i18n --- - -Helpers help you transform data into HTML string in templates, making it easier to develop a theme. The following is built-in helpers. +Helpers help you inserts specified content in theme or processes contents in theme quickly. ### css -Loads CSS file. `path` can be an array or a string. +Loads CSS files. `path` can be an array or a string. If `path` isn't prefixed with `/` or any protocol, it'll be prefixed with root URL. If you didn't add extension name `.css` after `path`, it'll be added. -``` -<%- css(path) %> +``` js +<%- css(path, [path1], [path2], [...]) %> ``` **Examples:** ``` js <%- css('style.css') %> -// <link rel="stylesheet" href="style.css" type="text/css"> +// <link rel="stylesheet" href="/style.css" type="text/css"> <%- css(['style.css', 'screen.css']) %> -// <link rel="stylesheet" href="style.css" type="text/css"> -// <link rel="stylesheet" href="screen.css" type="text/css"> +// <link rel="stylesheet" href="/style.css" type="text/css"> +// <link rel="stylesheet" href="/screen.css" type="text/css"> ``` ### js -Loads JavaScript file. `path` can be an array or a string. +Loads JavaScript files. `path` can be an array or a string. If `path` isn't prefixed with `/` or any protocol, it'll be prefixed with root URL. If you didn't add extension name `.js` after `path`, it'll be added. -``` -<%- js(path) %> +``` js +<%- js(path, [path1], [path2], [...]) %> ``` **Examples:** ``` js <%- js('script.js') %> -// <script type="text/javascript" src="script.js"></script> +// <script type="text/javascript" src="/script.js"></script> <%- js(['script.js', 'gallery.js']) %> -// <script type="text/javascript" src="script.js"></script> -// <script type="text/javascript" src="gallery.js"></script> +// <script type="text/javascript" src="/script.js"></script> +// <script type="text/javascript" src="/gallery.js"></script> ``` +### Conditional Tags + +Conditional tags help you check the status of current page. + +Helper | Description +--- | --- +`is_current(path)` | Checks if `path` matches the URL of current page +`is_home()` | Checks if the home page is being displayed +`is_post()` | Checks if posts are being displayed +`is_archive()` | Checks if archive pages are being displayed +`is_year()` | Checks if yearly archive pages are being displayed +`is_month()` | Checks if monthly archive pages are being displayed +`is_category()` | Checks if category pages are being displayed +`is_tag()` | Checks if tag pages are being displayed + ### gravatar -Loads Gravatar. +Inserts a Gravatar image. -``` -<%- gravatar(email, [size]) %> +``` js +<%- gravatar(email, [size]); ``` **Examples:** @@ -66,15 +79,15 @@ Loads Gravatar. Clears all spaces in a string. -``` +``` js <%- trim(string) %> ``` ### strip_html -Clears all HTML tags in a string. +Sanitizes all HTML tags in a string. -``` +``` js <%- strip_html(string) %> ``` @@ -87,9 +100,9 @@ Clears all HTML tags in a string. ### titlecase -Transforms a string into proper title capitalization. +Transforms a string into proper title caps. -``` +``` js <%- titlecase(string) %> ``` @@ -102,138 +115,107 @@ Transforms a string into proper title capitalization. ### partial -Loads other template. Use `locals` to define local variables. (Same as [express-partials][1]) +Loads other template files. You can define local variables in `local`. -``` +``` js <%- partial(layout, [locals]) %> ``` ### tagcloud -Inserts tag cloud. Input `tags` with [template data][3]. The following is `options`. +Inserts a tag cloud. +``` js +<%- tagcloud([tags], [options]) %> ``` -<%- tagcloud(tags, [options]) %> -``` - -**Options:** -- **min_font** - Minimal font size -- **max_font** - Maximum font size -- **unit** - Unit of font size -- **amount** - Amount of tags -- **orderby** - Order of tags -- **order** - Sort order. `1`, `asc` as ascending; `-1`, `desc` as descending. - -**Default:** - -``` json -{ - "min_font": 10, - "max_font": 20, - "unit": "px", - "amount": 40, - "orderby": "name", - "order": 1 -} -``` +Option | Description | Default +--- | --- | --- +`min_font` | Minimal font size | 10 +`max_font` | Maximum font size | 20 +`unit` | Unit of font size | px +`amount` | Total amount of tags | 40 +`orderby` | Order of tags | name +`order` | Sort order. `1`, `sac` as ascending; `-1`, `desc` as descending | 1 ### paginator -Inserts paginator. The following is `options`. +Inserts a paginator. -``` +``` js <%- paginator(options) %> ``` -**Options:** - -- **base** - Base URL -- **format** - URL format -- **total** - The total amount of pages -- **current** - Current page number -- **prev_text** - The previous page text -- **next_text** - The next page text -- **space** - The space text -- **prev_next** - Display previous and next links -- **end_size** - Number of pages displayed on the start and the end side -- **mid_size** - Number of pages displayed between current page, but not including current page -- **show_all** - Display all pages - -**Default:** - -``` json -{ - "base": "/", - "format": "page/%d/", - "total": 1, - "current": 0, - "prev_text": "Prev", - "next_text": "Next", - "space": "&hellp;", - "prev_next": true, - "end_size": 1, - "mid_size": 2, - "show_all": false -} -``` +Option | Description | Default +--- | --- | --- +`base` | Base URL | / +`format` | URL format | page/%d/ +`total` | Total amount of pages | 1 +`current` | Current page number | 0 +`prev_text` | The link text of previous page. Works only if `prev_next` is set to true. | Prev +`next_text` | The link text of next page. Works only if `prev_next` is set to true. | Next +`space` | The space text | &hellp; +`prev_next` | Display previous and next links | true +`end_size` | The number of pages displayed on the start and the end side | 1 +`mid_size` | The number of pages displayed between current page, but not including current page | 2 +`show_all` | Display all pages. If this is set true, `end_size` and `mid_size` will not works. | false ### date -Displays date. `date` is a date object. `format` is the output format ([Moment.js][5]), `date_format` in [global configuration][4] by default. +Inserts formatted date. `date` can be unix time, ISO string, date object, or moment.js object. `format` is `date_format` setting by default. -``` +``` js <%- date(date, [format]) %> ``` **Examples:** ``` js -<%- date(new Date()) %> +<%- date(Date.now()) %> // Jan 1, 2013 -<%- date(new Date(), 'YYYY/M/D') %> +<%- date(Date.now(), 'YYYY/M/D') %> // 2013/1/1 ``` ### date_xml -Displays date in XML format. `date` is a date object. +Inserts date in XML format. `date` can be unix time, ISO string, date object, or moment.js object. `format` is `date_format` setting by default. -``` +``` js <%- date_xml(date) %> ``` **Examples:** ``` js -<%- date_xml(new Date()) %> +<%- date_xml(Date.now()) %> // 2013-01-01T00:00:00.000Z ``` ### time -Displays time. `date` is a date object. `format` is the output format ([Moment.js][5]), `time_format` in [global configuration][4] by default. +Inserts formatted time. `date` can be unix time, ISO string, date object, or moment.js object. `format` is `time_format` setting by default. -``` -<%- time(date, [format]) %> +``` js +<%- date(date, [format]) %> ``` **Examples:** ``` js -<%- time(new Date()) %> +<%- time(Date.now()) %> // 13:05:12 -<%- time(new Date(), 'h:mm:ss a') %> +<%- time(Date.now(), 'h:mm:ss a') %> // 1:05:12 pm ``` ### full_date -Displays full date. `date` is a date object. `format` is the output format ([Moment.js][5]), `date_format` plus `time_format` in [global configuration][4] by default. +Inserts formatted date and time. `date` can be unix time, ISO string, date object, or moment.js object. `format` is `date_format + time_format` setting by default. -``` +``` js <%- full_date(date, [format]) %> ``` @@ -249,37 +231,27 @@ Displays full date. `date` is a date object. `format` is the output format ([Mo ### moment -[Moment.js](http://momentjs.com/) +[Moment.js] library. -### search_form +### searh_form -Returns a Google search form. The following is `options`. +Inserts a Google search form. -``` +``` js <%- search_form(options) %> ``` -**Options:** - -- **class** - Form class name -- **text** - Search hint word -- **button** - Whether to display search button. The value can be a boolean or a string. - -**Defaults:** - -``` json -{ - "class": "search-form", - "text": "Search", - "button": false -} -``` +Option | Description | Default +--- | --- | --- +`class` | The class name of form | search-form +`text` | Search hint word | Search +`button` | Display search button. The value can be a boolean or a string. When the value is a string, it'll be the text of the button. | false ### markdown -Renders string with Markdown. +Renders a string with Markdown. -``` +``` js <%- markdown(str) %> ``` @@ -292,24 +264,24 @@ Renders string with Markdown. ### word_wrap -Wraps the text into lines no longer than `length`. `length` is 80 by default。 +Wraps text into lines no longer than `length`. `length` is 80 by default. -``` +``` js <%- word_wrap(str, [length]) %> ``` **Examples:** -``` +``` js <%- word_wrap('Once upon a time', 8) %> // Once upon\n a time ``` ### truncate -Truncates a given `text` after a given `length`. +Truncates text after `length`. -``` +``` js <%- truncate(text, length) %> ``` @@ -322,9 +294,9 @@ Truncates a given `text` after a given `length`. ### truncate_words -Truncates words of a given `text` after a given `length`. +Truncates words after `length`. -``` +``` js <%- truncate_words(text, length) %> ``` @@ -335,75 +307,11 @@ Truncates words of a given `text` after a given `length`. // Once upon a time ``` -### is_current - -Checks if `path` is being displayed. - -``` -<%- is_current(path) %> -``` - -### is_home - -Check if the home page is being displayed - -``` -<%- is_home() %> -``` - -### is_post - -Check if the post is being displayed. - -``` -<%- is_post() %> -``` - -### is_archive - -Check if the archives is being displayed. - -``` -<%- is_archive() %> -``` - -### is_year - -Check if the yearly archives is being displayed. - -``` -<%- is_year() %> -``` - -### is_month - -Check if the monthly archives is being displayed. - -``` -<%- is_month() %> -``` - -### is_category - -Check if the category page is being displayed. - -``` -<%- is_category() %> -``` - -### is_tag - -Check if the tag page is being displayed. - -``` -<%- is_tag() %> -``` - ### link_to -Inserts a link. `path` is the link destination. `text` is the link text. `external` is whether the link is opened in a new window. +Inserts a link. -``` +``` js <%- link_to(path, [text], [external]) %> ``` @@ -422,9 +330,9 @@ Inserts a link. `path` is the link destination. `text` is the link text. `extern ### mail_to -Inserts a mail link. `path` is the link destination. `text` is the link text. +Inserts a mail link. -``` +``` js <%- mail_to(path, [text]) %> ``` @@ -440,100 +348,61 @@ Inserts a mail link. `path` is the link destination. `text` is the link text. ### list_categories -Inserts a list of categories. The following is `options`. +Inserts a list of all categories. -``` +``` js <%- list_categories([options]) %> ``` -**Options:** - -- **orderby** - Order of tags -- **order** - Sort of order. `1`, `asc` as ascending; `-1`, `desc` as descending. -- **show_count** - Whether to show the number of posts - -**Defaults:** - -``` json -{ - "orderby": "name", - "order": 1, - "show_count": true -} -``` +Option | Description | Default +--- | --- | --- +`orderby` | Order of categories | name +`order` | Sort of order. `1`, `sac` as ascending; `-1`, `desc` as descending | 1 +`show_count` | Display the total amount of posts for each category | true ### list_tags -Inserts a list of tags. The following is `options`. +Inserts a list of all categories. -``` +``` js <%- list_tags([options]) %> ``` -**Options:** - -- **orderby** - Order of tags -- **order** - Sort of order. `1`, `asc` as ascending; `-1`, `desc` as descending. -- **show_count** - Whether to show the number of posts - -**Defaults:** - -``` json -{ - "orderby": "name", - "order": 1, - "show_count": true -} -``` +Option | Description | Default +--- | --- | --- +`orderby` | Order of categories | name +`order` | Sort of order. `1`, `sac` as ascending; `-1`, `desc` as descending | 1 +`show_count` | Display the total amount of posts for each tag | true ### list_archives -Inserts a list of archives. The following is `options`. +Inserts a list of archives. +``` js +<%- list_archive([options]) %> ``` -<%- list_archives([options]) %> -``` - -**Options:** -- **type** - Type. `yearly` as yearly archives; `monthly` as monthly archives (default). -- **order** - Sort of order. `1`, `asc` as ascending; `-1`, `desc` as descending. -- **show_count** - Whether to show the number of posts -- **format** - Date format. `MMMM YYYY` by default. ([Moment.js][5]) - -**Defaults:** - -``` json -{ - "type": "monthly", - "order": 1, - "show_count": true, - "format": "MMMM YYYY" -} -``` +Option | Description | Default +--- | --- | --- +`type` | Type. This value can be `yearly` or `monthly`. | monthly +`order` | Sort of order. `1`, `sac` as ascending; `-1`, `desc` as descending | 1 +`show_count` | Display the total amount of posts for each tag | true +`format` | Date format | MMMM YYYY ### number_format -Formats a `number`. The following is `options`. +Formats a number. +``` js <%- number_format(number, options) %> - -**Options:** - -- **precision** - The precision of the number. The value can be `false` or nonnegative integer. -- **delimiter** - The thousands delimiter. -- **separator** - The sperator between the fractional and integer digits. - -**Defaults:** - -``` json -{ - "precision": false, - "delimiter": ",", - "separator": "." -} ``` +Option | Description | Default +--- | --- +`precision` | The precision of number. The value can be `false` or a nonnegative integer. | false +`delimiter` | The thousands delimiter | , +`separator` | The separator between the fractional and integer digits. | . + **Examples:** ``` js @@ -551,10 +420,4 @@ Formats a `number`. The following is `options`. <%- number_format(12345.67, {separator: '/'}) %> // 12,345/67 -``` - -[1]: https://github.com/publicclass/express-partials -[2]: render.html -[3]: template-data.html -[4]: configure.html -[5]: http://momentjs.com/docs/#/displaying/format/ \ No newline at end of file +``` \ No newline at end of file diff --git a/source/docs/i18n.md b/source/docs/i18n.md new file mode 100644 index 0000000000..348262aa19 --- /dev/null +++ b/source/docs/i18n.md @@ -0,0 +1,42 @@ +title: Internationalization (i18n) +prev: helpers +next: models +--- +Hexo has a simple i18n module built-in, which means you can make Hexo says your language! + +To enable i18n for Hexo, edit `language` setting. The language code must be written in [IETF format](http://www.w3.org/International/articles/language-tags/). For example: Traditional Chinese is `zh-TW`. + +``` yaml +language: zh-TW +``` + +## Structure + +``` plain +. +├── default.yml +└── zh-TW.yml +``` + +All language files must put into `languages` folder and be written in YAML format. All `languages` folder must have `default.yml` at least. + +{% note warn Write language files in YAML format %} +Don't use tabs in language files, use spaces instead. Also, add a space after colons. +{% endnote %} + +## i18n in Theme + +To use i18n in the theme. Use `__` (double underscores) with the key you set in language files. + +``` js +<%= __('key') %> +``` + +You can even pass more than one arguments: + +``` js +<%= __('Hello %s!', 'World') %> +// => Hello World! +``` + +`%s` in the first string will be replaced with the second string. The result will be `Hello World!`. \ No newline at end of file diff --git a/source/docs/index.md b/source/docs/index.md index 2f7e957eeb..c5dd197f03 100644 --- a/source/docs/index.md +++ b/source/docs/index.md @@ -1,53 +1,9 @@ +title: Docs +hide_title: true +next: installation --- -layout: page -title: Documentation -date: 2012-11-01 18:13:30 ---- - -## Getting Started - -#### [Install](install.html) - -#### [Setup](setup.html) - -#### [Configure](configure.html) - -#### [Deploy](deploy.html) - -#### [Migrate](migrate.html) - -## Usage - -#### [Writing](writing.html) - -#### [Tag Plugins](tag-plugins.html) - -#### [Server](server.html) - -#### [Scaffolds](scaffolds.html) - -#### [Permalink](permalink.html) - -#### [Scripts](scripts.html) - -#### [Command-line Interface (CLI)](cli.html) - -## Development - -#### [Global Variables](global-variables.html) - -#### [Template Data](template-data.html) - -#### [Helpers](helpers.html) - -#### [Collection](collection.html) - -#### [Events](events.html) - -#### [Render](render.html) - -#### [Theme Development](theme-development.html) +Welcome to the Hexo docs! This documentation can help you get started with Hexo. -#### [Plugin Development](plugin-development.html) +## What's Hexo? -#### [Contribute](contribute.html) \ No newline at end of file +Hexo is a fast and simple static site generator. \ No newline at end of file diff --git a/source/docs/install.md b/source/docs/install.md deleted file mode 100644 index 4b3c4215a9..0000000000 --- a/source/docs/install.md +++ /dev/null @@ -1,137 +0,0 @@ ---- -layout: page -title: Install -date: 2012-11-01 18:13:30 ---- - -Before installing Hexo, you should install [Git][2] & [Node.js][1] first. - -## Contents - -- [Windows](#windows) -- [Mac](#mac) -- [Linux](#linux) - -<a id="windows"></a> -## Windows - -### Git - -Download & execute [msysgit][7]. - -### Node.js - -It's very easy to install Node.js. Just [download][1] the installer and execute it. - -### Hexo - -Use [npm][3] to install. - -``` bash -npm install -g hexo -``` - -<a id="mac"></a> -## Mac - -### Git - -Mac has already built-in an older version Git. If you want to update it, you can try the following way. - -1. Use [Homebrew][5]. - - brew install git - -2. Use [MacPorts][6]. - - sudo port install git-core - -3. Use [Installer](http://code.google.com/p/git-osx-installer/). - -If an error occurred, maybe it's because you didn't install the compiler first, please go to App Store, download & install Xcode. - -### Node.js - -There are many way to install Node.js in Mac. We use [nvm][4] to install it. - -Execute the following command. - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -After the installation is done, add the following content in `~/.bash_profile` or `~/.bashrc` and open a new terminal window. - -``` -. ~/nvm/nvm.sh -``` - -Then you can install Node.js with [nvm][4]. It takes time to compile. Be patiently. - -``` bash -nvm install 0.8 -``` - -### Hexo - -Use [npm][3] to install. - -``` bash -npm install -g hexo -``` - -<a id="linux"></a> -## Linux - -### Git - -**Ubuntu, Debian:** - -``` bash -sudo apt-get install git-core -``` - -**Fedora, Red Hat, CentOS:** - -``` bash -sudo yum install git-core -``` - -### Node.js - -There are many way to install Node.js in Linux. We use [nvm][4] to install it. - -Execute the following command. - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -After the installation is done, add the following content in `~/.bash_profile` or `~/.bashrc` and open a new terminal window. - -``` plain -. ~/nvm/nvm.sh -``` - -Then you can install Node.js with [nvm][4]. It takes time to compile. Be patiently. - -``` bash -nvm install 0.8 -``` - -### Hexo - -Use [npm][3] to install. - -``` bash -npm install -g hexo -``` - -[1]: http://nodejs.org/ -[2]: http://git-scm.com/ -[3]: http://npmjs.org/ -[4]: https://github.com/creationix/nvm -[5]: http://mxcl.github.com/homebrew/ -[6]: http://www.macports.org/ -[7]: http://code.google.com/p/msysgit/ -[8]: http://code.google.com/p/git-osx-installer/ \ No newline at end of file diff --git a/source/docs/installation.md b/source/docs/installation.md new file mode 100644 index 0000000000..c5d604ce98 --- /dev/null +++ b/source/docs/installation.md @@ -0,0 +1,63 @@ +title: Installation +prev: index +next: setup +--- +It only takes few minutes for you to get Hexo ready. If you encounter any problems on installation and you can't find the solution here. Please [submit an issue](https://github.com/tommy351/hexo/issues) and I'll try to solve your problems. + +## Requirements + +Installing Hexo is quite easy. However, there're something required before you get started. + +- [Node.js](http://nodejs.org/) +- [Git](http://git-scm.com/) + +If your computer has been installed the requirements above already. Congratulations! Just install Hexo with npm. + +``` bash +$ npm install -g hexo +``` + +If not, please follow the following instructions to install all the requirements. + +{% note warn For Mac users %} +You may encounter some problems when compiling. Please install Xcode from App Store first. After Xcode is installed, open Xcode and go to **Preferences -> Download -> Command Line Tools -> Install** to install command line tools. +{% endnote %} + +## 1. Install Git + +- Windows: Download & install [msysgit](http://code.google.com/p/msysgit/). +- Mac: Install it with [Homebrew](http://mxcl.github.com/homebrew/), [MacPorts](http://www.macports.org/) or [installer](http://code.google.com/p/git-osx-installer/). +- Linux (Ubuntu, Debian): `sudo apt-get install git-core` +- Linux (Fedora, Red Hat, CentOS): `sudo yum install git-core` + +## 2. Install Node.js + +The best way to install Node.js is installing with [nvm](https://github.com/creationix/nvm). + +cURL: + +``` bash +$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh +``` + +Wget: + +``` bash +$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh +``` + +Once installed, restart the terminal and run the following command to install Node.js. + +``` bash +$ nvm install 0.10 +``` + +Or you can download the [installer](http://nodejs.org/) and install it. + +## 3. Install Hexo + +Once all the requirements are installed, you can install Hexo with npm. + +``` bash +$ npm install -g hexo +``` \ No newline at end of file diff --git a/source/docs/migrate.md b/source/docs/migrate.md deleted file mode 100644 index 98ff68bba9..0000000000 --- a/source/docs/migrate.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -layout: page -title: Migrate -date: 2012-11-15 18:13:30 ---- - -## Contents - -- [RSS](#rss) -- [Jekyll / Octopress](#jekyll) -- [WordPress](#wordpress) - -<a id="rss"></a> -## RSS - -First, execute the following command to install RSS migrator plugin, and add `hexo-migrator-rss` in `plugins` field in `_config.yml`. - -``` plain -npm install hexo-migrator-rss -``` - -After installed, execute the following command to migrate. `source` argument can be file path or URL. - - hexo migrate rss <source> - -<a id="jekyll"></a> -## Jekyll / Octopress - -Move files in `source/_posts` to `source/_posts` of Hexo, and modify `categories` field of articles to `tags`. - -Then edit `new_post_name` in `_config.yml` with `:year-:month-:day-:title.md`. - -<a id="wordpress"></a> -## WordPress - -First, execute the following command to install WordPress migrator plugin, and add `hexo-migrator-wordpress` in `plugins` field in `_config.yml`. - -``` plain -npm install hexo-migrator-wordpress -``` - -After installed, execute the following command to migrate. `source` argument can be file path or URL. - - hexo migrate wordpress <source> \ No newline at end of file diff --git a/source/docs/migration.md b/source/docs/migration.md new file mode 100644 index 0000000000..349d6ae185 --- /dev/null +++ b/source/docs/migration.md @@ -0,0 +1,47 @@ +title: Migration +prev: commands +next: writing +--- +## RSS + +First, install `hexo-migrator-rss` plugin. + +``` bash +$ npm install hexo-migrator-rss --save +``` + +Once the plugin is installed, run the following command to migrate all posts from RSS. `source` can be the file path or URL. + +``` bash +$ hexo migrate rss <source> +``` + +## Jekyll + +Move all files in `_posts` folder to `source/_posts` folder and modify `new_post_name` setting in `_config.yml`. + +``` yaml +new_post_name: :year-:month-:day-:title.md +``` + +## Octopress + +Move all files in `source/_posts` folder of Octopress to `source/_posts` of Hexo and modify `new_post_name` setting in `_config.yml`. + +``` yaml +new_post_name: :year-:month-:day-:title.md +``` + +## WordPress + +First, install `hexo-migrator-wordpress` plugin. + +``` bash +$ npm install hexo-migrator-wordpress --save +``` + +Once the plugin is installed, run the following command to migrate all posts from RSS. `source` can be the file path or URL. + +``` bash +$ hexo migrate wordpress <source> +``` \ No newline at end of file diff --git a/source/docs/models.md b/source/docs/models.md new file mode 100644 index 0000000000..88e0d2e37d --- /dev/null +++ b/source/docs/models.md @@ -0,0 +1,70 @@ +title: Models +prev: i18n +next: events +--- +Hexo store everything in data model. It's very important for you to know what's inside the data model. + +### Post + +Name | Description +--- | --- +`id` | Post ID (Set by user) +`title` | Post title +`date` | Post date ([Moment.js] object) +`updated` | Post last updated date ([Moment.js] object) +`categories` | All categories of the post +`tags` | All tags of the post +`comments` | Comment enabled or not +`layout` | Layout name +`content` | The full processed content of the post +`excerpt` | The processed excerpt of the post +`source` | The path of the source file +`full_path` | Full path of the source file +`path` | The URL of the post without root URL +`permalink` | Full URL of the post +`crime` | File created time ([Moment.js] object) +`mtime` | File modified time ([Moment.js] object) +`original_content` | The raw data of the post + +### Page + +Name | Description +--- | --- +`title` | Page title +`date` | Page date ([Moment.js] object) +`updated` | Page last updated date ([Moment.js] object) +`comments` | Comment enabled or not +`layout` | Layout name +`content` | The full processed content of the page +`excerpt` | The processed excerpt of the page +`source` | The path of the source file +`full_path` | Full path of the source file +`path` | The URL of the page without root URL +`permalink` | Full URL of the page +`crime` | File created time ([Moment.js] object) +`mtime` | File modified time ([Moment.js] object) +`original_content` | The raw data of the page + +### Category + +Name | Description +--- | --- +`name` | Category name +`slug` | Category slug +`posts` | All posts in the category +`path` | The URL of the category without root URL +`permalink` | Full URL of the category +`length` | Total number of posts in the category + +### Tag + +Name | Description +--- | --- +`name` | Tag name +`slug` | Tag slug +`posts` | All posts in the tag +`path` | The URL of the tag without root URL +`permalink` | Full URL of the tag +`length` | Total number of posts in the tag + +[Moment.js]: http://momentjs.com/ \ No newline at end of file diff --git a/source/docs/pagination.md b/source/docs/pagination.md new file mode 100644 index 0000000000..53908bb650 --- /dev/null +++ b/source/docs/pagination.md @@ -0,0 +1,44 @@ +title: Pagination +prev: variables +next: helpers +--- +When there're many posts in your blog, it's useful to separate into several pages. Hexo supports pagination. The following is how you can use pagination in Hexo. + +Before we start, you have to enable pagination. Edit `per_page` setting to change how many posts displayed in a single page. To disable pagination, just set it to `0`. + +``` yaml +per_page: 10 +``` + +You can edit the following setting to enable or disable pagination for specific pages. + +- 2: Enable pagination +- 1: Disable pagination +- 0: Fully disable + +``` yaml +archive: 2 +category: 2 +tag: 2 +``` + +## Basic + +The most basic pagination is just two links: "Previous page" & "Next page". For example: + +``` +<% if (page.prev){ %> + <a href="<%- config.root %><%- page.prev_link %>">Prev</a> +<% } %> +<% if (page.next){ %> + <a href="<%- config.root %><%- page.next_link %>">Next</a> +<% } %> +``` + +## Paginator helper + +To display pagination in number. You can use paginator helper. It helps you insert pagination fast. + +``` +<%- paginator() %> +``` \ No newline at end of file diff --git a/source/docs/permalink.md b/source/docs/permalink.md deleted file mode 100644 index b79f7e1b7a..0000000000 --- a/source/docs/permalink.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -layout: page -title: Permalink -date: 2012-11-01 18:13:30 ---- - -## Configure - -Edit `permalink` in `_config.yml`. Here is the default: - -``` plain -permalink: :year/:month/:day/:title/ -``` - -You can add the following variables in the permalink. Only the variables started with `:` is valid. - -- **year** - 4-digit year -- **month** - 2-digit month -- **day** - 2-digit date -- **title** - The filename of the post -- **category** - The category of the post. (Relative path to `source/_posts`) If the post is uncategorized, it will be `category_dir` in `_config.yml`. - -*(The date is based on the date set in the post)* - -## Example - -Given a post named `title.md` in `source/_posts/foo/bar` directory with the following content: - -``` plain ---- -title: Post Title -date: 2012-10-09 14:09:37 -tags: -- Node.js -- JavaScript ---- -``` - -And here is the result: - -``` plain -:year/:month/:day/:title/ => /2012/10/09/title/ -:year-:month-:day/:title/ => /2012-10-09/title/ -:category/:title/ => /foo/bar/title/ -``` \ No newline at end of file diff --git a/source/docs/permalinks.md b/source/docs/permalinks.md new file mode 100644 index 0000000000..601b827277 --- /dev/null +++ b/source/docs/permalinks.md @@ -0,0 +1,34 @@ +title: Permalinks +prev: deployment +next: themes +--- +You can specify the permalinks for your site in `_config.yml` or in the front-matter for each post. + +### Variables + +Variable | Description +--- | --- +`:year` | Published year of posts (4-digit) +`:month` | Published month of posts (2-digit) +`:day` | Published day of posts (2-digit) +`:title` | Filename +`:id` | Post ID +`:category` | Relative path to `source/_posts`. If the post is uncategorized, it'll be `category_dir` setting. + +### Examples + +Given a post named `hello-world.md` in `source/_posts/foo` folder with the following content. + +``` yaml +title: Hello World +date: 2013-07-14 17:01:34 +categories: +- bar +- baz +``` + +Setting | Result +--- | --- +`:year/:month/:day/:title/` | 2013/07/14/hello-world +`:year-:month-:day-:title.html` | 2013-07-14-hello-world.html +`:category/:title` | foo/bar/baz/hello-world \ No newline at end of file diff --git a/source/docs/plugin-development.md b/source/docs/plugin-development.md deleted file mode 100644 index ef526f1fdb..0000000000 --- a/source/docs/plugin-development.md +++ /dev/null @@ -1,269 +0,0 @@ ---- -layout: page -title: Plugin Development -date: 2012-11-01 18:13:30 ---- - -There're 8 sorts of plugins: - -- [Generator](#generator) - Generates static files -- [Renderer](#renderer) - Renders files -- [Helper](#helper) - Template helpers -- [Deployer](#deployer) - Deploy -- [Processor](#processor) - Process source files -- [Tag](#tag) - Article tag -- [Console](#console) - Command-line Interface (CLI) -- [Migrator](#migrator) - Migrate tool - -<a name="generator"></a> -## Generator - -### Syntax - -``` js -hexo.extend.generator.register(fn); -``` - -- **fn(locals, render, callback)** - - **locals** - [Global site data][1] - - **render(layout, locals, callback)** - Render function - - **path** - Path - - **layout** - The template to use - - **locals** - Data passed to the template, the `page` variable in the template - - **callback** - Callback function - -### Example - -Generates archives at `public/archive.html`. - -``` js -hexo.extend.generator.register(function(locals, render, callback){ - render('archive.html', ['archive', 'index'], locals); - callback(); -}); -``` - -<a name="renderer"></a> -## Renderer - -### Syntax - -``` js -hexo.extend.renderer.register(name, output, fn, [sync]); -``` - -- **name** - Extension of input file (lowercase, `.` excluded) -- **output** - Extension of output file (lowercase, `.` excluded) -- **fn** - As below -- **sync** - Sync mode (`false` by default) - -`fn(data[, options], callback)` - -- **data** - Input data containing the following - - **path** - Source file path - - **text** - File content -- **options** - Options -- **callback** - Callback function (Only in async mode) - -### Example - -#### Sync mode - -``` js -var ejs = require('ejs'); - -hexo.extend.renderer.register('ejs', 'html', function(data, options){ - options.filename = data.path; - return ejs.render(data.text, options); -}, true); -``` - -#### Async mode - -``` js -var stylus = require('stylus'); - -hexo.extend.renderer.register('styl', 'css', function(data, callback){ - stylus(data.text).set('filename', data.path).render(callback); -}); -``` - -<a name="helper"></a> -## Helper - -### Syntax - -``` js -hexo.extend.helper.register(); -``` - -### Example - -Inserts a JavaScript file. - -``` js -hexo.extend.helper.register('js', function(path){ - return '<script type="text/javascript" src="' + path + '"></script>'; -}); -``` - -Input: - -``` -<%- js('script.js') %> -``` - -Output: - -``` html -<script type="text/javascript" src="script.js"></script> -``` - -<a name="deployer"></a> -## Deployer - -### Syntax - -``` js -hexo.extend.deployer.register(name, method); -``` - -- **name** - Name (lowercase) -- **method(args)** - - **args** - Arguments - -### Example - -``` js -hexo.extend.deployer.register('github', { - // ... -}); -``` - -<a name="processor"></a> -## Processor - -### Syntax - -``` js -hexo.extend.processor.register(fn); -``` - -- **fn(locals, callback)** - - **locals** - [Global site data][1] - - **callback(err, locals)** - - **err** - Error content. Return `null` when no error occurred. - - **locals** - Processed data - -### Example - -Sort articles by date descending. - -``` js -hexo.extend.processor.register(function(locals, callback){ - locals.posts = locals.posts.sort('date', -1); - locals.pages = locals.pages.sort('date', -1); - callback(null, locals); -}); -``` - -<a name="tag"></a> -## Tag - -### Syntax - -``` js -hexo.extend.tag.register(name, fn, [ends]); -``` - -- **name** - Name (lowercase) -- **fn(args, content)** - - **args** - Arguments - - **content** - Content -- **ends** - End tag - -### Example - -Inserts a Youtube video. - -``` js -hexo.extend.tag.register('youtube', function(args, content){ - var id = args[0]; - return '<div class="video-container"><iframe width="560" height="315" src="http://www.youtube.com/embed/' + id + '" frameborder="0" allowfullscreen></iframe></div>'; -}); -``` - -Inserts a pull quote. - -``` js -hexo.extend.tag.register('pullquote', function(args, content){ - var className = args.length ? ' ' + args.join(' ') : ''; - return '<blockquote class="pullquote' + className + '">' + content + '</blockquote>'; -}, true); -``` - -<a name="console"></a> -## Console - -### Syntax - -``` js -hexo.extend.console.register(name, desc, [options], fn); -``` - -- **name** - Name (lowercase) -- **desc** - Description -- **options** - Options (As below) -- **fn(args)** - - **args** - Arguments - -### Options - -- **init** - Display when uninitialized -- **debug** - Display in debug mode - -### Example - -Display configuration when the following executed. - -``` -hexo config -``` - -``` js -hexo.extend.console.register('config', 'Display configuration', function(args){ - console.log(hexo.config); -}); -``` - -<a name="migrator"></a> -## Migrator - -### Syntax - -``` js -hexo.extend.migrator.register(name, fn); -``` - -- **name** - Name (lowercase) -- **fn(args)** - - **args** - Arguments - - -## Publish - -Don't forget to test before publishing. Copy your plugin into `node_modules` folder and install dependencies. Try to use or do unit tests. - -After all the tests done. Execute the following command to publish your plugins to NPM. - -``` -npm publish -``` - -## Reference - -You can reference [built-in modules][2] and [official plugins][3] to develop your plugin. - -[1]: template-data.html#site -[2]: https://github.com/tommy351/hexo/tree/master/lib -[3]: https://github.com/tommy351/hexo-plugins \ No newline at end of file diff --git a/source/docs/plugins.md b/source/docs/plugins.md new file mode 100644 index 0000000000..a956fd486f --- /dev/null +++ b/source/docs/plugins.md @@ -0,0 +1,390 @@ +title: Plugins +prev: scripts +next: troubleshooting +--- +Hexo has powerful plugin system. Most of built-in plugins are extensions of Hexo. This makes you easy to hook up your custom code easily. + +There're 2 ways to extend Hexo: **Script** and **Plugin**. If your code is simple and doesn't have any dependencies, you can choose **Script**. If your code is complicated and have dependencies, or you want to publish it on NPM registry, you should use **Plugin**. + +### Script + +To use script, put your JavaScript file in `scripts` folder and it'll be loaded once Hexo is initialized. + +### Plugin + +To use plugin, create a new folder. The folder name must `hexo-` prefixed so it could be loaded by Hexo. The folder must contained 2 files at least. One is your code and the other is `package.json`. + +``` plain +. +├── index.js +└── package.json +``` + +You should at least describe `name`, `version`, `main` and `dependencies` in `package.json`. For example: + +``` json +{ + "name": "hexo-my-plugin", + "version": "0.0.1", + "main": "index", + "dependencies": { + } +} +``` + +Hexo has 10 categories of plugins: + +1. Generator +2. Renderer +3. Helper +4. Deployer +5. Processor +6. Tag +7. Console +8. Migrator +9. Filter +10. Swig + +## Generator + +Generator generates content based on processed source files. + +### Syntax + +``` js +extend.generator.register(function(locals, render, callback){ + // ... +}); +``` + +Argument | Description +--- | --- +`locals` | [Site variables](variables.html) +`render` | Render function +`callback` | Callback function + +### Render + +To render your content with theme, you have to use render function. + +``` js +render(path, layout, locals) +``` + +Argument | Description +--- | --- +`path` | URL without root URL +`layout` | Theme layout to use. This value can be an array or a string. When it's an array, Hexo'll use the first matched layout. +`locals` | Page variables + +If you don't need to render your content with theme. You can bind the content on the routes directly. For example: + +``` js +route.set('feed.xml', content); +``` + +### Example + +``` js +hexo.extend.generator.register(function(locals, render, callback){ + render('archive.html', ['archive', 'index'], locals); + callback(); +}); +``` + +## Renderer + +If you want to use a new markup language in Hexo, you can implement it with renderer plugin. + +### Syntax + +``` js +hexo.extend.renderer.register(name, output, fn, [sync]); +``` + +Paramter | Description +--- | --- +`name` | Input file extension (lowercase, not included `.`) +`output` | Output file extension (lowercase, not included `.`) +`fn` | Render function +`sync` | Sync mode (`false` by default) + +`fn` is invoked with 3 arguments: + +Argument | Description +--- | --- +`data` | `data` contains 2 properties: `path` (File path) and `text` (File content). `path` doesn't always exist in sync mode. +`options` | Options or local variables. +`callback` | Callback function. Only used in async mode. + +### Example + +**Sync mode:** + +``` js +var ejs = require('ejs'); + +hexo.extend.renderer.register('ejs', 'html', function(data, options){ + options.filename = data.path; + return ejs.render(data.text, options); +}, true); +``` + +**Async mode:** + +``` js +var stylus = require('stylus'); + +hexo.extend.renderer.register('styl', 'css', function(data, callback){ + stylus(data.text).set('filename', data.path).render(callback); +}); +``` + +## Helper + +Helper is used in theme to help you insert specified content quickly. If you write something in your theme many times. You should consider to put it in the helper. (Don't repeat yourself, right?) + +### Syntax + +``` js +hexo.extend.helper.register(name, fn); +``` + +Paramter | Description +--- | --- +`name` | Helper name +`fn` | Helper function + +### Example + +``` js +hexo.extend.helper.register('js', function(path){ + return '<script type="text/javascript" src="' + path + '"></script>'; +}); +``` + +Input: + +``` js +<%- js('script.js') %> +``` + +Output: + +``` +<script type="text/javascript" src="script.js"></script> +``` + +## Deployer + +Deployer plugin helps you deploy your site on web without complicated commands. + +### Syntax + +``` js +hexo.extend.deployer.register(name, fn); +``` + +Parameter | Description +--- | --- +`name` | Deployer name +`fn` | Deployer function + +## Processor + +Processor processes raw data and stores them in database. If you want to process some specified files in `source` folder. You can implement it with the processor plugin. + +{% note info Hidden files won't be processed %} +Hexo won't process hidden files. +{% endnote %} + +### Syntax + +``` js +hexo.extend.processor.register([rule], fn); +``` + +Paramter | Description +--- | --- +`rule` | File path matching rule. This value can be a regular expression or a string. +`fn` | Processor function + +`fn` is invoked with 2 arguments: + +Argument | Description +--- | --- +`file` | File data (see below) +`callback` | Callback function + +### File data + +Property | Description +--- | --- +`source` | File source +`path` | File relative path +`type` | File event. The value can be `create`, `update` or `delete`. +`read` | Function to read file content +`stat` | Function to read file status + +**Read file content:** + +``` js +file.read(options, callback); +``` + +Option | Description | Default +--- | --- | --- +`cache` | Enables cache | false +`encoding` | File encoding | utf8 + +`callback` is invoked with 2 arguments: error and file content. + +**Read file status:** + +``` js +file.stat(callback); +``` + +`callback` is invoked with 2 arguments: error and file status ([fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats)). + +## Tag + +Tag helps you insert specified content in your post quickly. + +### Syntax + +``` js +hexo.extend.tag.register(name, fn, [ends]); +``` + +Parameter | Description +--- | --- +`name` | Tag name +`fn` | Tag function +`ends` | Enables end tag (disabled by default) + +`fn` is invoked with 2 arguments: + +Argument | Description +--- | --- +`args` | Arguments +`content` | Content (Only available when the tag has end tag) + +### Example + +**Without end tag:** Inserts a Youtube video. + +``` js +hexo.extend.tag.register('youtube', function(args, content){ + var id = args[0]; + return '<div class="video-container"><iframe width="560" height="315" src="http://www.youtube.com/embed/' + id + '" frameborder="0" allowfullscreen></iframe></div>'; +}); +``` + +**With end tag:** Inserts a pull quote. + +``` js +hexo.extend.tag.register('pullquote', function(args, content){ + var className = args.length ? ' ' + args.join(' ') : ''; + return '<blockquote class="pullquote' + className + '">' + content + '</blockquote>'; +}, true); +``` + +## Console + +Console is the interface between Hexo and you. + +### Syntax + +``` js +hexo.extend.console.register(name, desc, [options], fn); +``` + +Parameter | Description +--- | --- +`name` | Console name (lowercase) +`desc` | Console description +`options` | Options +`fn` | Console function. Invoked with a [Optimist] argument. + +### Options + +Option | Description +--- | --- +`init` | Display in a non-Hexo folder +`debug` | Display in debug mode +`alias` | Console alias + +### Example + +``` bash +$ hexo config +``` + +``` js +hexo.extend.console.register('config', 'Display configuration', function(args){ + console.log(hexo.config); +}); +``` + +## Migrator + +Migrator helps you migrate from other blog system to Hexo. + +### Syntax + +``` js +hexo.extend.migrator.register(name, fn); +``` + +Parameter | Description +--- | --- +`name` | Migrator name +`fn` | Migrator function. Invoked with a [Optimist] argument. + +## Filter + +There're 2 type of filters: **pre-filter** process uncompiled data, while **post-filter** process compiled data. + +![](http://i.minus.com/ibws9s60LP8sDG.PNG) + +### Syntax + +``` js +hexo.extend.filter.register([type], fn); +``` + +Parameter | Description +--- | --- +`type` | Filter type. The value can be `pre` or `post` (Default). +`fn` | Filter function. Invoked with a argument: post data. + +### Example + +Replaces `#username` in post content to a Twitter link. + +``` js +hexo.extend.filter.register('post', function(data){ + data.content = data.content.replace(/#(\d+)/, '<a href="http://twitter.com/$1">#$1</a>'); + + return data; +}); +``` + +## Swig + +You can extend Swig tags with Swig plugin. The API is same as Swig. You can find more detail [here](http://paularmstrong.github.io/swig/docs/#tags). + +### Syntax + +``` js +hexo.extend.swig.register(name, fn, [end]); +``` + +Paramter | Description +--- | --- +`name` | Plugin name +`fn` | Plugin function +`end` | Enables end tag (disabled by default) + +[Optimist]: https://github.com/substack/node-optimist \ No newline at end of file diff --git a/source/docs/render.md b/source/docs/render.md deleted file mode 100644 index a227bc8d3f..0000000000 --- a/source/docs/render.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -layout: page -title: Render -date: 2012-11-01 18:13:30 ---- - -## Usage - -#### render(data, [options], callback) - -- **data** - Input data - - **path** - Path - - **text** - Text - - **engine** - Render engine (Extension of `path` by default. Required if `path` undefined) -- **options** - Options -- **callback** - Callback function - -#### renderSync(data, [options]) - -Synchronous `render`. - -#### renderFile(path, [options], callback) - -- **path** - Path -- **options** - Options - - **cache** - Cache - - **layout** - Layout -- **callback** - Callback function - -### Example - -``` -hexo.render.render({path: layout.ejs}, function(err, content){ - // ... -}); -``` - -## Built-in Renderer - -### EJS - -- Input: ejs -- Output: html - -Reference: - -- [EJS][1] - -### Markdown - -- Input: md, markdown, mkd, mkdn, mdwn, mdtxt, mdtext -- Output: html - -Reference: - -- [Marked][2] -- [Markdown][3] - -### Stylus (with Nib) - -- Input: styl, stylus -- Output: css - -Reference: - -- [Stylus][4] -- [Nib][5] - -### Swig - -- Input: swig -- Output: html - -Reference: - -- [Swig][6] - -### YAML - -- Input: yml, yaml -- Output: json - -Reference: - -- [yamljs][7] -- [YAML][8] - -[1]: https://github.com/visionmedia/ejs -[2]: https://github.com/chjj/marked -[3]: http://daringfireball.net/projects/markdown/ -[4]: http://learnboost.github.com/stylus/ -[5]: http://visionmedia.github.com/nib/ -[6]: http://paularmstrong.github.com/swig/ -[7]: https://github.com/jeremyfa/yaml.js -[8]: http://www.yaml.org/ \ No newline at end of file diff --git a/source/docs/scripts.md b/source/docs/scripts.md deleted file mode 100644 index 999e21aa38..0000000000 --- a/source/docs/scripts.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -layout: page -title: Scripts -date: 2012-11-01 18:13:30 ---- - -A script is a extension which is smaller than a plugin and only has one file. - -## Usage - -Put a JavaScript file in `scripts` folder and it will be loaded automatically. File or folder whose name started with `.` (dot) or `_` (underscore) will be ignored. - -## Example - -Open file after the post created. - -``` -var spawn = require('child_process').spawn; - -hexo.on('new', function(){ - spawn('open', [target]); -}); -``` - -## Reference - -- [Global variables][1] -- [Events][2] - -[1]: global_variables.html -[2]: events.html \ No newline at end of file diff --git a/source/docs/server.md b/source/docs/server.md index 436311c5aa..d6f1c01472 100644 --- a/source/docs/server.md +++ b/source/docs/server.md @@ -1,66 +1,94 @@ ---- -layout: page title: Server -date: 2012-11-01 18:13:30 +prev: tag-plugins +next: deployment --- +## Express -## Built-in Server +To start server, run the following command: -Hexo uses [Connect][1] to serve static files. +``` bash +$ hexo server +``` -Edit `port` setting in `_config.yml` to configure the port of the server. +Your website will running at `http://localhost:4000`. You can edit the server port in `_config.yml` or use flags to override the default port. For example: -``` yaml -port: 4000 +``` bash +$ hexo server -p 5000 ``` -Execute the following command to start the server. Press `Ctrl+c` to stop it. +Server will watch for file changes and update automatically. However, server won't update files in `public` folder. You should run `hexo generate` instead. + +{% note info Restart Hexo after configuration changed %} +Hexo doesn't watch for configuration file changes. You have to restart Hexo to make the new configurations take effects. +{% endnote %} -**Options**: +### Static Mode -- **-p/--port**: Port -- **-s/--static**: Only serve static files +In static mode, only files in `public` folder will be served and file watching is disabled. You have to run `hexo generate` before starting the server. Usually used in production. ``` bash -hexo server -hexo server -p 12345 +$ hexo server -s ``` ### Logger -Edit `logger` in `_config.yml` to enable logger. Edit `logger_format` to adjust the content displayed. Check [Connect][4] for more info. +To log requests of server, you can enable logger in `_config.yml`. Logger is always enabled in debug mode. ``` yaml logger: true -logger_format: +logger_format: default ``` +Or use flags to override default settings. For example: + +``` bash +$ hexo server -l default +``` + +**Pre-defined formats:** + +Format | Description +--- | --- +`default` | :remote-addr - - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" +`short` | :remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms +`tiny` | :method :url :status :res[content-length] - :response-time ms +`dev` | concise output colored by response status for development use + +**Tokens:** + +Token | Description +--- | --- +`:req[header]` | Request header (e.g. `:req[Accept]`) +`:res[header]` | Response header (e.g. `:res[Content-Length]`) +`:http-version` | HTTP version +`:response-time` | Response time +`:remote-addr` | Remote IP address +`:date` | Request date +`:method` | Method +`:url` | Request URL +`:referrer` | Referrer +`:user-agent` | User agent +`:status` | Status + ## Pow -[Pow][2] is a zero-config Rack server for Mac powered by Node.js and it can serve static files, too. +[Pow](http://pow.cx/) is a zero-config Rack server for Mac powered by Node.js. -### Install +### Insall -Execute the following command. +Run the following command: ``` bash -curl get.pow.cx | sh +$ curl get.pow.cx | sh ``` -### Usage +### Setup -Create a symlink in `~/.pow` folder to use. +Symlink the folder into `~/.pow` ``` bash -cd ~/.pow -ln -s /path/to/myapp +$ cd ~/.pow +$ ln -s /path/to/myapp ``` -Your website will be up and running at `http://myapp.dev`. The URL is based on the name of the symlink. - -Check [Pow][3] for more info. - -[1]: https://github.com/senchalabs/connect -[2]: http://pow.cx/ -[3]: http://pow.cx/manual.html -[4]: http://www.senchalabs.org/connect/logger.html \ No newline at end of file +Your website will be up and running at `http://myapp.dev`. The URL is based on the name of symlink. \ No newline at end of file diff --git a/source/docs/setup.md b/source/docs/setup.md index 07658f99e0..65c3f96da3 100644 --- a/source/docs/setup.md +++ b/source/docs/setup.md @@ -1,73 +1,56 @@ ---- -layout: page title: Setup -date: 2012-11-01 18:13:30 +prev: installation +next: configuration --- - -After installed, execute the following command in the folder you want. Hexo will build all files you need in the target folder. +Once Hexo is installed, run the following command and hexo will build all files you need in the target folder. ``` bash -hexo init <folder> +$ hexo init <folder> ``` -After built, here's how the folder looks like: +After build, here's how the folder looks like: ``` plain -|-- .gitignore -|-- _config.yml -|-- package.json -|-- public -|-- scaffolds -|-- scripts -|-- source -| |-- _posts - |-- hello-world.md -| |-- _drafts -|-- themes - |-- light +. +├── _config.yml +├── package.json +├── scaffolds +├── scripts +├── source +| ├── _drafts +| └── _posts +└── themes ``` ### _config.yml -Global configuration file. +Site [configuration](configuration.html) file. You can configure most of options here. ### package.json -Application data. **Don't delete it.** If you deleted it unfortunately, rebuild the file with the following content. +Application data. If you deleted it unfortunately, rebuild the file with the following content. ``` json { "name": "hexo", "version": "0.0.1", "private": true, - "engines": { - "node": ">0.6.0", - "npm": ">1.1.0" - }, "dependencies": {} } ``` -### public - -Static file folder. - ### scaffolds -[Scaffold][2] folder. +[Scaffold](scaffolds.html) folder. When you create a new post, Hexo will build the file based on the scaffold. ### scripts -[Script][3] folder. +[Script](scripts.html) folder. Script is the easiest way to extend Hexo. JavaScript files in this folder will be executed automatically. ### source -Files in this folder will be processed and saved in `public` folder. File or folder whose name started with `.` (dot) or `_` (underscore) will be ignored except `_posts` folder. +Source folder is where you can put your content in. File or folder whose name is prefixed with `_` (underscore) and hidden files will be ignore except `_posts` folder. Markdown, HTML files will be processed and put into `public` folder, while other files will be copied. ### themes -Theme folder. The default theme of Hexo is [Light][1]。 - -[1]: https://github.com/tommy351/hexo-theme-light -[2]: writing.html -[3]: scripts.html \ No newline at end of file +[Theme](themes.html) folder. Hexo will generate files based on the theme. diff --git a/source/docs/tag-plugins.md b/source/docs/tag-plugins.md index 651fd2ac6f..a010e65db6 100644 --- a/source/docs/tag-plugins.md +++ b/source/docs/tag-plugins.md @@ -1,129 +1,218 @@ ---- -layout: page title: Tag Plugins -date: 2012-11-01 18:13:30 +prev: generating +next: server --- - -Tag plugins are different from tags in posts. Tag plugins are used for inserting specific contents in posts. +Tag plugins are different from tags in posts. They're ported from Octopress and can help you insert specific contents in posts quickly. ## Block Quote -Insert a block quote. +This plugin helps you insert quotes with author, source and title in posts. + +**Alias:** quote {% raw %} -<pre><code>{% blockquote [author[, source]] [link] [source_link_title] %} +<figure class="highlight"><pre>{% blockquote [author[, source]] [link] [source_link_title] %} content {% endblockquote %} -</code></pre> +</pre></figure> +{% endraw %} + +### Example + +**No arguments given. Only output plain blockquote** + +{% raw %} +<figure class="highlight"><pre>{% blockquote %} +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem. +{% endblockquote %} +</pre></figure> +{% endraw %} + +{% blockquote %} +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem. +{% endblockquote %} + +**Quote from a book** + +{% raw %} +<figure class="highlight"><pre>{% blockquote David Levithan, Wide Awake %} +Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy. +{% endblockquote %} +</pre></figure> +{% endraw %} + +{% blockquote David Levithan, Wide Awake %} +Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy. +{% endblockquote %} + +**Quote from Twitter** + +{% raw %} +<figure class="highlight"><pre>{% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %} +NEW: DevDocs now comes with syntax highlighting. http://devdocs.io +{% endblockquote %} +</pre></figure> {% endraw %} -**Alias:**`quote` +{% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %} +NEW: DevDocs now comes with syntax highlighting. http://devdocs.io +{% endblockquote %} -[Reference][1] +**Quote from an article on the web** + +{% raw %} +<figure class="highlight"><pre>{% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} +Every interaction is both precious and an opportunity to delight. +{% endblockquote %} +</pre></figure> +{% endraw %} + +{% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} +Every interaction is both precious and an opportunity to delight. +{% endblockquote %} ## Code Block -Inserts a code block. +This plugins helps you insert code snippets in posts. + +**Alias:** code {% raw %} -<pre><code>{% codeblock [title] [lang:language] [url] [link text] %} -content +<figure class="highlight"><pre>{% codeblock [title] [lang:language] [url] [link text] %} +code snippet {% endcodeblock %} -</code></pre> +</pre></figure> {% endraw %} -**Alias:**`code` +### Example -[Reference][2] +**A normal code block** -## Backtick Code Block +{% raw %} +<figure class="highlight"><pre>{% codeblock %} +alert('Hello World!'); +{% endcodeblock %} +</pre></figure> +{% endraw %} -Inserts a code block. +{% codeblock %} +alert('Hello World!'); +{% endcodeblock %} - ``` [language] [title] [url] [link text] - content - ``` +**Specify language** + +{% raw %} +<figure class="highlight"><pre>{% codeblock lang:objc %} +[rectangle setX: 10 y: 10 width: 20 height: 20]; +{% endcodeblock %} +</pre></figure> +{% endraw %} + +{% codeblock lang:objc %} +[rectangle setX: 10 y: 10 width: 20 height: 20]; +{% endcodeblock %} -[Reference][3] +**Add caption to code block** + +{% raw %} +<figure class="highlight"><pre>{% codeblock Array.map %} +array.map(callback[, thisArg]) +{% endcodeblock %} +</pre></figure> +{% endraw %} + +{% codeblock Array.map %} +array.map(callback[, thisArg]) +{% endcodeblock %} + +**Add caption with an optional URL** + +{% raw %} +<figure class="highlight"><pre>{% codeblock _.compact http://underscorejs.org/#compact Underscore.js %} +_.compact([0, 1, false, 2, '', 3]); +=> [1, 2, 3] +{% endcodeblock %} +</pre></figure> +{% endraw %} + +{% codeblock _.compact http://underscorejs.org/#compact Underscore.js %} +_.compact([0, 1, false, 2, '', 3]); +=> [1, 2, 3] +{% endcodeblock %} + +## Backtick Code Block + +This plugin is same as code block, but in backtick style. + +{% code %} +``` [language] [title] [url] [link text] +code snippet +``` +{% endcode %} ## Pull Quote -Inserts a pull quote. +This plugin helps you insert a pull quote in posts. {% raw %} -<pre><code>{% pullquote [class_name] %} +<figure class="highlight"><pre>{% pullquote [class] %} content {% endpullquote %} -</code></pre> +</pre></figure> {% endraw %} -[Reference][4] - ## jsFiddle -Embeds jsFiddle. +This plugin helps you embed jsFiddle snippets in posts. {% raw %} -<pre><code>{% jsfiddle shorttag [tabs] [skin] [width] [height] %} -</code></pre> +<figure class="highlight"><pre>{% jsfiddle shorttag [tabs] [skin] [width] [height] %} +</pre></figure> {% endraw %} -[Reference][5] - ## Gist -Embeds Gist. +This plugin helps you embed Gist snippets in posts. {% raw %} -<pre><code>{% gist gist_id [filename] %} -</code></pre> +<figure class="highlight"><pre>{% gist gist_id [filename] %} +</pre></figure> {% endraw %} -[Reference][6] - -## Image Tag +## Image -Inserts a picture. +This plugin helps you insert an image in posts with specified size. {% raw %} -<pre><code>{% img [class names] /path/to/image [width] [height] [title text [alt text]] %} -</code></pre> +<figure class="highlight"><pre>{% img [class names] /path/to/image [width] [height] [title text [alt text]] %} +</pre></figure> {% endraw %} -[Reference][7] - ## Youtube -Inserts a Youtube video. +This plugin helps you insert a Youtube video in posts. {% raw %} -<pre><code>{% youtube video_id %} -</code></pre> +<figure class="highlight"><pre>{% youtube video_id %} +</pre></figure> {% endraw %} ## Vimeo -Inserts a Vimeo video. +This plugin helps you insert a Vimeo video in posts. {% raw %} -<pre><code>{% vimeo video_id %} -</code></pre> +<figure class="highlight"><pre>{% vimeo video_id %} +</pre></figure> {% endraw %} ## Raw -Escapes contents. (Please delete the backslash) +If there're some contents can't be processed in posts, you can wrapped it with `raw` tag. {% raw %} -<pre><code>{% raw %} +<figure class="highlight"><pre>{% raw %} +content {% endraw /%} -</code></pre> -{% endraw %} - -[1]: http://octopress.org/docs/plugins/blockquote/ -[2]: http://octopress.org/docs/plugins/codeblock/ -[3]: http://octopress.org/docs/plugins/backtick-codeblock/ -[4]: http://octopress.org/docs/plugins/pullquote/ -[5]: http://octopress.org/docs/plugins/jsfiddle-tag/ -[6]: http://octopress.org/docs/plugins/gist-tag/ -[7]: http://octopress.org/docs/plugins/image-tag/ \ No newline at end of file +</pre></figure> +{% endraw %} \ No newline at end of file diff --git a/source/docs/template-data.md b/source/docs/template-data.md deleted file mode 100644 index c56b8a032e..0000000000 --- a/source/docs/template-data.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -layout: page -title: Template Data -date: 2012-11-01 18:13:30 ---- - -## Global - -- **[site](#site)** - Global site data -- **[page](#page)** - Data of the current page, differed from each page -- **config** - [Global configuration][3], the content of `_config.yml` -- **theme** - Theme configuration, the content of `_config.yml` in theme folder, differed from each theme -- **__** (double underscores) - Gets [internationalization (i18n)][9] strings -- **layout** - Layout -- **cache** - Cache - -<a name="site"></a> -## site - -Global site data. In case of no other plugins loaded, **site** has the following content: - -- **posts** - All posts -- **pages** - All pages -- **categories** - All categories -- **tags** - All tags - -<a name="page"></a> -## page - -Data of the current page, differed from each page. - -### Article (post, page, …) - -- **title** - Title -- **date** - Published date ([Moment.js][7] object) -- **updated** - Updated date ([Moment.js][7] object) -- **categories** - Categories ([Model][5] object) -- **tags** - Tags ([Model][5] object) -- **comments** - Comment enabled or not -- **layout** - Layout -- **content** - Content -- **excerpt** - Exerpt (Content before`<!--more-->`) -- **source** - Source file path -- **path** - Path -- **ctime** - File created time ([Moment.js][7] object) -- **mtime** - File modified time ([Moment.js][7] object) -- **prev** - Previous post -- **next** - Next post - -And other variables user set in articles. The difference of **page** and **post** is that **page** doesn't have `categories`, `tag`, `prev` and `next`. - -<a name="index"></a> -### Home (index) - -**Pagination enabled**: - -- **per_page** - Posts displayed per page -- **total** - Number of posts -- **current** - Current page number -- **current_url** - Current page link -- **posts** - Posts ([Model][5] object) -- **prev** - Previous page number -- **prev_link** - Previous page link -- **next** - Next page number -- **next_link** - Next page link - -**Pagination disabled**: - -A [Model][5] object. - -### Archive (archive) - -Same as [index layout](#index) with the following: - -- **archive** - equals `true` -- **year** - Archive year -- **month** - Archive month - -### Category (category) - -Same as [index layout](#index) with the following: - -- **category** - Category name - -### Tag (tag) - -Same as [index layout](#index) with the following: - -- **tag** - Tag name - -[3]: configure.html -[5]: collection.html#model -[7]: http://momentjs.com/ -[9]: global-variables.html#i18n \ No newline at end of file diff --git a/source/docs/theme-development.md b/source/docs/theme-development.md deleted file mode 100644 index 001bfd2b9f..0000000000 --- a/source/docs/theme-development.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -layout: page -title: Theme Development -date: 2012-11-01 18:13:30 ---- - -## Structure - -``` plain -|-- _config.yml -|-- languages -|-- layout -|-- source -``` - -### _config.yml - -Theme configuration file. - -Reference: [Configure][1] - -### languages - -Folder of language files. - -Reference: [Internationalization (i18n)][2] - -### layout - -Layout folder. You can use [EJS][4] or [Swig][5] to render template files, or install [renderer plugins][8] to use the template engine you like. - -Basic layouts: - -- **archive** - Archives, use **index** layout instead if not exist -- **category** - Category archives, use **archive** layout instead if not exist -- **index** - Home page -- **page** - Page, use **index** layout instead if not exist -- **post** - Post, use **index** layout instead if not exist -- **tag** - Tag archives, use **archive** layout instead if not exist - -You can customize other layouts such as `link` or `photo`. If the custom layout not found, it'll use other layout based on generators. - -*(**index** layout at least)* - -### source - -Source files folder. CSS, JavaScript and other files (Asset) should be placed in this folder. The files in this folder will be processed and copied to `public` folder. File or folder whose name started with `.` (dot) or `_` (underscore) will be ignored. - -Hexo supports [Stylus][6] & [nib][7]. You can install [renderer plugins][8] to add more support for Hexo. - -## Reference - -Reference the default theme [Light][3] to make your theme. - -[1]: configure.html -[2]: global-variables.html#i18n -[3]: https://github.com/tommy351/hexo-theme-light -[4]: https://github.com/visionmedia/ejs -[5]: http://paularmstrong.github.com/swig/ -[6]: http://learnboost.github.com/stylus/ -[7]: http://visionmedia.github.com/nib/ -[8]: ../plugins/#renderer \ No newline at end of file diff --git a/source/docs/themes.md b/source/docs/themes.md new file mode 100644 index 0000000000..a58aebaa4f --- /dev/null +++ b/source/docs/themes.md @@ -0,0 +1,130 @@ +title: Themes +prev: permalinks +next: variables +--- +It's easier to build your theme based on the default theme. If you come across any problems, please [submit the issue](https://github.com/tommy351/hexo/issues) on GitHub. + +## Structure + +``` plain +. +├── _config.yml +├── languages +├── layout +└── source +``` + +### _config.yml + +Theme configuration file. + +### languages + +Folder of language files. + +### layout + +Layout folder. File or folder whose name is prefixed with `_` (underscore) and hidden files will be ignored. + +Hexo provides [EJS](https://github.com/visionmedia/ejs) and [Swig](http://paularmstrong.github.com/swig/) template engine. You can install other template engines such as Haml, Jade. Hexo chooses template engines based on the extension name of files. For example: + +``` plain +EJS: layout.ejs +Swig: layout.swig +``` + +Every theme should at least has `index` layout. + +Layout | Description | Fallback +--- | --- | --- +`index` | Index layout | +`post` | Post layout | `index` +`page` | Page layout | `index` +`archive` | Archives layout | `index` +`category` | Category archives layout | `archive` +`tag` | Tag archives layout | `archive` + +Hexo ported **Layout** and **Partials** feature from Express. Every template file use `layout.ejs` as layout by default. You can set `layout: false` in front-matter or delete `layout.ejs` to disable the layout feature. + +{% note info Custom layout %} +If you set a custom for your posts. You have to add a new layout file in `layout` folder or it'll fallback to `post` layout. Page variables in the custom layout is same as `post` layout. +{% endnote %} + +### source + +Source folder. Asset files like CSS and Javascript files should be placed in this folder. File or folder whose name is prefixed with `_` (underscore) and hidden files will be ignored. Stylus files will be processed and put into `public` folder, while other files will be copied. + +Hexo supports [Stylus](http://learnboost.github.com/stylus/) and [nib](http://visionmedia.github.com/nib/). You can install other plugins such as Less, CoffeeScript. + +## Basic Techniques + +Here are some code snippets that may help you on theme development. + +### Post index + +``` +<% page.posts.each(function(post){ %> + <article class="post"> + <h1> + <a href="<%= config.root %><%= post.path %>"><%= post.title %></a> + </h1> + </article> +<% }); %> +``` + +### Post excerpts + +``` +<% page.posts.each(function(post){ %> + <article class="post"> + <% if (post.excerpt){ %> + <%- post.excerpt %> + <% } else { %> + <%- post.content %> + <% } %> + </article> +<% }); %> +``` + +### Recent posts + +``` +<ul> + <% site.post.sort('date', -1).limit(5).each(function(post){ %> + <li> + <a href="<%= config.root %><%= post.path %>"><%= post.title %></a> + </li> + <% }); %> +</ul> +``` + +### Tag list + +You can inserts a tag list in your theme by `list_tags()` helper or the following code. + +``` +<ul> +<% site.tags.sort('name').each(function(tag){ %> + <li><a href="<%- config.root %><%- tag.path %>"><%= tag.name %></a><small><%= tag.posts.length %></small></li> +<% }); %> +</ul> +``` + +### Disqus comment + +``` +<div id="disqus_thread"> + <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> +</div> +<script type="text/javascript"> +var disqus_shortname = '<%= config.disqus_shortname %>'; + +(function(){ + var dsq = document.createElement('script'); + dsq.type = 'text/javascript'; + dsq.async = true; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); +}()); +</script> +``` \ No newline at end of file diff --git a/source/docs/troubleshooting.md b/source/docs/troubleshooting.md new file mode 100644 index 0000000000..aa04c59aa5 --- /dev/null +++ b/source/docs/troubleshooting.md @@ -0,0 +1,68 @@ +title: Troubleshooting +prev: plugins +next: contributing +--- +You may encounter some problems when using Hexo. The following are the solutions to the problems that people frequently asked. If you can't find the answer here, run again in debug mode and [report an issue](https://github.com/tommy351/hexo/issues/new) on GitHub. + +## YAML Parsing Error + +``` bash +/usr/local/lib/node_modules/hexo/node_modules/yamljs/bin/yaml.js:1219 +throw new YamlParseException('Unable to parse.', this.getRealCurrentLineNb +^ +YamlParseException: Unable to parse. +``` + +When you encounter `YamlParseException`, check your configuration and front-matter in the post files. Make sure they are written in correct YAML format: use spaces instead of tabs and add a space before colons. For example: + +``` yaml +foo: 1 +bar: + baz: 2 +``` + +## EMFILE Error + +``` bash +Error: EMFILE, too many open files +``` + +Though Node.js has non-blocking I/O, the number of synchronous I/O is still limited by system. You may come across EMFILE error when trying to generate a large number of files. You can try to run the following command to increase the number of synchronous I/O. + +``` bash +$ ulimit -n 10000 +``` + +## GitHub Deployment Problems + +``` bash +fatal: 'username.github.io' does not appear to be a git repository +``` + +Make sure you have [set up git](https://help.github.com/articles/set-up-git) on your computer and try to use HTTPS repository URL instead. + +## Server Problems + +``` bash +Error: listen EADDRINUSE +``` + +You may open Hexo server twice or there's other applications using the same port. Try to edit `port` setting or start Hexo server with `-p` flag. + +``` bash +$ hexo server -p 5000 +``` + +## Plugin Installation Problems + +``` bash +npm WARN package.json plugin-name@0.0.1 No read me data. +``` + +This error comes out when you install a plugin which doesn't provide read me file. Don't be scared. This error won't cause any problems. + +``` bash +npm ERR! node-waf configure build +``` + +This error may occurred when you trying to install a plugin written in C, C++ or other non-JavaScript language. Make sure you have installed compiler on your computer. \ No newline at end of file diff --git a/source/docs/variables.md b/source/docs/variables.md new file mode 100644 index 0000000000..3df1bcedd6 --- /dev/null +++ b/source/docs/variables.md @@ -0,0 +1,95 @@ +title: Variables +prev: themes +next: pagination +--- +### Global Variables + +Variable | Description +--- | --- +`site` | Sitewide information. +`page` | Page specific information and custom variables set in front-matter. +`config` | Site configuration +`theme` | Theme configuration. Inherits from site configuration. +`_` (single underscore) | [Lodash](http://lodash.com/) library +`__` (double underscores) | Internationalization (i18n) utility. See below for detail. + +{% note tip Custom Variables %} +You can also use front-matter in layouts just like writing posts! +{% endnote %} + +### Site Variables + +All of the following variables are [Data Model]. + +Variable | Description +--- | --- +`site.posts` | All posts +`site.pages` | All pages +`site.categories` | All categories +`site.tags` | All tags + +### Page Vairables + +**Article (post, page, ...)** + +Variable | Description +--- | --- +`page.title` | Article title +`page.date` | Article created date ([Moment.js] object) +`page.updated` | Article last updated date ([Moment.js] object) +`page.categories` | All categories of the article +`page.tags` | All tags of the article +`page.comments` | Comment enabled or not +`page.layout` | Layout name. +`page.content` | The full processed content of the article +`page.excerpt` | The processed excerpt of the article +`page.source` | The path of the source file +`page.full_path` | Full path of the source file +`page.path` | The URL of the article without root URL. We usually use `config.root + page.path` in theme. +`page.permalink` | Full URL of the article +`page.ctime` | File created time ([Moment.js] object) +`page.mtime` | File modified time ([Moment.js] object) +`page.prev` | The previous post. `null` if the post is the first post. +`page.next` | The next post. `null` if the post is the last post. +`page.original_content` | The raw data of the article + +{% note info Custom front-matter %} +The front-matter in posts will be available under `page`. +{% endnote %} + +**Home (index):** If pagination is disabled, page variables will be a [Data Model]. If not, they'll be the following variables. + +Variable | Description +--- | --- +`page.per_page` | Posts displayed per page +`page.total` | Total number of posts +`page.current` | Current page number +`page.current_url` | The URL of current page +`page.posts` | Posts in this page ([Data Model]) +`page.prev` | Previous page number. `0` if the current page is the first. +`page.prev_link` | The URL of previous page. `''` if the current page is the first. +`page.next` | Next page number. `0` if the current page is the last. +`page.next_link` | The URL of next page. `''` if the current page is the first. +`page.path` | The URL of current page without root URL. We usually use `config.root + page.path` in theme. + +**Archive (archive):** Same as `index` layout but add the following variables. + +Variable | Description +--- | --- +`archive` | Equals `true` +`year` | Archive year (4-digit) +`month` | Archive month (2-digit without leading zeros) + +**Category (category):** Same as `index` layout but add the following variables. + +Variable | Description +--- | --- +`category` | Category name + +**Tag (tag):** Same as `index` layout but add the following variables. + +Variable | Description +--- | --- +`tag` | Tag name + +[Moment.js]: http://momentjs.com/ \ No newline at end of file diff --git a/source/docs/writing.md b/source/docs/writing.md index cceb437f56..834ff87c88 100644 --- a/source/docs/writing.md +++ b/source/docs/writing.md @@ -1,143 +1,143 @@ ---- -layout: page title: Writing -date: 2012-11-01 18:13:30 +prev: migration +next: generating --- +## Create a New Post -## Create - -Execute the following command. - - hexo new [layout] <title> +You can create a new post by yourself or run the following command. If `layout` isn't defined, it'll be the `default_layout` setting. If there're spaces or other special characters in `title`, wrap it with quotation marks. -`layout` is optional. Default is `default_layout` setting in [global configuration][2]. - -``` -hexo new "New Post" -> source/_posts/new-post.md -hexo new page "New Page" -> source/new-page/index.md -hexo new draft "New Draft" -> source/_drafts/new-draft.md +``` bash +$ hexo new [layout] <title> ``` -### File name +### Layout -You can configure the name of new files by editing `new_post_name` setting in [global configuration][2]. Default is `:title.md`. +Hexo has 3 default layouts: `post`, `page` and `draft`. Other layouts will be saved in `source/_posts` by default. -- `:title` - Article title (Default URL of the article) -- `:year` - Published year (4-digit) -- `:month` - Published month (2-digit) -- `:day` - Published date (2-digit) +Layout | Destination +--- | --- +`post` (Default) | source/_posts +`page` | source +`draft` | source/_drafts -To make files sorted by date, you can set it to `:year-:month-:day-:title.md`. +{% note tip Don't process my posts! %} +If you don't want your posts processed. You can set `layout: false` in front-matter. +{% endnote %} -## Configure +### Example -The beginning of article is a block wrapped with `---`, called [YAML Front Matter][1]. You can use YAML to configure posts. +``` bash +$ hexo new "New Post" +# => The file will be created at source/_posts/new-post.md -- **layout** - Layout (Optional) -- **title** - Title -- **date** - Published date (Created date of the file by default) -- **updated** - Last updated date (Optional. Last modified date of the file by default) -- **comments** - Whether to enable comment (Optional. Enabled by default) -- **tags** - Tags (Optional. Not availiable for page) -- **categories** - Categories (Optional. Not availiable for page) -- **permalink** - Override default URL (Optional) +$ hexo new page "New Page" +# => The file will be created at source/new-page/index.html -## Categories +$ hexo new draft "New Draft" +# => The file will be created at source/_drafts/new-draft.md +``` -Category is the relative path to `source/_posts`. It's hierarchical. You can add `categories` property in the file. Its content will be added after the original categories. For example: +### Filename -For example: +You can modify the name of files created by Hexo in `new_post_name` setting. -- `source/_posts/title.md` - Uncategorized -- `source/_posts/Fruits/title.md` - Fruit -- `source/_posts/Fruits/Apple/title.md` - Fruit, Apple +Variable | Description +--- | --- +`:title` | Escaped title (lower case and replace spaces with dash) +`:year` | Created year (4-digit) +`:month` | Created month (2-digit) +`:day` | Created day (2-digit) -``` yaml -# Single category -categories: Fruits +{% note tip Organize your posts by date %} +You can set `new_post_name` as `:year-:month-:day-:title.md` to make your posts ordered by date. +{% endnote %} -# Multiple categories -categories: Fruits/Apple +## Front-matter -categories: [Fruits, Apple] +Front-matter is a block wrapped with `---` in front of the file. For example: -categories: -- Fruits -- Apple +``` yaml +title: Hello World +date: 2013/7/13 20:46:25 +--- ``` -### Category Slug +You can configure all post configuration in the front-matter. The following is predefined settings. -You can configure category slug by editing `categories_map` in [global configuration][2]. For example: +Setting | Description | Default +--- | --- | --- +`layout` | Layout | post/page +`title` | Title | +`date` | Published date | File created date +`updated` | Last updated date | File last updated date +`comments` | Enables comment feature for the post | true +`tags` | Tags (Not available for pages) | +`categories` | Categories (Not available for pages) | +`permalink` | Overrides the default permalink of the post | Filename -- `categories/Games/` - categories/games/ -- `categories/Diary/` - categories/diary/ +{% note warn YAML front-matter %} +Write the front-matter in YAML format. Don't use tabs in the front-matter, use spaces instead. Also, add a space after colons. +{% endnote %} -``` yaml -categories_map: - Games: games - Diary: diary -``` +## Excerpts -## Tags +You can hide parts of your post by adding `<!-- more -->` in the content. Index page will only show the post from the first to the first occurrence of `<!-- more -->`. -``` yaml -# Single tag -tags: Apple +``` markdown +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur libero est, vulputate nec nibh sit amet, luctus placerat diam. Aliquam sit amet est arcu. -# Multiple tags -tags: [Apple, Banana] +<!-- more --> -tags: -- Apple -- Banana +Aenean sit amet mi tristique, luctus diam sit amet, pharetra justo. Quisque ac faucibus tellus, non viverra augue. Phasellus justo ligula, pharetra adipiscing vulputate eget, fringilla sit amet urna. Nunc aliquam fermentum est ac fringilla. ``` -### Tag Slug +## Code Highlighting -You can configure tag slug by editing `tags_map` in [global configuration][2]. For example: +There're 2 ways for you to highlight your code snippets in your posts: **Backtick code block** and **Swig code block**. Both are ported from Octopress. -- `tags/Games/` - tags/games/ -- `tags/Diary/` - tags/diary/ +### Backtick Code Block -``` yaml -tags_map: - Games: games - Diary: diary +{% code %} +``` [language] [title] [url] [link text] +code snippet ``` +{% endcode %} -## Scaffolds - -A scaffold is the default template of articles. Hexo will create articles based on the scaffolds. - -### Example - -Create `photo.md` in `scaffolds` folder. +### Swig Code Block {% raw %} -<pre><code>layout: {{ layout }} -title: {{ title }} -date: {{ date }} -tags: ---- -</code></pre> +<figure class="highlight"><pre>{% code [title] [lang:language] [url] [link text] %} +code snippet +{% endcode %} +</pre></figure> {% endraw %} -And execute the following: +## Scaffold -``` -hexo new photo "New Gallery" +Hexo will create a new post based on the correspond scaffold. For example: + +``` bash +$ hexo new photo "My Gallery" +# => The file will be created at source/_posts/my-gallery.md ``` -Hexo will create a new file based on the content above. +Hexo will find the scaffold file named `photo` in the `scaffolds` folder. If the scaffold not exists, use the post scaffold instead. -### Usage +### Example + +Variables are wrapped by double curly brackets. For example: -A scaffold is processed by Swig. Variables are wrapped by double curly brackets. The following are the variables: +{% code %} +layout: {% raw %}{{ layout }}{% endraw %} +title: {% raw %}{{ title }}{% endraw %} +date: {% raw %}{{ date }}{% endraw %} +--- +{% endcode %} -- **layout** - Layout name -- **title** - Article title -- **date** - Published date +### Variables -[1]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[2]: configure.html \ No newline at end of file +Variable | Description +--- | --- +`layout` | Layout name +`title` | Post title +`date` | File created date \ No newline at end of file diff --git a/source/zh-CN/docs/cli.md b/source/zh-CN/docs/cli.md deleted file mode 100644 index c57b5d5bce..0000000000 --- a/source/zh-CN/docs/cli.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -layout: page -title: 命令 (CLI) -lang: zh-CN -date: 2013-02-18 18:50:50 ---- - -显示 Hexo 目前的版本号 - - hexo version - -建立网站,若`folder`未定义,则Hexo会在目前的资料夹建立网站 - - hexo init <folder> - -建立新文章 - - hexo new [layout] <title> - -生成静态文件,使用`-t`或`--theme`以忽略主题安装 - -- -t/--theme:忽略主题安装 -- -d/--deploy:生成后自动布局 -- -w/--watch:监视文件变更 - -``` -hexo generate -hexo generate -t/--theme -hexo generate -d/--deploy -hexo generate -w/--watch -``` - -启动服务器,按下`Ctrl+C`停止服务器 - -- -p/--port:连接端口设定 - -``` -hexo server -hexo server -p 12345 -``` - -预览,按下`Ctrl+C`停止服务器 - -- -p/--port:连接端口设定 -- -w/--watch:监视文件变更 - -``` -hexo preview -hexo preview -p 12345 -``` - -显示网站设定 - - hexo config - -部署 - -- --setup:只设定不部署 -- --generate:部署前先生成文件 - -``` -hexo deploy -hexo deploy --setup -hexo deploy --generate -``` - -渲染文件 - - hexo render <source> <destination> - -安全模式,此模式下插件不会被载入 - - hexo --safe - -调试模式 - - hexo --debug \ No newline at end of file diff --git a/source/zh-CN/docs/collection.md b/source/zh-CN/docs/collection.md deleted file mode 100644 index ac2c8a33dc..0000000000 --- a/source/zh-CN/docs/collection.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -layout: page -title: 集合(Collection) -lang: zh-CN -date: 2013-02-18 19:05:51 ---- - -<a id="collection"></a> -## Collection - -Collection 类别用于一般的文章集合。 - -#### each(iterator) - -执行循环`iterator(item, i)`,`item`为循环目前的项目,`i`为循环执行的次数(从0开始)。 - -**别名**:forEach - -#### map(iterator) - -执行循环`iterator(item, i)`,并用其回传值代替原项目的值,`item`为循环目前的项目,`i`为循环执行的次数(从0开始)。 - -#### filter(iterator) - -执行循环`iterator(item, i)`,若其回传值为真,则保留其值,`item`为循环目前的项目,`i`为循环执行的次数(从0开始)。 - -**别名**:select - -#### toArray - -将事件转换为数组(Array)。 - -#### slice(start, [end]) - -取出事件中的特定部分。`start`, `end`的值可为负数。 - -#### skip(num) - -忽略事件中最前的指定段落。 - -#### limit(num) - -限制传回的事件数量。 - -#### set(item) - -在事件中新增项目。 - -**别名**:push - -#### sort(orderby, [order]) - -排列事件。`order`为`1`, `asc`时为升序排列(预设),`-1`, `desc`时为降序排列。 - -#### reverse - -反转对象顺序。 - -#### random - -随机排列事件。 - -**别名**:shuffle - -<a id="taxonomy"></a> -## Taxonomy - -Taxonomy 类别用于文章分类集合,是 Collection 类别的继承,与 Collection 类别的差别在于 Taxonomy 类别使用字串当作键值。 - -#### get(name) - -取得事件中的指定项目。 - -#### set(name, item) - -在事件中新增一个名为`name`的项目。 - -**别名**:push - -#### each(iterator) - -执行循环`iterator(value, key, i)`,`value`为循环目前的项目数值,`key`为循环目前的项目名称,`i`为循环执行的次数(从0开始)。 - -**别名**:forEach - -#### map(iterator) - -执行循环`iterator(value, key, i)`,并用其回传值代替原项目的值,`value`为循环目前的项目数值,`key`为循环目前的项目名称,`i`为循环执行的次数(从0开始)。 - -#### filter(iterator) - -执行循环`iterator(value, key, i)`,若其回传值为真,则保留其值,`value`为循环目前的项目数值,`key`为循环目前的项目名称,`i`为循环执行的次数(从0开始)。 - -**别名**:select - -<a id="paginator"></a> -## Paginator - -Paginator 类别是原类别的继承,仅增加下列属性。 - -- **per_page** - 每页显示的文章数量 -- **total** - 文章总数量 -- **current** - 目前页数 -- **current_url** - 目前页数的网址 -- **posts** - [Collection 类别][1] -- **prev** - 上一页的页数 -- **prev_link** - 上一页的链接 -- **next** - 下一页的页数 -- **next_link** - 下一页的链接 - -[1]: #collection \ No newline at end of file diff --git a/source/zh-CN/docs/configure.md b/source/zh-CN/docs/configure.md deleted file mode 100644 index ce3e0701e2..0000000000 --- a/source/zh-CN/docs/configure.md +++ /dev/null @@ -1,184 +0,0 @@ ---- -layout: page -title: 设定 -lang: zh-CN -date: 2013-02-18 18:55:29 ---- - -全局设定文件储存于网站根目录下的`_config.yml`。 - -## 设定 - -### 网站 - -- **title** - 网站标题 -- **subtitle** - 网站副标题 -- **description** - 网站描述 -- **author** - 网站作者 -- **email** - 网站作者的电子信箱位址 -- **language** - 网站使用的语言([IETF 格式][1],例如繁体中文为 `zh-TW`) - -### 网址 - -- **url** - 网站网址 -- **root** - 网站的根目录。假设 `url` 为 `http://yoursite.com/child`,则 `root` 为 `/child/`。 -- **permalink** - 文章的固定连接([设定][2]) -- **tag_dir** - 标签文件夹 -- **archive_dir** - 存档列表文件夹 -- **category_dir** - 分类文件夹 - -### 写作 - -- **new_post_name** - 新文章的文件名([设定][7]) -- **default_layout** - 预设布局 -- **auto_spacing** - 在东方文字与西方文字之间插入空白 -- **titlecase** - 将标题转为合适的大小写 -- **max_open_file** - 最大同时处理文件数量 -- **filename_case** - 转换文件名称为 (1) 小写 (2) 大写 -- **highlight** - 代码区块设定 - - **enable** - 启用代码 Highlight - - **backtick_code_block** - 启用 [Backtick Code Block][6] - - **line_number** - 显示行号 - - **tab_replace** - 取代 Tab - -### 分类 & 标签 - -- **default_category** - 预设分类 -- **category_map** - 分类别名 -- **tag_map** - 标签别名 - -### 存档列表 - -`2` - 开启列表的分页功能 -`1` - 关闭列表的分页功能 -`0` - 完全关闭 - -- **archive** -- **category** -- **tag** - -### 服务器 - -- **port** - 服务器连接端口 -- **logger** - 启用服务器记录 -- **logger_format** - 服务器记录的格式([Connect][3]) - -### 日期 / 时间格式 - -Hexo 使用 Moment.js 解析和显示日期。([Moment.js][4]) - -- **date_format** - 日期格式 -- **time_format** - 时间格式 - -### 分页 - -- **per_page** - 每页显示的文章数量(0 代表关闭分页功能) -- **pagination_dir** - 分页文件夹 - -### Disqus - -- **disqus_shortname** - [Disqus][5] 的 Shortname - -### 扩充套件 - -- **themes** - 目前使用的主题 -- **exclude_generator** - 要关闭的 Generator(archive, category, home, page, post, tag) - -### 部署 - -- **type** - 部署类型 - -其他设定请依照各个布局扩展调整设定。 - -## 预设值 - -``` yaml -# Hexo Configuration -## Docs: http://zespia.tw/hexo/docs/configure.html -## Source: https://github.com/tommy351/hexo/ - -# Site -title: Hexo -subtitle: -description: -author: John Doe -email: -language: - -# URL -## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' -url: http://yoursite.com -root: / -permalink: :year/:month/:day/:title/ -tag_dir: tags -archive_dir: archives -category_dir: categories - -# Writing -new_post_name: :title.md # File name of new posts -default_layout: post -auto_spacing: false # Add spaces between asian characters and western characters -titlecase: false # Transform title into titlecase -max_open_file: 100 -filename_case: 0 -highlight: - enable: true - backtick_code_block: true - line_number: true - tab_replace: - -# Category & Tag -default_category: uncategorized -category_map: -tag_map: - -# Archives -## 2: Enable pagination -## 1: Disable pagination -## 0: Fully Disable -archive: 2 -category: 2 -tag: 2 - -# Server -## Hexo uses Connect as a server -## You can customize the logger format as defined in -## http://www.senchalabs.org/connect/logger.html -port: 4000 -logger: false -logger_format: - -# Date / Time format -## Hexo uses Moment.js to parse and display date -## You can customize the date format as defined in -## http://momentjs.com/docs/#/displaying/format/ -date_format: MMM D YYYY -time_format: H:mm:ss - -# Pagination -## Set per_page to 0 to disable pagination -per_page: 10 -pagination_dir: page - -# Disqus -disqus_shortname: - -# Extensions -## Plugins: https://github.com/tommy351/hexo/wiki/Plugins -## Themes: https://github.com/tommy351/hexo/wiki/Themes -theme: light -exclude_generator: - -# Deployment -## Docs: http://zespia.tw/hexo/docs/deploy.html -deploy: - type: -``` - -[1]: http://www.w3.org/International/articles/language-tags/ -[2]: permalink.html -[3]: http://www.senchalabs.org/connect/logger.html -[4]: http://momentjs.com/docs/#/displaying/format/ -[5]: http://disqus.com/ -[6]: tag-plugins.html -[7]: writing.html \ No newline at end of file diff --git a/source/zh-CN/docs/contribute.md b/source/zh-CN/docs/contribute.md deleted file mode 100644 index 23e9ef4d51..0000000000 --- a/source/zh-CN/docs/contribute.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -layout: page -title: 贡献 -lang: zh-CN -date: 2013-02-18 18:40:43 ---- - -## 汇报错误 - -当你使用Hexo时,如果发现错误的话,请在GitHub上汇报,如果有任何建议的话,也欢迎提出。 - -你可从GitHub上复制**dev**分支尝鲜,几乎每天都有新玩意! - -``` -npm install -g https://github.com/tommy351/hexo/archive/dev.tar.gz -``` - -[汇报问题][1] - -## 撰写文件 - -当发现文件有不足或错误时,你可以: - -1. Fork 本专案 -2. 根据 **site** 分支建立新分支 -3. 修改文件 -4. 发送 Pull Request 到 **site** 分支 - -如果想要帮忙翻译文件,请在`source`文件夹开一个新的文件夹,并将原始文件复制进去。例如: - -``` plain -zh-CN -|-- docs -|-- index.md -|-- plugins -|-- themes -``` - -并在每个文章新增语言参数,例如: - -``` plain ---- -layout: page -title: 贡献 -lang: zh-CN -date: 2013-02-19 09:56:45 ---- -``` - -语言码请依照 [IETF 格式][3] 命名。 - -[原始码][2] - -## 参与开发 - -如果你想要参与开发,你可以: - -1. Fork 本专案 -2. 开新分支 -3. 新功能开发完成后,发送 Pull Request 到 **dev** 分支 - -如果你开发了很棒的插件的话,也可以发送 Pull Request,也许你开发的插件能够合并主程序! - -[原码][4] - -[1]: https://github.com/tommy351/hexo/issues -[2]: https://github.com/tommy351/hexo/tree/site -[3]: http://www.w3.org/International/articles/language-tags/ -[4]: https://github.com/tommy351/hexo \ No newline at end of file diff --git a/source/zh-CN/docs/deploy.md b/source/zh-CN/docs/deploy.md deleted file mode 100644 index 8fe25366b1..0000000000 --- a/source/zh-CN/docs/deploy.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -layout: page -title: 部署 -lang: zh-CN -date: 2013-02-18 19:04:50 ---- - -Hexo 的部署非常简单,仅需一个指令即可完成所有设定。 - -## GitHub - -### 设定 - -编辑`_config.yml`。 - -``` yaml -deploy: - type: github - repository: - branch: -``` - -- **repository** - GitHub的Repository网址 -- **branch** - 若 Repository类似`username.github.com`,则填入`master`,否则填入`gh-pages` - -### 部署 - -静态文件生成后,执行下列指令即可完成部署,或可加入 `--generate` 选项,在部署前自动生成文件。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -### 移除 - -执行下列指令移除部署文件。 - -``` bash -rm -rf .deploy -``` - -### 自定域名 - -在`source`文件夹内建立名为`CNAME`的文件。 - -请根据你的域名类型设定DNS。 - -#### 顶级域名 (Top-level domain) - -若域名类似`example.com`,则加入 **A 记录 (A record)** `204.232.175.78`。`CNAME`文件内容为`example.com`。 - -#### 子域名 (Subdomain) - -若域名类似`username.example.com`,则加入 **CNAME 记录 (CNAME record)** `username.github.com`。`CNAME`文件内容为`username.example.com`。 - -请参考 [GitHub Pages][1] 以取得更多资讯。 - -## Heroku - -### 设定 - -编辑 `_config.yml`。 - -``` yaml -deploy: - type: heroku - repository: -``` - -- **repository** - Heroku的Repository - -### 部署 - -静态文件生成后,执行下列指令即可完成部署,或可加入 `--generate` 选项,在部署前自动生成文件。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -请参考 [Heroku][2] 以取得更多资讯。 - -### 移除 - -删除`.git`、`app.js`和`Procfile`即可移除部署。 - -## Rsync - -### 设定 - -编辑`_config.yml`文件。 - -``` yaml -deploy: - type: rsync - host: - user: - root: - port: - delete: -``` - -- **host** - 远端主机的位置 -- **user** - 使用者名称 -- **root** - 远端主机的根目录 -- **port** - 连接端口(预设为`22`) -- **delete** - 删除远端主机的旧有文件(预设为`true`) - -### 部署 - -静态文件生成后,执行下列指令即可完成部署,或可加入 `--generate` 选项,在部署前自动生成文件。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -[1]: https://help.github.com/articles/setting-up-a-custom-domain-with-pages -[2]: https://devcenter.heroku.com/ diff --git a/source/zh-CN/docs/events.md b/source/zh-CN/docs/events.md deleted file mode 100644 index 7ef29f0a63..0000000000 --- a/source/zh-CN/docs/events.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -layout: page -title: 事件 -lang: zh-CN -date: 2013-02-18 19:46:12 ---- - -[全局变量][1] `hexo` 本身是一个 [EventEmitter][2] 对象,你可直接监听或触发事件。 - -## 使用 - -监听事件: - -``` -hexo.on('ready', function(){ - ... -}); -``` - -触发事件: - -``` -hexo.emit('event', [arg1], [arg2], [….]); -``` - -[参考][2] - -## 预设事件 - -### ready - -设定和所有插件都载入完毕后。 - -### generateBefore - -开始生成文件前。 - -### generateAfter - -生成文件完成后。 - -### new - -建立新文章后。回传一个参数 `target`,代表新文件的绝对路径。 - -### server - -服务器开启后。 - -### preview - -预览服务器开启后。 - -[1]: global-variables.html -[2]: http://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file diff --git a/source/zh-CN/docs/global-variables.md b/source/zh-CN/docs/global-variables.md deleted file mode 100644 index 2bee397f87..0000000000 --- a/source/zh-CN/docs/global-variables.md +++ /dev/null @@ -1,198 +0,0 @@ ---- -layout: page -title: 全局变量 -lang: zh-CN -date: 2013-02-18 19:06:27 ---- - -Hexo 在初始化时,会建立一个名为`hexo`的命名空间(Namespace),此命名空间内拥有以下唯读变量。 - -- **base_dir** - 网站根目录 -- **public_dir** - 静态文件目录(public) -- **source_dir** - 源文件目录(source) -- **theme_dir** - 主题目录(theme/theme_name) -- **plugin_dir** - 插件目录(node_modules) -- **script_dir** - 脚本目录(scripts) -- **scaffold_dir** - 骨架目录(scaffolds) -- **core_dir** - 程序根目录(hexo) -- **lib_dir** - 程序资源库目录(hexo/lib) -- **version** - Hexo 版本号 -- **env** - 执行环境 -- **safe** - 安全模式 -- **debug** - 调试模式 -- **config** - [全站设定][1],即`_config.yml`的内容 -- **render** - [渲染][5] -- **[extend](#extend)** - 扩展程序 -- **[util](#util)** - 工具程序 -- **[i18n](#i18n)** - 国际化(i18n)模组 -- **[route](#route)** - 路由模组 -- **[cache](#cache)** - 缓存模组 - -<a id="extend"></a> -### extend - -extend是负责处理所有扩展程序的模组,每个扩展都有两种方法:**list** 和 **register**,前者可列出该扩展所掌管的所有扩展程序,后者可挂载新的扩展程序到该扩展上。 - -#### generator - -- **list** - 返回一个数组(Array) -- **register(fn)** - 加载扩展程序 - -#### renderer - -- **list** - 返回一个对象(Object),扩展内的元素拥有`output`属性。 -- **register(name, output, fn, sync)** - 挂载扩展程序。`name`为扩展程序的名称,`output`为输出后的扩展名,`sync`决定扩展程序是否可同步执行(预设为false)。 - -#### tag - -- **list** - 返回一个对象(Object) -- **register(name, fn, ends)** - 挂载扩展程序。`name`为扩展程序的名称,`ends`决定该扩展程序是否拥有结尾标签(End tag),预设为`false` - -#### deployer - -- **list** - 返回一个对象(Object) -- **register(name, fn)** - 加载扩展程序。`name`为扩展程序的名称。 - -#### processor - -- **list** - 返回一个数组(Array) -- **register(fn)** - 加载扩展程序 - -#### helper - -- **list** - 返回一个对象(Object) -- **register(name, fn)** - 加载扩展程序。`name`为扩展程序的名称。 - -#### console - -- **list** - 返回一个对象(Object),扩展内的元素拥有`description`属性。 -- **register(name, desc, fn)** - 挂载扩展程序。`name`为扩展程序的名称,`desc`为扩展程序的描述。 - -#### migrator - -- **list** - 返回一个对象(Object) -- **register(name, fn)** - 挂载扩展程序。`name`为扩展程序的名称。 - -更多详细资料请参考 [插件开发][2]。 - -<a id="util"></a> -### util - -util为工具程序,包含下列模组: - -#### file - -用以操作文件,拥有以下方法: - -- **mkdir(dest, callback)** -- **write(dest, content, callback)** -- **copy(src, dest, callback)** -- **dir(src, callback)** -- **read(src, callback)** -- **readSync(src, callback)** -- **empty(target, exclude, callback)** - -#### highlight(string, options) - -用以输出Highlight代码区块。以下为选项: - -- **gutter** - 显示行号 -- **first_line** - 起始行号 -- **lang** - 语言 -- **caption** - 代码区块说明 - -#### titlecase(string) - -用以将字串转为适合的标题大小写。 - -#### yfm(string) - -用以解析 [YAML Front Matter][3],输出一个对象(Object),本文存放于`_content`属性。 - -<a id="i18n"></a> -### i18n - -i18n为处理国际化(Internationalization)的模组,使用方式如下: - -``` js -var i18n = new hexo.i18n(); -``` - -i18n对象拥有以下方法: - -#### get - -第一引数必须为语言档的键值,其后的引数则会使用 [util.format][4] 处理。 - -若第一引数为数组(Array),则会判断第二引数的数值来处理复数名词。 - -- 第一引数拥有2个元素 - - n > 1: 使用第2个元素 - - n <= 1: 使用第1个元素 -- 第一引数拥有3个元素 - - n > 1: 使用第3个元素 - - 0 < n <= 1: 使用第2个元素 - - n == 0: 使用第1个元素 - -#### set(key, value) - -- **key** - 键值 -- **value** - 对应值 - -#### list([obj]) - -若`obj`未定义,则传回对象内的所有数值;若`obj`为一对象(Object),则将对象取代为传入的引数。 - -#### load(path, callback) - -自动载入语言文件。`path`为放置语言文件的文件夹,Hexo会根据`_config.yml`的`language`设定载入相对应的语言文件,若找不到语言文件的话,则会载入`default.yml`,因此文件夹内至少要有一个`default.yml`。 - -<a id="route"></a> -### route - -自从0.3版之后,Hexo开始引入路由模组处理网站的所有文件路径。 - -#### get(path) - -取得路径内容,传回一个函数。 - -#### set(path, content) - -设定路径内容。`content`可为函数或其他内容,若为函数则必须使用`function(err, content)`格式。 - -#### format(path) - -处理路径格式。若路径为空或结尾为`/`,则在最后加入`index.html`。 - -#### destroy(path) - -删除路径。 - -#### list() - -返回一个对象(Object)。 - -<a id="cache"></a> -### cache - -#### list() - -列出所有缓存内容。 - -#### get(name) - -取得指定缓存。 - -#### set(name, value, [callback]) - -设定缓存内容。 - -#### destroy(name, [callback]) - -删除指定缓存。 - -[1]: configure.html -[2]: plugin-development.html -[3]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[4]: http://nodejs.org/api/util.html#util_util_format_format -[5]: render.html \ No newline at end of file diff --git a/source/zh-CN/docs/helpers.md b/source/zh-CN/docs/helpers.md deleted file mode 100644 index f1e1132932..0000000000 --- a/source/zh-CN/docs/helpers.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -layout: page -title: 辅助方法 (Helper) -lang: zh-CN -date: 2013-02-18 19:44:02 ---- - -辅助方法(Helper)为模板中所使用的辅助方法,可将资料转换为 HTML 字串,使主题开发更加容易。以下是内建的辅助方法:(语法以EJS为范例) - -### css - -载入CSS文件。 - -``` -<%- css(path) %> -``` - -### js - -载入JavaScript文件。 - -``` -<%- js(path) %> -``` - -### gravatar - -载入Gravatar。 - -``` -<%- gravatar(email, [size]) %> -``` - -### trim - -清除字串内的空白。 - -``` -<%- trim(string) %> -``` - -### strip_html - -清除字串内的所有HTML标签。 - -``` -<%- strip_html(string) %> -``` - -### titlecase - -将字串转为合适的标题大小写。 - -``` -<%- titlecase(string) %> -``` - -### render - -使用指定的[渲染引擎][2](`engine`)渲染内容,可使用`locals`指定区域变量。 - -``` -<%- render(string, engine, [locals]) %> -``` - -例如:使用Markdown渲染。 - -``` -<%- render('**bold**', 'md') %> -``` - -### partial - -载入其他模板。`layout`为模板的相对路径;可使用`locals`指定区域变量。(使用方法与 [express-partials][1] 相同) - -``` -<%- partial(layout, [locals]) %> -``` - -### tagcloud - -插入标签云(Tag Cloud)。`tags`请输入 [模板变量][3] `tags`;`options`详见下方。 - -``` -<%- tagcloud(tags, [options]) %> -``` - -**选项:** - -- **min_font** - 最小的字体大小 -- **max_font** - 最大的字体大小 -- **unit** - 字体单位 -- **amount** - 标签数量 -- **orderby** - 排列顺序 -- **order** - 排列方式。`1`, `asc`代表升序排列,`-1`, `desc`代表降序排列,`rand`, `random`代表随机排列。 - -**预设值:** - -``` -{ - min_font: 10, - max_font: 20, - unit: 'px', - amount: 40, - orderby: 'name', - order: 1 -} -``` - -### paginator - -插入翻页导航(Paginator)。`options`详见下方。 - -``` -<%- paginator(options) %> -``` - -**选项:** - -- **base** - 基础网址 -- **format** - 网址格式 -- **total** - 总页数 -- **current** - 目前页数 -- **prev_text** - 上一页文字 -- **next_text** - 下一页文字 -- **space** - 间隔 -- **prev_next** - 显示上一页和下一页链接 -- **end_size** - 开头和尾端显示的分页数量 -- **mid_size** - 目前页面周围显示的分页数量 -- **show_all** - 显示所有分页 - -**预设值:** - -``` -{ - base: '/', - format: 'page/%d/', - total: 1, - current: 0, - prev_text: 'Prev', - next_text: 'Next', - space: '&hellp;', - prev_next: true, - end_size: 1, - mid_size: 2, - show_all: false -} -``` - -[1]: https://github.com/publicclass/express-partials -[2]: render.html -[3]: template-data.html \ No newline at end of file diff --git a/source/zh-CN/docs/index.md b/source/zh-CN/docs/index.md deleted file mode 100644 index b6a2533451..0000000000 --- a/source/zh-CN/docs/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -layout: page -title: 文件 -lang: zh-CN -date: 2013-02-18 19:42:35 ---- - -## 开始 - -#### [安装](install.html) - -#### [建立](setup.html) - -#### [设定](configure.html) - -#### [部署](deploy.html) - -#### [迁移](migrate.html) - -## 使用 - -#### [写作](writing.html) - -#### [标签插件](tag-plugins.html) - -#### [服务器](server.html) - -#### [固定连接](permalink.html) - -#### [脚本](scripts.html) - -#### [命令 (CLI)](cli.html) - -## 开发 - -#### [全局变量](global-variables.html) - -#### [模板资料](template-data.html) - -#### [辅助方法 (Helper)](helpers.html) - -#### [集合 (Collection)](collection.html) - -#### [事件](events.html) - -#### [渲染](render.html) - -#### [主题开发](theme-development.html) - -#### [插件开发](plugin-development.html) - -#### [贡献](contribute.html) \ No newline at end of file diff --git a/source/zh-CN/docs/install.md b/source/zh-CN/docs/install.md deleted file mode 100644 index 1f6f62b315..0000000000 --- a/source/zh-CN/docs/install.md +++ /dev/null @@ -1,142 +0,0 @@ ---- -layout: page -title: 安装 -lang: zh-CN -date: 2013-02-18 19:41:43 ---- - -在安装 Hexo 之前,必须先安装 [Git][2] 和 [Node.js][1]。 - -## 目录 - -- [Windows](#windows) -- [Mac](#mac) -- [Linux](#linux) - -<a id="windows"></a> -## Windows - -### Git - -下载 [msysgit][7] 并执行即可完成安装。 - -### Node.js - -在 Windows 环境下安装 Node.js 非常简单,仅须 [下载][1] 安装文件并执行即可完成安装。 - -### Hexo - -利用 [npm][3] 即可安装。 - -``` bash -npm install -g hexo -``` - -<a id="mac"></a> -## Mac - -### Git - -Mac 已内建 Git,虽然版本较旧,不过还是能用,如果你想要使用较新版的 Git 的话,可参考以下方式安装。 - -1. 使用 [Homebrew][5]。 - - brew install git - -2. 使用 [MacPorts][6]。 - - sudo port install git-core - -3. 使用 [安装程式][8]。 - -如果出现错误情况,可能是尚未安装编译工具,请至 App Store 下载 Xcode。 - -### Node.js - -Mac 环境下有很多安装方式可供选择,以下使用 [nvm][4] 来安装。 - -执行以下指令。 - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -安装完毕后,在`~/.bash_profile`或`~/.bashrc`加入以下内容并重开一个新的终端视窗。 - -``` bash -. ~/nvm/nvm.sh -``` - -之后即可使用 [nvm][4] 来安装 Node.js 了,编译可能需要花些时间,请耐心等候。 - -``` bash -nvm install v0.8.14 -nvm use v0.8.14 -nvm alias default v0.8.14 -``` - -### Hexo - -利用 [npm][3] 即可安装。 - -``` bash -npm install -g hexo -``` - -<a id="linux"></a> -## Linux - -### Git - -**Ubuntu, Debian:** - -``` bash -sudo apt-get install git-core -``` - -**Fedora, Red Hat, CentOS:** - -``` bash -sudo yum install git-core -``` - -### Node.js - -Linux 环境下有很多安装方式可供选择,以下使用 [nvm][4] 来安装。 - -执行以下指令。 - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -安装完毕后,在`~/.bash_profile`或`~/.bashrc`加入以下内容并重开一个新的终端视窗。 - -``` plain -. ~/nvm/nvm.sh -``` - -之后即可使用 [nvm][4] 来安装 Node.js 了,编译可能需要花些时间,请耐心等候。 - -``` bash -nvm install v0.8.14 -nvm use v0.8.14 -nvm alias default v0.8.14 -``` - -### Hexo - -利用 [npm][3] 即可安装。 - -``` bash -npm install -g hexo -``` - -[1]: http://nodejs.org/ -[2]: http://git-scm.com/ -[3]: http://npmjs.org/ -[4]: https://github.com/creationix/nvm -[5]: http://mxcl.github.com/homebrew/ -[6]: http://www.macports.org/ -[7]: http://code.google.com/p/msysgit/ -[8]: http://code.google.com/p/git-osx-installer/ \ No newline at end of file diff --git a/source/zh-CN/docs/migrate.md b/source/zh-CN/docs/migrate.md deleted file mode 100644 index 636ed5ef06..0000000000 --- a/source/zh-CN/docs/migrate.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -layout: page -title: 迁移 -lang: zh-CN -date: 2013-02-18 19:40:47 ---- - -## 目录 - -- [RSS](#rss) -- [Jekyll / Octopress](#jekyll) -- [WordPress](#wordpress) - -<a id="rss"></a> -## RSS - -首先,执行以下指令安装 RSS Migrator 插件,并在`_config.yml`中的`plugins`栏位加入`hexo-migrator-rss`。 - -``` plain -npm install hexo-migrator-rss -``` - -安装完毕后,执行以下指令即可,`source`参数可为文件路径或网址。 - - hexo migrate rss <source> - -<a id="jekyll"></a> -## Jekyll / Octopress - -将`source/_posts`内的档桉拷贝至Hexo的`source/_posts`内,并将文章内的`categories`属性修改为`tags`。 - -然后调整 `_config.yml` 中的 `new_post_name` 为 `:year-:month-:day-:title.md`。 - -<a id="wordpress"></a> -## WordPress - -首先,执行以下指令安装 WordPress Migrator 插件,并在`_config.yml`中的`plugins`栏位加入`hexo-migrator-wordpress`。 - -``` plain -npm install hexo-migrator-wordpress -``` - -安装完毕后,执行以下指令即可,`source`参数可为文件路径或网址。 - - hexo migrate wordpress <source> \ No newline at end of file diff --git a/source/zh-CN/docs/permalink.md b/source/zh-CN/docs/permalink.md deleted file mode 100644 index 3dfb058838..0000000000 --- a/source/zh-CN/docs/permalink.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -layout: page -title: 固定链接 -lang: zh-CN -date: 2013-02-18 19:39:10 ---- - -## 设定 - -在`_config.yml`中的`permalink`栏位设定文章链接,预设值为: - -``` plain -permalink: :year/:month/:day/:title/ -``` - -在固定连接中可加入以下变量,变量名称前必须拥有`:`才有效。 - -- **year** - 4位数的年份 -- **month** - 2位数的月份 -- **day** - 2位数的日期 -- **title** - 文章的文件名称 -- **category** - 文章的分类(对于`source/_posts`的相对路径),若文章无分类,则为`_config.yml`中的`category_dir`栏位 - -*(日期以文章设定中的日期为基准)* - -## 举例 - -假设有一文章名为`title.md`,放置于`source/_posts/foo/bar`文件夹,内容为: - -``` plain ---- -title: Post Title -date: 2012-10-09 14:09:37 -tags: -- Node.js -- JavaScript ---- -``` - -则结果会是: - -``` plain -:year/:month/:day/:title/ => /2012/10/09/title/ -:year-:month-:day/:title/ => /2012-10-09/title/ -:category/:title/ => /foo/bar/title/ -``` \ No newline at end of file diff --git a/source/zh-CN/docs/plugin-development.md b/source/zh-CN/docs/plugin-development.md deleted file mode 100644 index 661018a954..0000000000 --- a/source/zh-CN/docs/plugin-development.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -layout: page -title: 插件开发 -lang: zh-CN -date: 2013-02-18 19:34:52 ---- - -插件分为以下八种类型: - -- [Generator](#generator) - 生成静态文件 -- [Renderer](#renderer) - 渲染文件 -- [Helper](#helper) - 模板辅助方法 -- [Deployer](#deployer) - 部署工具 -- [Processor](#processor) - 处理原始文件 -- [Tag](#tag) - 文章标签 -- [Console](#console) - 命令(CLI) -- [Migrator](#migrator) - 迁移工具 - -<a id="generator"></a> -## Generator - -### 语法 - -``` js -hexo.extend.generator.register(fn); -``` - -- **fn(locals, render, callback)** - - **locals** - [网站全局资料][1] - - **render(layout, locals)** - 渲染函数 - - **layout** - 要使用的模板 - - **locals** - 传入模板的资料,即模板中的`page`变量 - - **callback** - 回传函数 - -### 范例 - -在`public/archive.html`生成文章列表页面。 - -``` js -hexo.extend.generator.register(function(locals, render, callback){ - hexo.route.set('archive.html', function(func){ - var result = render('archive', locals); - func(null, result); - }); -}); -``` - -<a id="renderer"></a> -## Renderer - -### 语法 - -``` js -hexo.extend.renderer.register(name, output, fn, [sync]); -``` - -- **name** - 输入文件的扩展名(小写,不包含`.`) -- **output** - 输出文件的扩展名(小写,不包含`.`) -- **fn** - 见下方 -- **sync** - 同步模式,预设为`false` - -**同步模式**(当`sync`为`true`时) - -`fn(path, content, [locals])` - 当执行完成时,应使用`return`回传结果 - -- **path** - 输入文件的路径,仅在编译(Compile)模式时有效 -- **content** - 输入文件的内容 -- **locals** - 自定变量 - -**非同步模式**(当`sync`为`false`或未指定时) - -`fn(path, content, [locals], [callback])` - 当执行完成时,应透过`callback`回传结果 - -- **path** - 输入文件的路径,仅在编译(Compile)模式时有效 -- **content** - 输入文件的内容 -- **locals** - 自定变量 -- **callback** - 回传函数 - -### 范例 - -#### 同步模式 - -``` js -var ejs = require('ejs'), - _ = require('underscore'); - -hexo.extend.renderer.register('ejs', 'html', function(path, content, locals){ - if (path) locals = _.extend(locals, {filename: path}); - return ejs.render(content, locals); -}, true); -``` - -#### 非同步模式 - -``` js -var stylus = require('stylus'); - -hexo.extend.renderer.register('styl', 'css', function(path, content, callback){ - stylus(content).set('filename', path).render(callback); -}); -``` - -<a id="helper"></a> -## Helper - -### 语法 - -``` js -hexo.extend.helper.register(name, fn); -``` - -- **name** - 名称(小写) -- **fn** - 应传回一函数 - -### 举例 - -插入 JavaScript 文件。 - -``` js -hexo.extend.helper.register('js', function(){ - return function(path){ - return '<script type="text/javascript" src="' + path + '"></script>'; - } -}); -``` - -输入: - -``` -<%- js('script.js') %> -``` - -输出: - -``` html -<script type="text/javascript" src="script.js"></script> -``` - -<a id="deployer"></a> -## Deployer - -### 语法 - -``` js -hexo.extend.deployer.register(name, fn); -``` - -- **name** - 名称(小写) -- **fn(args)** - - **args** - 引数 - -### 范例 - -``` js -hexo.extend.deployer.register('github', function(args){ - // ... -}); -``` - -<a id="processor"></a> -## Processor - -### 语法 - -``` js -hexo.extend.processor.register(fn); -``` - -- **fn(locals, callback)** - - **locals** - [网站全站资料][1] - - **callback(err, locals)** - - **err** - 错误内容,当无错误时请返回`null` - - **locals** - 处理后的资料 - -### 范例 - -根据日期升降排列文章。 - -``` js -hexo.extend.processor.register(function(locals, callback){ - locals.posts = locals.posts.sort('date', -1); - locals.pages = locals.pages.sort('date', -1); - callback(null, locals); -}); -``` - -<a id="tag"></a> -## Tag - -### 语法 - -``` js -hexo.extend.tag.register(name, fn, [ends]); -``` - -- **name** - 名称(小写) -- **fn(args, content)** - - **args** - 引数 - - **content** - 内容 -- **ends** - 结尾标签 - -### 范例 - -插入Youtube影片。 - -``` js -hexo.extend.tag.register('youtube', function(args, content){ - var id = args[0]; - return '<div class="video-container"><iframe width="560" height="315" src="http://www.youtube.com/embed/' + id + '" frameborder="0" allowfullscreen></iframe></div>'; -}); -``` - -插入 Pull Quote - -``` js -hexo.extend.tag.register('pullquote', function(args, content){ - var className = args.length ? ' ' + args.join(' ') : ''; - return '<blockquote class="pullquote' + className + '">' + content + '</blockquote>'; -}, true); -``` - -<a id="console"></a> -## Console - -### 语法 - -``` js -hexo.extend.console.register(name, desc, [options], fn); -``` - -- **name** - 名称(小写) -- **desc** - 描述 -- **options** - 选项(见下方) -- **fn(args)** - - **args** - 引数 - -### 选项 - -- **init** - 未初始化时显示 -- **debug** - 调试模式时显示 - -### 范例 - -执行以下指令时显示网站设定。 - -``` bash -hexo config -``` - -``` js -hexo.extend.console.register('config', 'Display configuration', function(args){ - console.log(hexo.config); -}); -``` - -<a id="migrator"></a> -## Migrator - -### 语法 - -``` js -hexo.extend.migrator.register(name, fn); -``` - -- **name** - 名称(小写) -- **fn(args)** - - **args** - 引数 - -## 发布 - -在发布之前,别忘了先测试。将插件复制至`node_modules`资料夹内,安装相关模组后,试着实际使用,或进行单元测试。 - -当一切测试结束后,执行以下指令,将插件发布至 NPM。 - -``` -npm publish -``` - -## 参考 - -你可参考 [内建模组][2] 和 [官方插件][3] 的原始码来制作插件。 - -[1]: template-data.html#site -[2]: https://github.com/tommy351/hexo/tree/master/lib -[3]: https://github.com/tommy351/hexo-plugins \ No newline at end of file diff --git a/source/zh-CN/docs/render.md b/source/zh-CN/docs/render.md deleted file mode 100644 index 9ad715acfd..0000000000 --- a/source/zh-CN/docs/render.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -layout: page -title: 渲染 -lang: zh-CN -date: 2013-02-18 19:34:41 ---- - -## 使用 - -渲染模组拥有两种方法,**render** 和 **compile**,前者为输入字串后渲染,后者为读取文件后渲染,两种方法都有同步和非同步两种模式。 - -**render(string, engine, [locals], callback)** -**renderSync(string, engine, [locals])** - -- **string** - 输入字串 -- **engine** - 渲染引擎 -- **locals** - 区域变量 -- **callback** - 回传函数 - - **err** - 错误内容 - - **content** - 输出内容 - - **ext** - 输出文件的副文件名 - -**compile(src, locals, callback)** -**compileSync(src, locals)** - -- **src** - 原始文件路径 -- **locals** - 区域变量 -- **callback** - 回传函数 - - **err** - 错误内容 - - **content** - 输出内容 - - **ext** - 输出文件的扩展名 - -### 范例 - -渲染Markdown字串。 - - hexo.render.render('**bold**', 'md', function(err, content, ext){ - // … - }); - -编译EJS样板。 - - hexo.render.compile('layout.ejs', {foo: 1, bar: 2}, function(err, content, ext){ - // … - }); - -## 内建渲染器 - -### EJS - -- 输入文件名:ejs -- 输出文件名:html - -参考: - -- [EJS][1] - -### Markdown - -- 输入文件名:md, markdown, mkd, mkdn, mdwn, mdtxt, mdtext -- 输出文件名:html - -参考: - -- [Marked][2] -- [Markdown][3] - -### Stylus (with Nib) - -- 输入文件名:styl, stylus -- 输出文件名:css - -参考: - -- [Stylus][4] -- [Nib][5] - -### Swig - -- 输入文件名:swig -- 输出文件名:html - -参考: - -- [Swig][6] - -### YAML - -- 输入文件名:yml, yaml -- 输出文件名:json - -参考: - -- [yamljs][7] -- [YAML][8] - -[1]: https://github.com/visionmedia/ejs -[2]: https://github.com/chjj/marked -[3]: http://daringfireball.net/projects/markdown/ -[4]: http://learnboost.github.com/stylus/ -[5]: http://visionmedia.github.com/nib/ -[6]: http://paularmstrong.github.com/swig/ -[7]: https://github.com/jeremyfa/yaml.js -[8]: http://www.yaml.org/ \ No newline at end of file diff --git a/source/zh-CN/docs/scripts.md b/source/zh-CN/docs/scripts.md deleted file mode 100644 index d26d55bc8a..0000000000 --- a/source/zh-CN/docs/scripts.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: page -title: 脚本 -lang: zh-CN -date: 2013-02-18 19:32:35 ---- - -脚本(Script)相较于插件(Plugin),是规模较小且仅有单一文件的扩展程序。 - -## 使用 - -将JavaScript文件放置于`scripts`文件夹,即会自动载入,文件或文件夹名称开头为`_`(点)或`.`(底线)的会被忽略。 - -## 范例 - -文章建立后,自动开启文件。 - -``` -var spawn = require('child_process').spawn; - -hexo.on('newPost', function(){ - spawn('open', [target]); -}); -``` - -## 参考 - -- [全局变量][1] -- [事件][2] - -[1]: global_variables.html -[2]: events.html \ No newline at end of file diff --git a/source/zh-CN/docs/server.md b/source/zh-CN/docs/server.md deleted file mode 100644 index 6675b6c3c8..0000000000 --- a/source/zh-CN/docs/server.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -layout: page -title: 服务器 -lang: zh-CN -date: 2013-02-18 19:31:09 ---- - -## 内建服务器 - -Hexo 使用 [Connect][1] 作为静态文件的服务器。 - -编辑`_config.yml`中的`port`栏位调整服务器的连接端口。 - -``` yaml -port: 4000 -``` - -执行以下命令启动服务器,按下`Ctrl+C`关闭服务器。加入 `-p/--port` 选项设定连接端口。 - -``` bash -hexo server -hexo server -p 12345 -``` - -### 记录器 - -编辑`_config.yml`中的`logger`栏位启动记录器。编辑`logger_format`栏位可调整记录的显示内容,参考 [Connect][4] 以获得更多资讯。 - -``` yaml -logger: true -logger_format: -``` - -## Pow - -[Pow][2] 是由Node.js所建立的Mac环境专用的零配置Rack服务器,不过它也能用于处理一般的静态文件。 - -### 安装 - -执行以下命令即可完成安装。 - -``` bash -curl get.pow.cx | sh -``` - -### 使用 - -在`~/.pow`建立链接即可使用。 - -``` bash -cd ~/.pow -ln -s /path/to/myapp -``` - -完成后,网站即会出现在`http://myapp.dev`,网址根据链接名称而有所不同。 - -参考 [Pow][3] 以获得更多资讯。 - -[1]: https://github.com/senchalabs/connect -[2]: http://pow.cx/ -[3]: http://pow.cx/manual.html -[4]: http://www.senchalabs.org/connect/logger.html \ No newline at end of file diff --git a/source/zh-CN/docs/setup.md b/source/zh-CN/docs/setup.md deleted file mode 100644 index 6d51ae09e0..0000000000 --- a/source/zh-CN/docs/setup.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -layout: page -title: 建立 -lang: zh-CN -date: 2013-02-18 19:12:17 ---- - -安装完成后,在你喜爱的文件夹下,执行以下指令,Hexo 即会自动在目标文件夹建立网站所需要的所有文件。 - -``` bash -hexo init <folder> -``` - -建立完成后,文件夹结构如下: - -``` plain -|-- .gitignore -|-- _config.yml -|-- package.json -|-- public -|-- scaffolds -|-- scripts -|-- source -| |-- _posts - |-- hello-world.md -| |-- _drafts -|-- themes - |-- light -``` - -### _config.yml - -全站的设定文件。 - -### package.json - -应用程式资料。**请勿删除**,若不幸删除,请依照以下内容重建文件。 - -``` json -{ - "name": "hexo", - "version": "0.0.1", - "private": true, - "engines": { - "node": ">0.6.0", - "npm": ">1.1.0" - }, - "dependencies": {} -} -``` - -### public - -静态文件夹。 - -### scaffolds - -[骨架][2] 文件夹。 - -### scripts - -[脚本][3] 文件夹。 - -### source - -在此文件夹内的文件会被处理并另存至`public`文件夹。名称开头为`.`(点)或`_`(底线)的文件或文件夹会被忽略,除了`_posts`文件夹以外。 - -### themes - -主题文件夹。Hexo 的预设主题为 [Light][1]。 - -[1]: https://github.com/tommy351/hexo-theme-light -[2]: writing.html -[3]: scripts.html \ No newline at end of file diff --git a/source/zh-CN/docs/tag-plugins.md b/source/zh-CN/docs/tag-plugins.md deleted file mode 100644 index 59e849be6a..0000000000 --- a/source/zh-CN/docs/tag-plugins.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -layout: page -title: 标签插件 -lang: zh-CN -date: 2013-02-18 19:52:12 ---- - -标签插件(Tag Plugin)与文章中的标签(Tag)不同,标签插件用于在文章内快速加入特定内容。 - -## Block Quote - -插入 Block Quote。 - -{% raw %} -<pre><code>{% blockquote [author[, source]] [link] [source_link_title] %} -content -{% endblockquote %} -</code></pre> -{% endraw %} - -**别名:**`quote` - -[参考][1] - -## Code Block - -插入代码区块。 - -{% raw %} -<pre><code>{% codeblock [title] [lang:language] [url] [link text] %} -content -{% endcodeblock %} -</code></pre> -{% endraw %} - -**别名:**`code` - -[参考][2] - -## Backtick Code Block - -插入代码区块。 - - ``` [language] [title] [url] [link text] - content - ``` - -[参考][3] - -## Pull Quote - -插入 Pull Quote。 - -{% raw %} -<pre><code>{% pullquote [class_name] %} -content -{% endpullquote %} -</code></pre> -{% endraw %} - -[参考][4] - -## jsFiddle - -插入 jsFiddle。 - -{% raw %} -<pre><code>{% jsfiddle shorttag [tabs] [skin] [width] [height] %} -</code></pre> -{% endraw %} - -[参考][5] - -## Gist - -插入 Gist。 - -{% raw %} -<pre><code>{% gist gist_id [filename] %} -</code></pre> -{% endraw %} - -[参考][6] - -## Image Tag - -插入图片。 - -{% raw %} -<pre><code>{% img [class names] /path/to/image [width] [height] [title text [alt text]] %} -</code></pre> -{% endraw %} - -[参考][7] - -## Youtube - -插入 Youtube 影片。 - -{% raw %} -<pre><code>{% youtube video_id %} -</code></pre> -{% endraw %} - -## Vimeo - -插入 Vimeo 影片。 - -{% raw %} -<pre><code>{% vimeo video_id %} -</code></pre> -{% endraw %} - -## Raw - -逃脱处理。(请去掉反斜线) - -{% raw %} -<pre><code>{% raw %} -{% endraw /%} -</code></pre> -{% endraw %} - -[1]: http://octopress.org/docs/plugins/blockquote/ -[2]: http://octopress.org/docs/plugins/codeblock/ -[3]: http://octopress.org/docs/plugins/backtick-codeblock/ -[4]: http://octopress.org/docs/plugins/pullquote/ -[5]: http://octopress.org/docs/plugins/jsfiddle-tag/ -[6]: http://octopress.org/docs/plugins/gist-tag/ -[7]: http://octopress.org/docs/plugins/image-tag/ \ No newline at end of file diff --git a/source/zh-CN/docs/template-data.md b/source/zh-CN/docs/template-data.md deleted file mode 100644 index 68af8efa00..0000000000 --- a/source/zh-CN/docs/template-data.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -layout: page -title: 模板资料 -lang: zh-CN -date: 2013-02-18 19:06:06 ---- - -## 全局 - -- **[site](#site)** - 网站全局资料,由 [Processor][1] 所控制 -- **[page](#page)** - 目前页面的资料,内容根据不同页面而有所差异,由 [Generator][2] 所控制 -- **config** - [全局设定][3],即`_config.yml`的内容 -- **theme** - 主题设定,即主题文件夹内`_config.yml`的内容,根据不同主题而有所差异 -- **__**(双底线) - 取得 [国际化(i18n)][9] 字串 - -<a id="site"></a> -## site - -网站全局资料,在没有挂载其他扩展程序的情况下,**site**拥有以下内容: - -- **posts** - 所有文章,根据发表日期降序排列 -- **pages** - 所有分页,根据发表日期降序排列 -- **categories** - 所有分类,根据字母顺序排列 -- **tags** - 所有标签,根据字母顺序排列 - -**posts**, **pages** 为 [Collection][4] 事件 - -**categories**, **tags** 为 [Taxonomy][5] 事件 - -<a id="page"></a> -## page - -目前页面的资料,内容根据不同页面而有所差异,以下仅列举内建Generator所拥有的page内容。 - -#### page, post - -- **layout** - 文章布局 -- **title** - 文章标题 -- **date** - 文章的发布日期([Moment.js][7] 库) -- **updated** - 文章的更新日期([Moment.js][7] 库) -- **comments** - 开启此文章的留言功能 -- **permalink** - 文章的固定连接 -- **stats** - 文章的文件状态([fs.Stats][8] 类别) -- **content** - 文章内文 -- **excerpt** - 文章摘要(内文中 `<!-- more -->` 之前的内容) -- **source** - 原始文件路径 -- **path** - 文章的相对路径 - -以及使用者在文章设定中所设定的其他变量。 - -page和post的差别不大,仅在于page没有`categories`和`tags`变量。 - -#### index - -- 启用分页功能:[Paginator][6] 事件 -- 关闭分页功能:[Taxonomy][5] 事件 - -#### archive - -- 启用分页功能:[Paginator][6] 事件 -- 关闭分页功能:[Taxonomy][5] 事件 - -以及以下变量: - -- **archive** - 为`true` -- **year** - 年份 -- **month** - 月份 - -#### category - -- 启用分页功能:[Paginator][6] 事件 -- 关闭分页功能:[Taxonomy][5] 事件 - -以及以下变量: - -- **category** - 分类名称 - -#### tag - -- 启用分页功能:[Paginator][6] 事件 -- 关闭分页功能:[Taxonomy][5] 事件 - -以及以下变量: - -- **tag** - 标签名称 - -[1]: plugin-development.html#processor -[2]: plugin-development.html#generator -[3]: configure.html -[4]: collection.html#collection -[5]: collection.html#taxonomy -[6]: collection.html#paginator -[7]: http://momentjs.com/ -[8]: http://nodejs.org/api/fs.html#fs_class_fs_stats -[9]: global-variables.html#i18n \ No newline at end of file diff --git a/source/zh-CN/docs/theme-development.md b/source/zh-CN/docs/theme-development.md deleted file mode 100644 index 26dce6cfd1..0000000000 --- a/source/zh-CN/docs/theme-development.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -layout: page -title: 主题开发 -lang: zh-CN -date: 2013-02-18 18:58:52 ---- - -## 结构 - -``` plain -|-- _config.yml -|-- languages -|-- layout -|-- source -``` - -### _config.yml - -主题的设定文件。 - -参考:[设定][1] - -### languages - -主题的语言文件。 - -参考:[国际化(i18n)][2] - -### layout - -模板文件夹。你可使用 [EJS][4] 或 [Swig][5] 处理模版文件,或安装 [Renderer 插件][8] 以使用你喜爱的样板引擎。 - -基础布局: - -- **archive** - 存档列表,若无此模板则使用 **index** 布局。 -- **category** - 分类,若无此模板则使用 **archive** 布局。 -- **index** - 首页 -- **page** - 分页,若无此模板则使用 **index** 布局。 -- **post** - 文章,若无此模板则使用 **index** 布局。 -- **tag** - 标签,若无此模板则使用 **archive** 布局。 - -你也可以在主题中自定其他布局,例如`link`或`photo`之类的,若找不到自定的布局的话,则会根据 Generator 的不同,使用相对应的布局代替。 - -*(至少要有**index**布局)* - -### source - -源文件,CSS、JavaScript等文件(Asset)应放置于此文件夹。此文件夹内的文件在经过处理后会被复制至`public`文件夹,文件或文件夹名称开头为`.`(点)或`_`(底线)的会被忽略。 - -Hexo 内建 [Stylus][6] 及 [nib][7] 支持,你可安装 [Renderer 插件][8] 让 Hexo 支持更多文件格式。 - -## 参考 - -你可参考预设主题 [Light][3] 来制作主题。 - -[1]: configure.html -[2]: global-variables.html#i18n -[3]: https://github.com/tommy351/hexo-theme-light -[4]: https://github.com/visionmedia/ejs -[5]: http://paularmstrong.github.com/swig/ -[6]: http://learnboost.github.com/stylus/ -[7]: http://visionmedia.github.com/nib/ -[8]: ../plugins/#renderer \ No newline at end of file diff --git a/source/zh-CN/docs/writing.md b/source/zh-CN/docs/writing.md deleted file mode 100644 index b6d6fc8567..0000000000 --- a/source/zh-CN/docs/writing.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -layout: page -title: 写作 -lang: zh-CN -date: 2012-11-01 18:13:30 ---- - -## 基础 - -### 建立 - -执行以下指令。 - -``` bash -hexo new [layout] <title> -``` - -`layout` 参数可忽略,预设为 [全局设定][2] 的 `default_layout` 设定。 - -标题会被转为小写,空白会被转为连字号(-),若目标文件名重复则会在后面加上数字。例如: - -``` -hexo new "New Post" -> source/_posts/new-post.md -hexo new page "New Page" -> source/new-page/index.md -hexo new draft "New Draft" -> source/_drafts/new-draft.md -``` - -### 文件名称 - -你可在 [全局设定][2] 的 `new_post_name` 设定调整新建文件的名称,预设为 `:title.md`。 - -- `:title` - 文章标题(文章的预设网址) -- `:year` - 发表年份(4位数) -- `:month` - 发表月份(2位数) -- `:day` - 发表日期(2位数) - -如果你想要让文章依日期排列,可设定为 `:year-:month-:day-:title.md`。 - -### 设定 - -文章最前面有一段用 `---` 包裹的区块,称为 [YAML Front Matter][1]。你可使用 YAML 格式设定文章。以下是预设内容,你可随自己喜好增减内容。 - -- **layout** - 布局(选填) -- **title** - 标题 -- **date** - 发表日期 -- **updated** - 更新日期(选填) -- **comments** - 留言功能(选填,预设开启) -- **tags** - 标签(选填,不适用于分页) -- **categories** - 分类(选填,不适用于分页) -- **permalink** - 覆写预设网址(选填) - -### 分类 - -分类为文章与 `source/_posts` 的相对位置,具有阶层性。你也可在文件内设定 `categories` 属性,该属性的内容会加入至原本分类的后面。例如: - -- `source/_posts/title.md` - 无分类 -- `source/_posts/Fruits/title.md` - Fruit -- `source/_posts/Fruits/Apple/title.md` - Fruit, Apple - -分类设定: - -``` yaml -# 单一分类 -categories: Fruits - -# 多重分类 -categories: Fruits/Apple - -categories: [Fruits, Apple] - -categories: -- Fruits -- Apple -``` - -### 标签 - -``` yaml -# 单一标签 -tags: Apple - -# 多重标签 -tags: [Apple, Banana] - -tags: -- Apple -- Banana -``` - -## 骨架(Scaffold) - -骨架(Scaffold)为文章的预设模版,新建文章时会根据骨架(Scaffold)内容建立文章。 - -### 范例 - -在 `scaffolds` 文件夹内建立 `photo.md`。 - -{% raw %} -<pre><code>layout: {{ layout }} -title: {{ title }} -date: {{ date }} -tags: ---- -</code></pre> -{% endraw %} - -如此一来,输入 - -``` -hexo new photo "New Gallery" -``` - -就会根据上面的内容建立新文件了。 - -### 使用 - -骨架(Scaffold)使用 Swig 处理,变量以双大括号包裹。以下是变量内容: - -- **layout** - 布局名称 -- **title** - 文章标题 -- **date** - 发表日期 - -[1]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[2]: configure.html \ No newline at end of file diff --git a/source/zh-CN/index.md b/source/zh-CN/index.md deleted file mode 100644 index 1e6aead22e..0000000000 --- a/source/zh-CN/index.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -layout: index -title: Node.js 博客框架 -subtitle: 快速、简单且功能强大的 Node.js 博客框架。 -date: 2013-02-18 19:47:34 -lang: zh-CN ---- - -## 功能 - -- 不可思议的快速 ─ 只要一眨眼静态文件即生成完成 -- 支持 [Markdown][1] -- 仅需一道指令即可部署到 [GitHub Pages][2] 和 [Heroku][3] -- 已移植 [Octopress][4] 插件 -- 高扩展性、自订性 -- 兼容于 Windows, Mac & Linux - -## 安装 - -``` bash -npm install -g hexo -``` - -## 更新 - -``` bash -npm update -g -``` - -## 开始 - -建立项目: - -``` bash -hexo init project -cd project -``` - -建立新文章: - -``` bash -hexo new "New Post" -``` - -生成静态文件: - -``` bash -hexo generate -``` - -启动服务器: - -``` bash -hexo server -``` - -## 下一步 - -有兴趣吗?浏览 [文件][5] 了解如何使用! - -[1]: http://daringfireball.net/projects/markdown/ -[2]: http://pages.github.com/ -[3]: http://heroku.com/ -[4]: http://octopress.org/ -[5]: docs/ \ No newline at end of file diff --git a/source/zh-TW/docs/cli.md b/source/zh-TW/docs/cli.md deleted file mode 100644 index e29efecce3..0000000000 --- a/source/zh-TW/docs/cli.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -layout: page -title: 命令列介面 (CLI) -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -顯示 Hexo 目前的版本號 - -``` plain -hexo version -``` - -建立網站,若`folder`未定義,則Hexo會在目前的資料夾建立網站 - -``` plain -hexo init [folder] -``` - -建立新文章 - -``` plain -hexo new [layout] <title> -``` - -生成靜態檔案,使用`-t`或`--theme`以忽略主題安裝 - -- -d/--deploy:生成後自動佈署 -- -w/--watch:監視檔案變更 - -``` plain -hexo generate -``` - -啟動伺服器,按下`Ctrl+C`停止伺服器 - -- -p/--port:連接埠設定 -- -s/--static:僅處理靜態檔案 - -``` plain -hexo server -``` - -顯示網站設定 - -``` plain -hexo config -``` - -佈署 - -- --setup:只設定不佈署 -- --generate:佈署前先生成檔案 - -``` plain -hexo deploy -``` - -渲染 - -- -o/--output:輸出位置 - -``` plain -hexo render -``` - -安全模式,此模式下外掛不會被載入 - -``` plain -hexo --safe -``` - -除錯模式 - -``` plain -hexo --debug -``` \ No newline at end of file diff --git a/source/zh-TW/docs/collection.md b/source/zh-TW/docs/collection.md deleted file mode 100644 index c0abe86320..0000000000 --- a/source/zh-TW/docs/collection.md +++ /dev/null @@ -1,122 +0,0 @@ ---- -layout: page -title: 集合(Collection) -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -自 1.0 版後,Hexo 採用 [Warehouse][1] 記錄所有資料,[Warehouse][1] 繼承了舊有的部份程式碼,並增加了搜尋功能,效能提昇,更為強大。 - -<a name="model>"></a> -## Model - -Model 為資料的集合。 - -#### get(id1[, id2, ..., idN]) - -取得指定編號的資料。當 `id` 數量大於 1 時返回陣列。 - -#### each(iterator) - -遞迴 Model 內所有項目,執行 `iterator(data, id)`。 - -#### toArray() - -將 Model 轉換為陣列。 - -#### count() - -返回元素數量,相等於 `length`。 - -#### insert(data, callback) - -插入資料至 Model。`data` 可為物件(Object)或陣列(Array),插入完成後,執行回呼函數 `callback(data, id)`。 - -#### update([id, ]data) - -更新資料。`id` 可為數字、陣列,當不指定時會更新 Model 內的所有資料。 - -操作元: - -- **$push** - 對陣列插入元素 -- **$pull** - 從陣列移除元素 -- **$shift** - 刪除陣列前幾個元素 -- **$pop** - 刪除陣列後幾個元素 -- **$addToSet** - 對陣列插入元素(只在元素不存在時) -- **$inc** - 增加數字 -- **$dec** - 減少數字 - -#### replace([id, ]data) - -取代資料。`id` 可為數字、陣列,當不指定時會取代 Model 內的所有資料。 - -#### remove([id1, id2, ..., idN]) - -移除資料。不指定 `id` 時會刪除 Model 內的所有資料。 - -#### destroy() - -從資料庫刪除 Model 的所有資料。 - -#### first() - -取得第一個物件。 - -#### last() - -取得最後一個物件。 - -#### eq(num) - -取得指定位置的物件。 - -#### slice(start[, end]) - -取得特定區段的資料。`start` 和 `end` 可為負數。 - -#### limit(num) - -限制物件數量。 - -#### skip(num) - -省略前幾個物件。 - -#### reverse() - -反轉物件順序。 - -#### sort(orderby[, order]) - -排序物件。`order` 為 `-1` 或 `desc` 時為降冪排列,預設為升冪排列。 - -#### random() - -隨機排序 Model 內的資料。 - -#### find(query) - -尋找資料。 - -操作元: - -- **$lt** - 小於 -- **$lte** - 小於或等於 -- **$gt** - 大於 -- **$gte** - 大於或等於 -- **$length** - 陣列長度 -- **$in** - 陣列內含有指定元素 -- **$nin** - 陣列內不含有指定元素 -- **$all** - 陣列內含有所有指定元素 -- **$exists** - 物件存在 -- **$ne** - 不等於 - -#### findRaw(query) - -根據原始內容,尋找資料。 - -#### findOne(query) - -尋找資料,並只返回第一個物件。 - -[1]: https://github.com/tommy351/warehouse \ No newline at end of file diff --git a/source/zh-TW/docs/configure.md b/source/zh-TW/docs/configure.md deleted file mode 100644 index bfa4f1ad44..0000000000 --- a/source/zh-TW/docs/configure.md +++ /dev/null @@ -1,184 +0,0 @@ ---- -layout: page -title: 設定 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -全域設定檔案儲存於網站根目錄下的`_config.yml`。 - -## 設定 - -### 網站 - -- **title** - 網站標題 -- **subtitle** - 網站副標題 -- **description** - 網站描述 -- **author** - 網站作者 -- **email** - 網站作者的電子信箱位址 -- **language** - 網站使用的語言([IETF 格式][1],例如正體中文為 `zh-TW`) - -### 網址 - -- **url** - 網站網址 -- **root** - 網站的根目錄。假設 `url` 為 `http://yoursite.com/child`,則 `root` 為 `/child/`。 -- **permalink** - 文章的網址格式([設定][2]) -- **tag_dir** - 標籤資料夾 -- **archive_dir** - 網誌彙整資料夾 -- **category_dir** - 分類資料夾 - -### 寫作 - -- **new_post_name** - 新文章的檔案名- 稱([設定][7]) -- **default_layout** - 預設布局 -- **auto_spacing** - 在東方文字與西方文字之間插入空白 -- **titlecase** - 將標題轉為合適的大小寫 -- **max_open_file** - 最大同時處理檔案數量 -- **filename_case** - 轉換檔案名稱為 (1) 小寫 (2) 大寫 -- **highlight** - 程式碼區塊設定 - - **enable** - 啟用程式碼 Highlight - - **backtick_code_block** - 啟用 [Backtick Code Block][6] - - **line_number** - 顯示行號 - - **tab_replace** - 取代 Tab - -### 分類 & 標籤 - -- **default_category** - 預設分類 -- **category_map** - 分類別名 -- **tag_map** - 標籤別名 - -### 網誌彙整 - -`2` - 開啟彙整的分頁功能 -`1` - 關閉彙整的分頁功能 -`0` - 完全關閉 - -- **archive** -- **category** -- **tag** - -### 伺服器 - -- **port** - 伺服器連接埠 -- **logger** - 啟用伺服器記錄 -- **logger_format** - 伺服器記錄的格式([Connect][3]) - -### 日期 / 時間格式 - -Hexo 使用 Moment.js 解析和顯示日期。([Moment.js][4]) - -- **date_format** - 日期格式 -- **time_format** - 時間格式 - -### 分頁 - -- **per_page** - 每頁顯示的文章數量(0 代表關閉分頁功能) -- **pagination_dir** - 分頁資料夾 - -### Disqus - -- **disqus_shortname** - [Disqus][5] 的 Shortname - -### 擴充套件 - -- **themes** - 目前使用的主題 -- **exclude_generator** - 要關閉的 Generator(archive, category, home, page, post, tag) - -### 佈署 - -- **type** - 佈署類型 - -其他設定請依照各個佈署套件調整設定。 - -## 預設值 - -``` yaml -# Hexo Configuration -## Docs: http://zespia.tw/hexo/docs/configure.html -## Source: https://github.com/tommy351/hexo/ - -# Site -title: Hexo -subtitle: -description: -author: John Doe -email: -language: - -# URL -## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' -url: http://yoursite.com -root: / -permalink: :year/:month/:day/:title/ -tag_dir: tags -archive_dir: archives -category_dir: categories - -# Writing -new_post_name: :title.md # File name of new posts -default_layout: post -auto_spacing: false # Add spaces between asian characters and western characters -titlecase: false # Transform title into titlecase -max_open_file: 100 -filename_case: 0 -highlight: - enable: true - backtick_code_block: true - line_number: true - tab_replace: - -# Category & Tag -default_category: uncategorized -category_map: -tag_map: - -# Archives -## 2: Enable pagination -## 1: Disable pagination -## 0: Fully Disable -archive: 2 -category: 2 -tag: 2 - -# Server -## Hexo uses Connect as a server -## You can customize the logger format as defined in -## http://www.senchalabs.org/connect/logger.html -port: 4000 -logger: false -logger_format: - -# Date / Time format -## Hexo uses Moment.js to parse and display date -## You can customize the date format as defined in -## http://momentjs.com/docs/#/displaying/format/ -date_format: MMM D YYYY -time_format: H:mm:ss - -# Pagination -## Set per_page to 0 to disable pagination -per_page: 10 -pagination_dir: page - -# Disqus -disqus_shortname: - -# Extensions -## Plugins: https://github.com/tommy351/hexo/wiki/Plugins -## Themes: https://github.com/tommy351/hexo/wiki/Themes -theme: light -exclude_generator: - -# Deployment -## Docs: http://zespia.tw/hexo/docs/deploy.html -deploy: - type: -``` - -[1]: http://www.w3.org/International/articles/language-tags/ -[2]: permalink.html -[3]: http://www.senchalabs.org/connect/logger.html -[4]: http://momentjs.com/docs/#/displaying/format/ -[5]: http://disqus.com/ -[6]: tag-plugins.html -[7]: writing.html \ No newline at end of file diff --git a/source/zh-TW/docs/contribute.md b/source/zh-TW/docs/contribute.md deleted file mode 100644 index 6cd3564609..0000000000 --- a/source/zh-TW/docs/contribute.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -layout: page -title: 貢獻 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 回報錯誤 - -當你使用Hexo時,如果發現錯誤的話,請在GitHub上回報,如果有任何建議的話,也歡迎提出。 - -你可從GitHub上複製**dev**分支嘗鮮,幾乎每天都有新玩意! - -``` -npm install -g https://github.com/tommy351/hexo/archive/dev.tar.gz -``` - -[回報問題][1] - -## 撰寫文件 - -當發現文件有不足或訛誤時,你可以: - -1. Fork 本專案 -2. 根據 **site** 分支建立新分支 -3. 修改文件 -4. 發送 Pull Request 到 **site** 分支 - -如果想要幫忙翻譯文件,請在`source`文件夾開一個新的資料夾,並將原始檔案複製進去。例如: - -``` plain -zh-TW -|-- docs -|-- index.md -|-- plugins -|-- themes -``` - -並在每個文章新增語言參數,例如: - -``` plain ---- -layout: page -title: 貢獻 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- -``` - -語言碼請依照 [IETF 格式][3] 命名。 - -[原始碼][2] - -## 參與開發 - -如果你想要參與開發,你可以: - -1. Fork 本專案 -2. 開新分支 -3. 新功能開發完成後,發送 Pull Request 到 **dev** 分支 - -如果你開發了很棒的外掛的話,也可以發送 Pull Request,也許你開發的外掛能夠併入主程式! - -[原始碼][4] - -[1]: https://github.com/tommy351/hexo/issues -[2]: https://github.com/tommy351/hexo/tree/site -[3]: http://www.w3.org/International/articles/language-tags/ -[4]: https://github.com/tommy351/hexo \ No newline at end of file diff --git a/source/zh-TW/docs/deploy.md b/source/zh-TW/docs/deploy.md deleted file mode 100644 index 6bf8a3b194..0000000000 --- a/source/zh-TW/docs/deploy.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -layout: page -title: 佈署 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -Hexo 的佈署非常簡單,僅需一個指令即可完成所有設定。 - -## GitHub - -### 設定 - -編輯`_config.yml`。 - -``` yaml -deploy: - type: github - repository: - branch: -``` - -- **repository** - GitHub的Repository網址 -- **branch** - 若 Repository類似`username.github.com`,則填入`master`,否則填入`gh-pages` - -### 佈署 - -靜態檔案生成後,執行下列指令即可完成佈署,或可加入 `--generate` 選項,在佈署前自動生成檔案。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -### 移除 - -執行下列指令移除佈署檔案。 - -``` bash -rm -rf .deploy -``` - -### 自定網域 - -在`source`資料夾內建立名為`CNAME`的檔案,其內容為: - -``` -example.com -``` - -請根據你的網域類型設定DNS。 - -#### 頂級網域 (Top-level domain) - -若網域類似`example.com`,則加入 **A 記錄 (A record)** `204.232.175.78`。 - -#### 子網域 (Subdomain) - -若網域類似`username.example.com`,則加入 **CNAME 記錄 (CNAME record)** `username.github.com`。 - -請參考 [GitHub Pages][1] 以取得更多資訊。 - -## Heroku - -### 設定 - -編輯 `_config.yml`。 - -``` yaml -deploy: - type: heroku - repository: -``` - -- **repository** - Heroku的Repository - -### 佈署 - -靜態檔案生成後,執行下列指令即可完成佈署,或可加入 `--generate` 選項,在佈署前自動生成檔案。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -請參考 [Heroku][2] 以取得更多資訊。 - -### 移除 - -刪除`.git`、`app.js`和`Procfile`即可移除佈署。 - -## Rsync - -### 設定 - -編輯`_config.yml`檔案。 - -``` yaml -deploy: - type: rsync - host: - user: - root: - port: - delete: -``` - -- **host** - 遠端主機的位址 -- **user** - 使用者名稱 -- **root** - 遠端主機的根目錄 -- **port** - 連接埠(預設為`22`) -- **delete** - 刪除遠端主機的舊有檔案(預設為`true`) - -### 佈署 - -靜態檔案生成後,執行下列指令即可完成佈署,或可加入 `--generate` 選項,在佈署前自動生成檔案。 - -``` bash -hexo deploy -hexo deploy --generate -``` - -[1]: https://help.github.com/articles/setting-up-a-custom-domain-with-pages -[2]: https://devcenter.heroku.com/ \ No newline at end of file diff --git a/source/zh-TW/docs/events.md b/source/zh-TW/docs/events.md deleted file mode 100644 index 4f42db7d60..0000000000 --- a/source/zh-TW/docs/events.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -layout: page -title: 事件 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -[全域變數][1] `hexo` 本身是一個 [EventEmitter][2] 物件,你可直接監聽或觸發事件。 - -## 使用 - -監聽事件: - -``` -hexo.on('ready', function(){ - ... -}); -``` - -觸發事件: - -``` -hexo.emit('event', [arg1], [arg2], [….]); -``` - -[參考][2] - -## 預設事件 - -### ready - -設定和所有外掛都載入完畢後。 - -### generateBefore - -開始生成檔案前。 - -### generateAfter - -檔案生成完成後。 - -### processBefore - -開始處理原始檔案前。 - -### processAfter - -原始檔案處理完畢後。 - -### new - -建立新文章後。回傳一個參數 `target`,代表新檔案的絕對路徑。 - -### server - -伺服器開啟後。 - -### exit - -程式結束時。 - -[1]: global-variables.html -[2]: http://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file diff --git a/source/zh-TW/docs/global-variables.md b/source/zh-TW/docs/global-variables.md deleted file mode 100644 index 6070426dc7..0000000000 --- a/source/zh-TW/docs/global-variables.md +++ /dev/null @@ -1,200 +0,0 @@ ---- -layout: page -title: 全域變數 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -Hexo 在初始化時,會建立一個名為`hexo`的命名空間(Namespace),此命名空間內擁有以下唯讀變數。 - -- **base_dir** - 網站根目錄 -- **public_dir** - 靜態檔案目錄(public) -- **source_dir** - 原始檔目錄(source) -- **theme_dir** - 主題目錄(theme/theme_name) -- **plugin_dir** - 外掛目錄(node_modules) -- **script_dir** - 腳本目錄(scripts) -- **scaffold_dir** - 骨架(Scaffold)目錄(scaffolds) -- **core_dir** - 程式根目錄(hexo) -- **lib_dir** - 程式資源庫目錄(hexo/lib) -- **version** - Hexo 版本號 -- **env** - 執行環境 -- **safe** - 安全模式 -- **debug** - 除錯模式 -- **config** - [全域設定][1],即`_config.yml`的內容 -- **render** - [渲染][5] -- **[extend](#extend)** - 擴充功能 -- **[util](#util)** - 工具程式 -- **[i18n](#i18n)** - 國際化(i18n)模組 -- **[route](#route)** - 路由模組 -- **[call](#call)** - 呼叫其他 Console -- **[db](#db)** - 資料庫 - -<a name="extend"></a> -### extend - -extend是負責處理所有擴充套件的模組,每個物件都有兩種方法:**list** 和 **register**,前者可列出該物件所掌管的所有擴充套件,後者可掛載新的擴充套件到該物件上。 - -#### generator - -- **list** - 返回一個陣列(Array) -- **register(fn)** - 掛載擴充套件 - -#### renderer - -- **list** - 返回一個物件(Object),物件內的元素擁有`output`屬性。 -- **register(name, output, fn, sync)** - 掛載擴充套件。`name`為擴充套件的名稱,`output`為輸出後的副檔名,`sync`決定擴充套件是否可同步執行(預設為否)。 - -#### tag - -- **list** - 返回一個物件(Object) -- **register(name, fn, ends)** - 掛載擴充套件。`name`為擴充套件的名稱,`ends`決定該擴充套件是否擁有結尾標籤(End tag),預設為`false` - -#### deployer - -- **list** - 返回一個物件(Object) -- **register(name, fn)** - 掛載擴充套件。`name`為擴充套件的名稱。 - -#### processor - -- **list** - 返回一個陣列(Array) -- **register(rule, fn)** - 掛載擴充套件。`rule`為路徑規則,可為字串(String)或正規表示式(RegExp)。 - -#### helper - -- **list** - 返回一個物件(Object) -- **register(name, fn)** - 掛載擴充套件。`name`為擴充套件的名稱。 - -#### console - -- **list** - 返回一個物件(Object),物件內的元素擁有`description`屬性。 -- **register(name, desc, fn)** - 掛載擴充套件。`name`為擴充套件的名稱,`desc`為擴充套件的描述。 - -#### migrator - -- **list** - 返回一個物件(Object) -- **register(name, fn)** - 掛載擴充套件。`name`為擴充套件的名稱。 - -更多資訊請參考 [外掛開發][2]。 - -<a name="util"></a> -### util - -util為工具程式,包含下列模組: - -#### file - -用以操作檔案,擁有以下方法: - -- **mkdir(dest, callback)** -- **write(dest, content, callback)** -- **copy(src, dest, callback)** -- **dir(src, callback)** -- **read(src, callback)** -- **readSync(src, callback)** -- **empty(target, exclude, callback)** - -#### highlight(string, options) - -用以輸出Highlight程式區塊。以下為選項: - -- **gutter** - 顯示行號 -- **first_line** - 起始行號 -- **lang** - 語言 -- **caption** - 程式區塊說明 - -#### titlecase(string) - -用以將字串轉為適合的標題大小寫。 - -#### yfm(string) - -用以解析 [YAML Front Matter][3],輸出一個物件(Object),本文存放於`_content`屬性。 - -<a name="i18n"></a> -### i18n - -i18n為處理國際化(Internationalization)的模組,使用方式如下: - -``` js -var i18n = new hexo.i18n.i18n(); -``` - -i18n物件擁有以下方法: - -#### get - -第一引數必須為語言檔的鍵值,其後的引數則會使用 [util.format][4] 處理。 - -若第一引數為陣列(Array),則會判斷第二引數的數值來處理複數名詞。 - -- 第一引數擁有2個元素 - - n > 1: 使用第2個元素 - - n <= 1: 使用第1個元素 -- 第一引數擁有3個元素 - - n > 1: 使用第3個元素 - - 0 < n <= 1: 使用第2個元素 - - n == 0: 使用第1個元素 - -#### set(key, value) - -- **key** - 鍵值 -- **value** - 對應值 - -#### list([obj]) - -若`obj`未定義,則傳回物件內的所有數值;若`obj`為一物件(Object),則將物件取代為傳入的引數。 - -#### load(path, callback) - -自動載入語言檔案。`path`為放置語言檔案的資料夾,Hexo會根據`_config.yml`的`language`設定載入相對應的語言檔案,若找不到語言檔案的話,則會載入`default.yml`,因此資料夾內至少要有一個`default.yml`。 - -<a name="route"></a> -### route - -#### get(path) - -取得路徑內容,傳回一個函數。 - -#### set(path, content) - -設定路徑內容。`content`可為函數或其他內容,若為函數則必須使用`function(err, content)`格式。 - -#### format(path) - -處理路徑格式。若路徑為空或結尾為`/`,則在最後加入`index.html`。 - -#### remove(path) - -刪除路徑。 - -#### list() - -返回一個物件(Object)。 - -<a name="call"></a> -### call - -#### call(name, [args], callback) - -- **name** - Console 外掛名稱 -- **args** - 參數 -- **callback** - 回傳函數 - -`call` 是用於呼叫其他 Console 外掛的函數,例如: - -``` js -hexo.call('generate', function(){ - // ... -}); -``` - -<a name="db"></a> -### db - -資料庫。 - -[1]: configure.html -[2]: plugin-development.html -[3]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[4]: http://nodejs.org/api/util.html#util_util_format_format -[5]: render.html \ No newline at end of file diff --git a/source/zh-TW/docs/helpers.md b/source/zh-TW/docs/helpers.md deleted file mode 100644 index e87f05b044..0000000000 --- a/source/zh-TW/docs/helpers.md +++ /dev/null @@ -1,561 +0,0 @@ ---- -layout: page -title: 輔助方法 (Helper) -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -輔助方法(Helper)為樣板中所使用的輔助方法,可將資料轉換為 HTML 字串,使主題開發更加容易。以下是內建的輔助方法: - -### css - -載入 CSS 檔案。`path` 可為陣列或字串。 - -``` -<%- css(path) %> -``` - -**範例:** - -``` js -<%- css('style.css') %> -// <link rel="stylesheet" href="style.css" type="text/css"> - -<%- css(['style.css', 'screen.css']) %> -// <link rel="stylesheet" href="style.css" type="text/css"> -// <link rel="stylesheet" href="screen.css" type="text/css"> -``` - -### js - -載入 JavaScript 檔案。`path` 可為陣列或字串。 - -``` -<%- js(path) %> -``` - -**範例:** - -``` js -<%- js('script.js') %> -// <script type="text/javascript" src="script.js"></script> - -<%- js(['script.js', 'gallery.js']) %> -// <script type="text/javascript" src="script.js"></script> -// <script type="text/javascript" src="gallery.js"></script> -``` - -### gravatar - -載入 Gravatar。 - -``` -<%- gravatar(email, [size]) %> -``` - -**範例:** - -``` js -<%- gravatar('a@abc.com') %> -// http://www.gravatar.com/avatar/b9b00e66c6b8a70f88c73cb6bdb06787 - -<%- gravatar('a@abc.com', 40) %> -// http://www.gravatar.com/avatar/b9b00e66c6b8a70f88c73cb6bdb06787?s=40 -``` - -### trim - -清除字串內的空白。 - -``` -<%- trim(string) %> -``` - -### strip_html - -清除字串內的所有 HTML 標籤。 - -``` -<%- strip_html(string) %> -``` - -**範例:** - -``` js -<%- strip_html('It's not <b>important</b> anymore!') %> -// It's not important anymore! -``` - -### titlecase - -將字串轉為合適的標題大小寫。 - -``` -<%- titlecase(string) %> -``` - -**範例:** - -``` js -<%- titlecase('this is an apple') %> -# This is an Apple -``` - -### partial - -載入其他樣版。`layout`為樣版的相對路徑;可使用`locals`指定區域變數。(使用方法與 [express-partials][1] 相同) - -``` -<%- partial(layout, [locals]) %> -``` - -### tagcloud - -插入標籤雲(Tag Cloud)。`options`詳見下方。 - -``` -<%- tagcloud([options]) %> -``` - -**選項:** - -- **min_font** - 最小的字體大小 -- **max_font** - 最大的字體大小 -- **unit** - 字體單位 -- **amount** - 標籤數量 -- **orderby** - 排列順序 -- **order** - 排列方式。`1`, `asc`代表升冪排列,`-1`, `desc`代表降冪排列,`rand`, `random`代表隨機排列。 - -**預設值:** - -``` json -{ - "min_font": 10, - "max_font": 20, - "unit": "px", - "amount": 40, - "orderby": "name", - "order": 1 -} -``` - -### paginator - -插入翻頁導航(Paginator)。`options`詳見下方。 - -``` -<%- paginator(options) %> -``` - -**選項:** - -- **base** - 基礎網址 -- **format** - 網址格式 -- **total** - 總頁數 -- **current** - 目前頁數 -- **prev_text** - 上一頁文字 -- **next_text** - 下一頁文字 -- **space** - 間隔 -- **prev_next** - 顯示上一頁和下一頁連結 -- **end_size** - 開頭和尾端顯示的分頁數量 -- **mid_size** - 目前頁面周圍顯示的分頁數量 -- **show_all** - 顯示所有分頁 - -**預設值:** - -``` json -{ - "base": "/", - "format": "page/%d/", - "total": 1, - "current": 0, - "prev_text": "Prev", - "next_text": "Next", - "space": "&hellp;", - "prev_next": true, - "end_size": 1, - "mid_size": 2, - "show_all": false -} -``` - -### date - -顯示日期。`date` 為 Date 物件,`format` 為輸出格式,預設為 [全域設定][4] 中的 `date_format`。 - -``` -<%- date(date, [format]) %> -``` - -**範例:** - -``` js -<%- date(new Date()) %> -// Jan 1, 2013 - -<%- date(new Date(), 'YYYY/M/D') %> -// 2013/1/1 -``` - -### date_xml - -顯示 XML 格式的日期。`date` 為 Date 物件。 - -``` -<%- date_xml(date) %> -``` - -**範例:** - -``` js -<%- date_xml(new Date()) %> -// 2013-01-01T00:00:00.000Z -``` - -### time - -顯示時間。`date` 為 Date 物件,`format` 為輸出格式,預設為 [全域設定][4] 中的 `time_format`。 - -``` -<%- time(date, [format]) %> -``` - -**範例:** - -``` js -<%- time(new Date()) %> -// 13:05:12 - -<%- time(new Date(), 'h:mm:ss a') %> -// 1:05:12 pm -``` - -### full_date - -顯示完整日期。`date` 為 Date 物件,`format` 為輸出格式,預設為 [全域設定][4] 中的 `date_format` 加上 `time_format`。 - -``` -<%- full_date(date, [format]) %> -``` - -**範例:** - -``` js -<%- full_date(new Date()) %> -// Jan 1, 2013 0:00:00 - -<%- full_date(new Date(), 'dddd, MMMM Do YYYY, h:mm:ss a') %> -// Tuesday, January 1st 2013, 12:00:00 am -``` - -### moment - -[Moment.js](http://momentjs.com/) - -### search_form - -Google 搜尋表單。`options` 詳見下方。 - -``` -<%- search_form(options) %> -``` - -**選項:** - -- **class** - 表單 Class Name -- **text** - 搜尋提示文字 -- **button** - 顯示搜尋按鈕。數值可為布林值(Boolean)或字串,數值為字串時即是搜尋按鈕的文字。 - -**預設值:** - -``` json -{ - "class": "search-form", - "text": "Search", - "button": false -} -``` - -### markdown - -使用 Markdown 渲染字串。 - -``` -<%- markdown(str) %> -``` - -**範例:** - -``` js -<%- markdown('make me **strong**') %> -// make me <strong>strong</strong> -``` - -### word_wrap - -使字串每一固定長度換行。`length` 預設為 80。 - -``` -<%- word_wrap(str, [length]) %> -``` - -**範例:** - -``` -<%- word_wrap('Once upon a time', 8) %> -// Once upon\n a time -``` - -### truncate - -截取字串中的前幾個字元。 - -``` -<%- truncate(str, length) %> -``` - -**範例:** - -``` js -<%- truncate('Once upon a time in a world far far away', 16) %> -// Once upon a time -``` - -### truncate_words - -截取字串中的前幾個單字。 - -``` -<%- truncate_words(str, length) %> -``` - -**範例:** - -``` js -<%- truncate_words('Once upon a time in a world far far away', 4) %> -// Once upon a time -``` - -### is_current - -判斷是否為目前頁面。 - -``` -<%- is_current(path) %> -``` - -### is_home - -判斷目前頁面是否為首頁。 - -``` -<%- is_home() %> -``` - -### is_post - -判斷目前頁面是否為文章。 - -``` -<%- is_post() %> -``` - -### is_archive - -判斷目前頁面是否為彙整。 - -``` -<%- is_archive() %> -``` - -### is_year - -判斷目前頁面是否為年份彙整。 - -``` -<%- is_year() %> -``` - -### is_month - -判斷目前頁面是否為月份彙整。 - -``` -<%- is_month() %> -``` - -### is_category - -判斷目前頁面是否為分類頁面。 - -``` -<%- is_category() %> -``` - -### is_tag - -判斷目前頁面是否為標籤頁面。 - -``` -<%- is_tag() %> -``` - -### link_to - -插入超連結。`path` 為連結目標,`text` 為連結文字,`external` 為是否在新視窗開啟。 - -``` -<%- link_to(path, [text], [external]) %> -``` - -**範例:** - -``` js -<%- link_to('http://www.google.com') %> -// <a href="http://www.google.com" title="http://www.google.com">http://www.google.com</a> - -<%- link_to('http://www.google.com', 'Google') %> -// <a href="http://www.google.com" title="Google">Google</a> - -<%- link_to('http://www.google.com', 'Google', true) %> -// <a href="http://www.google.com" title="Google" target="_blank" rel="external">Google</a> -``` - -### mail_to - -插入電子信箱連結。`path` 為連結目標,`text` 為連結文字。 - -``` -<%- mail_to(path, [text]) %> -``` - -**範例:** - -``` js -<%- mail_to('a@abc.com') %> -// <a href="mailto:a@abc.com" title="a@abc.com">a@abc.com</a> - -<%- mail_to('a@abc.com', 'Email') %> -// <a href="mailto:a@abc.com" title="Email">Email</a> -``` - -### list_categories - -插入分類列表。`options` 詳見下方。 - -``` -<%- list_categories([options]) %> -``` - -**選項:** - -- **orderby** - 排序依據 -- **order** - 排列順序。`1`, `asc`代表升冪排列,`-1`, `desc`代表降冪排列。 -- **show_count** - 顯示文章數目 - -**預設值:** - -``` json -{ - "orderby": "name", - "order": 1, - "show_count": true -} -``` - -### list_tags - -插入標籤列表。`options` 詳見下方。 - -``` -<%- list_tags([options]) %> -``` - -**選項:** - -- **orderby** - 排序依據 -- **order** - 排列順序。`1`, `asc`代表升冪排列,`-1`, `desc`代表降冪排列。 -- **show_count** - 顯示文章數目 - -**預設值:** - -``` json -{ - "orderby": "name", - "order": 1, - "show_count": true -} -``` - -### list_archives - -插入彙整列表。`options` 詳見下方。 - -``` -<%- list_archives([options]) %> -``` - -**選項:** - -- **type** - 類型。`yearly` 表示年份彙整,`monthly` 表示月份彙整。預設為 `monthly`。 -- **order** - 排列順序。`1`, `asc`代表升冪排列,`-1`, `desc`代表降冪排列。 -- **show_count** - 顯示文章數目 -- **format** - 日期格式。預設為 `MMMM YYYY`。(設定詳見 [Moment.js][5]) - -**預設值:** - -``` json -{ - "type": "monthly", - "order": 1, - "show_count": true, - "format": "MMMM YYYY" -} -``` - -### number_format - -格式化文字。`options` 詳見下方。 - -<%- number_format(num, options) %> - -**選項:** - -- **precision** - 捨去小數點位數。數值可為 `false` 或非負整數。 -- **delimiter** - 千位分隔符號 -- **separator** - 整數與分數的分隔符號 - -**預設值:** - -``` json -{ - "precision": false, - "delimiter": ",", - "separator": "." -} -``` - -**範例:** - -``` js -<%- number_format(12345.67, {precision: 1}) %> -// 12,345.68 - -<%- number_format(12345.67, {precision: 4}) %> -// 12,345.6700 - -<%- number_format(12345.67, {precision: 0}) %> -// 12,345 - -<%- number_format(12345.67, {delimiter: ''}) %> -// 12345.67 - -<%- number_format(12345.67, {separator: '/'}) %> -// 12,345/67 -``` - -[1]: https://github.com/publicclass/express-partials -[2]: render.html -[3]: template-data.html -[4]: configure.html -[5]: http://momentjs.com/docs/#/displaying/format/ \ No newline at end of file diff --git a/source/zh-TW/docs/index.md b/source/zh-TW/docs/index.md deleted file mode 100644 index e6d3aa13f7..0000000000 --- a/source/zh-TW/docs/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -layout: page -title: 文件 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 開始 - -#### [安裝](install.html) - -#### [建立](setup.html) - -#### [設定](configure.html) - -#### [佈署](deploy.html) - -#### [遷移](migrate.html) - -## 使用 - -#### [寫作](writing.html) - -#### [標籤外掛](tag-plugins.html) - -#### [伺服器](server.html) - -#### [永久連結](permalink.html) - -#### [腳本](scripts.html) - -#### [命令列介面 (CLI)](cli.html) - -## 開發 - -#### [全域變數](global-variables.html) - -#### [樣版資料](template-data.html) - -#### [輔助方法 (Helper)](helpers.html) - -#### [集合 (Collection)](collection.html) - -#### [事件](events.html) - -#### [渲染](render.html) - -#### [主題開發](theme-development.html) - -#### [外掛開發](plugin-development.html) - -#### [貢獻](contribute.html) \ No newline at end of file diff --git a/source/zh-TW/docs/install.md b/source/zh-TW/docs/install.md deleted file mode 100644 index e765e707a1..0000000000 --- a/source/zh-TW/docs/install.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -layout: page -title: 安裝 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -在安裝 Hexo 之前,必須先安裝 [Git][2] 和 [Node.js][1]。 - -## 目錄 - -- [Windows](#windows) -- [Mac](#mac) -- [Linux](#linux) - -<a id="windows"></a> -## Windows - -### Git - -下載 [msysgit][7] 並執行即可完成安裝。 - -### Node.js - -在 Windows 環境下安裝 Node.js 非常簡單,僅須 [下載][1] 安裝檔案並執行即可完成安裝。 - -### Hexo - -利用 [npm][3] 即可安裝。 - -``` bash -npm install -g hexo -``` - -<a id="mac"></a> -## Mac - -### Git - -Mac 已內建 Git,雖然版本較舊,不過還是能用,如果你想要使用較新版的 Git 的話,可參考以下方式安裝。 - -1. 使用 [Homebrew][5]。 - - brew install git - -2. 使用 [MacPorts][6]。 - - sudo port install git-core - -3. 使用 [安裝程式][8]。 - -如果出現錯誤情況,可能是尚未安裝編譯工具,請至 App Store 下載 Xcode。 - -### Node.js - -Mac 環境下有很多安裝方式可供選擇,以下使用 [nvm][4] 來安裝。 - -執行以下指令。 - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -安裝完畢後,在`~/.bash_profile`或`~/.bashrc`加入以下內容並重開一個新的終端機視窗。 - -``` bash -. ~/nvm/nvm.sh -``` - -之後即可使用 [nvm][4] 來安裝 Node.js 了,編譯可能需要花些時間,請耐心等候。 - -``` bash -nvm install 0.8 -``` - -### Hexo - -利用 [npm][3] 即可安裝。 - -``` bash -npm install -g hexo -``` - -<a id="linux"></a> -## Linux - -### Git - -**Ubuntu, Debian:** - -``` bash -sudo apt-get install git-core -``` - -**Fedora, Red Hat, CentOS:** - -``` bash -sudo yum install git-core -``` - -### Node.js - -Linux 環境下有很多安裝方式可供選擇,以下使用 [nvm][4] 來安裝。 - -執行以下指令。 - -``` bash -git clone git://github.com/creationix/nvm.git ~/nvm -``` - -安裝完畢後,在`~/.bash_profile`或`~/.bashrc`加入以下內容並重開一個新的終端機視窗。 - -``` plain -. ~/nvm/nvm.sh -``` - -之後即可使用 [nvm][4] 來安裝 Node.js 了,編譯可能需要花些時間,請耐心等候。 - -``` bash -nvm install 0.8 -``` - -### Hexo - -利用 [npm][3] 即可安裝。 - -``` bash -npm install -g hexo -``` - -[1]: http://nodejs.org/ -[2]: http://git-scm.com/ -[3]: http://npmjs.org/ -[4]: https://github.com/creationix/nvm -[5]: http://mxcl.github.com/homebrew/ -[6]: http://www.macports.org/ -[7]: http://code.google.com/p/msysgit/ -[8]: http://code.google.com/p/git-osx-installer/ \ No newline at end of file diff --git a/source/zh-TW/docs/migrate.md b/source/zh-TW/docs/migrate.md deleted file mode 100644 index 9ec5346723..0000000000 --- a/source/zh-TW/docs/migrate.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -layout: page -title: 遷移 -lang: zh-TW -date: 2012-11-15 18:13:30 ---- - -## 目錄 - -- [RSS](#rss) -- [Jekyll / Octopress](#jekyll) -- [WordPress](#wordpress) - -<a id="rss"></a> -## RSS - -首先,執行以下指令安裝 RSS Migrator 外掛,並在`_config.yml`中的`plugins`欄位加入`hexo-migrator-rss`。 - -``` plain -npm install hexo-migrator-rss -``` - -安裝完畢後,執行以下指令即可,`source`參數可為檔案路徑或網址。 - - hexo migrate rss <source> - -<a id="jekyll"></a> -## Jekyll / Octopress - -將`source/_posts`內的檔案拷貝至Hexo的`source/_posts`內,並將文章內的`categories`屬性修改為`tags`。 - -然後調整 `_config.yml` 中的 `new_post_name` 為 `:year-:month-:day-:title.md`。 - -<a id="wordpress"></a> -## WordPress - -首先,執行以下指令安裝 WordPress Migrator 外掛,並在`_config.yml`中的`plugins`欄位加入`hexo-migrator-wordpress`。 - -``` plain -npm install hexo-migrator-wordpress -``` - -安裝完畢後,執行以下指令即可,`source`參數可為檔案路徑或網址。 - - hexo migrate wordpress <source> \ No newline at end of file diff --git a/source/zh-TW/docs/permalink.md b/source/zh-TW/docs/permalink.md deleted file mode 100644 index 79a538f41e..0000000000 --- a/source/zh-TW/docs/permalink.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -layout: page -title: 永久連結 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 設定 - -在`_config.yml`中的`permalink`欄位設定文章連結,預設值為: - -``` plain -permalink: :year/:month/:day/:title/ -``` - -在永久連結中可加入以下變數,變數名稱前必須擁有`:`才有效。 - -- **year** - 4位數的年份 -- **month** - 2位數的月份 -- **day** - 2位數的日期 -- **title** - 文章的檔案名稱 -- **category** - 文章的分類(對於`source/_posts`的相對路徑),若文章無分類,則為`_config.yml`中的`category_dir`欄位 - -*(日期以文章設定中的日期為基準)* - -## 舉例 - -假設有一文章名為`title.md`,放置於`source/_posts/foo/bar`資料夾,內容為: - -``` plain ---- -title: Post Title -date: 2012-10-09 14:09:37 -tags: -- Node.js -- JavaScript ---- -``` - -則結果會是: - -``` plain -:year/:month/:day/:title/ => /2012/10/09/title/ -:year-:month-:day/:title/ => /2012-10-09/title/ -:category/:title/ => /foo/bar/title/ -``` \ No newline at end of file diff --git a/source/zh-TW/docs/plugin-development.md b/source/zh-TW/docs/plugin-development.md deleted file mode 100644 index f944630a40..0000000000 --- a/source/zh-TW/docs/plugin-development.md +++ /dev/null @@ -1,269 +0,0 @@ ---- -layout: page -title: 外掛開發 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -外掛分為以下八種類型: - -- [Generator](#generator) - 生成靜態檔案 -- [Renderer](#renderer) - 渲染檔案 -- [Helper](#helper) - 樣板輔助方法 -- [Deployer](#deployer) - 佈署工具 -- [Processor](#processor) - 處理原始檔案 -- [Tag](#tag) - 文章標籤 -- [Console](#console) - 命令列介面(CLI) -- [Migrator](#migrator) - 遷移工具 - -<a name="generator"></a> -## Generator - -### 語法 - -``` js -hexo.extend.generator.register(fn); -``` - -- **fn(locals, render, callback)** - - **locals** - [網站全域資料][1] - - **render(path, layout, locals)** - 渲染函數 - - **path** - 路徑 - - **layout** - 要使用的樣板 - - **locals** - 傳入樣板的資料,即樣板中的`page`變數 - - **callback** - 回傳函數 - -### 範例 - -在`public/archive.html`生成文章彙整頁面。 - -``` js -hexo.extend.generator.register(function(locals, render, callback){ - render('archive.html', ['archive', 'index'], locals); - callback(); -}); -``` - -<a name="renderer"></a> -## Renderer - -### 語法 - -``` js -hexo.extend.renderer.register(name, output, fn, [sync]); -``` - -- **name** - 輸入檔案的副檔名(小寫,不包含`.`) -- **output** - 輸出檔案的副檔名(小寫,不包含`.`) -- **fn** - 見下方 -- **sync** - 同步模式,預設為`false` - -`fn(data[, options], callback)` - -- **data** - 輸入資料,包含以下內容 - - **path** - 原始檔案路徑 - - **text** - 檔案內容 -- **options** - 選項 -- **callback** - 回傳函數,僅限於非同步模式 - -### 範例 - -#### 同步模式 - -``` js -var ejs = require('ejs'); - -hexo.extend.renderer.register('ejs', 'html', function(data, options){ - options.filename = data.path; - return ejs.render(data.text, options); -}, true); -``` - -#### 非同步模式 - -``` js -var stylus = require('stylus'); - -hexo.extend.renderer.register('styl', 'css', function(data, callback){ - stylus(data.text).set('filename', data.path).render(callback); -}); -``` - -<a name="helper"></a> -## Helper - -### 語法 - -``` js -hexo.extend.helper.register(); -``` - -### 舉例 - -插入 JavaScript 檔案。 - -``` js -hexo.extend.helper.register('js', function(path){ - return '<script type="text/javascript" src="' + path + '"></script>'; -}); -``` - -輸入: - -``` -<%- js('script.js') %> -``` - -輸出: - -``` html -<script type="text/javascript" src="script.js"></script> -``` - -<a name="deployer"></a> -## Deployer - -### 語法 - -``` js -hexo.extend.deployer.register(name, fn); -``` - -- **name** - 名稱(小寫) -- **fn(args)** - - **args** - 引數 - -### 範例 - -``` js -hexo.extend.deployer.register('github', function(args){ - // ... -}); -``` - -<a name="processor"></a> -## Processor - -### 語法 - -``` js -hexo.extend.processor.register(fn); -``` - -- **fn(locals, callback)** - - **locals** - [網站全域資料][1] - - **callback(err, locals)** - - **err** - 錯誤內容,當無錯誤時請返回`null` - - **locals** - 處理後的資料 - -### 範例 - -根據日期降冪排列文章。 - -``` js -hexo.extend.processor.register(function(locals, callback){ - locals.posts = locals.posts.sort('date', -1); - locals.pages = locals.pages.sort('date', -1); - callback(null, locals); -}); -``` - -<a name="tag"></a> -## Tag - -### 語法 - -``` js -hexo.extend.tag.register(name, fn, [ends]); -``` - -- **name** - 名稱(小寫) -- **fn(args, content)** - - **args** - 引數 - - **content** - 內容 -- **ends** - 結尾標籤 - -### 範例 - -插入Youtube影片。 - -``` js -hexo.extend.tag.register('youtube', function(args, content){ - var id = args[0]; - return '<div class="video-container"><iframe width="560" height="315" src="http://www.youtube.com/embed/' + id + '" frameborder="0" allowfullscreen></iframe></div>'; -}); -``` - -插入 Pull Quote - -``` js -hexo.extend.tag.register('pullquote', function(args, content){ - var className = args.length ? ' ' + args.join(' ') : ''; - return '<blockquote class="pullquote' + className + '">' + content + '</blockquote>'; -}, true); -``` - -<a name="console"></a> -## Console - -### 語法 - -``` js -hexo.extend.console.register(name, desc, [options], fn); -``` - -- **name** - 名稱(小寫) -- **desc** - 描述 -- **options** - 選項(見下方) -- **fn(args)** - - **args** - 引數 - -### 選項 - -- **init** - 未初始化時顯示 -- **debug** - 除錯模式時顯示 - -### 範例 - -執行以下指令時顯示網站設定。 - -``` bash -hexo config -``` - -``` js -hexo.extend.console.register('config', 'Display configuration', function(args){ - console.log(hexo.config); -}); -``` - -<a name="migrator"></a> -## Migrator - -### 語法 - -``` js -hexo.extend.migrator.register(name, fn); -``` - -- **name** - 名稱(小寫) -- **fn(args)** - - **args** - 引數 - -## 發佈 - -在發佈之前,別忘了先測試。將外掛複製至`node_modules`資料夾內,安裝相依性模組後,試著實際使用,或進行單元測試。 - -當一切測試結束後,執行以下指令,將外掛發佈至 NPM。 - -``` -npm publish -``` - -## 參考 - -你可參考 [內建模組][2] 和 [官方外掛][3] 的原始碼來製作外掛。 - -[1]: template-data.html#site -[2]: https://github.com/tommy351/hexo/tree/master/lib -[3]: https://github.com/tommy351/hexo-plugins \ No newline at end of file diff --git a/source/zh-TW/docs/render.md b/source/zh-TW/docs/render.md deleted file mode 100644 index 50589b4632..0000000000 --- a/source/zh-TW/docs/render.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -layout: page -title: 渲染 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 使用 - -#### render(data, [options], callback) - -- **data** - 輸入資料 - - **path** - 路徑 - - **text** - 字串 - - **engine** - 渲染引擎(預設為`path`的副檔名,`path`未定義則此為必填項目) -- **options** - 選項 -- **callback** - 回呼函數 - -#### renderSync(data, [options]) - -同步模式的 `render`. - -#### renderFile(path, [options], callback) - -- **path** - 路徑 -- **options** - 選項 - - **cache** - 快取 - - **layout** - 布局 -- **callback** - 回呼函數 - -### 範例 - -``` js -hexo.render.render({path: layout.ejs}, function(err, content){ - // ... -}); -``` - -## 內建渲染器 - -### EJS - -- 輸入檔名:ejs -- 輸出檔名:html - -參考: - -- [EJS][1] - -### Markdown - -- 輸入檔名:md, markdown, mkd, mkdn, mdwn, mdtxt, mdtext -- 輸出檔名:html - -參考: - -- [Marked][2] -- [Markdown][3] - -### Stylus (with Nib) - -- 輸入檔名:styl, stylus -- 輸出檔名:css - -參考: - -- [Stylus][4] -- [Nib][5] - -### Swig - -- 輸入檔名:swig -- 輸出檔名:html - -參考: - -- [Swig][6] - -### YAML - -- 輸入檔名:yml, yaml -- 輸出檔名:json - -參考: - -- [yamljs][7] -- [YAML][8] - -[1]: https://github.com/visionmedia/ejs -[2]: https://github.com/chjj/marked -[3]: http://daringfireball.net/projects/markdown/ -[4]: http://learnboost.github.com/stylus/ -[5]: http://visionmedia.github.com/nib/ -[6]: http://paularmstrong.github.com/swig/ -[7]: https://github.com/jeremyfa/yaml.js -[8]: http://www.yaml.org/ \ No newline at end of file diff --git a/source/zh-TW/docs/scripts.md b/source/zh-TW/docs/scripts.md deleted file mode 100644 index fe0597e444..0000000000 --- a/source/zh-TW/docs/scripts.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: page -title: 腳本 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -腳本(Script)相較於外掛(Plugin),是規模較小且僅有單一檔案的擴充元件。 - -## 使用 - -將JavaScript檔案放置於`scripts`資料夾,即會自動載入,檔案或資料夾名稱開頭為`_`(點)或`.`(底線)的會被忽略。 - -## 範例 - -文章建立後,自動開啟檔案。 - -``` -var spawn = require('child_process').spawn; - -hexo.on('new', function(){ - spawn('open', [target]); -}); -``` - -## 參考 - -- [全域變數][1] -- [事件][2] - -[1]: global_variables.html -[2]: events.html \ No newline at end of file diff --git a/source/zh-TW/docs/server.md b/source/zh-TW/docs/server.md deleted file mode 100644 index 61011d272d..0000000000 --- a/source/zh-TW/docs/server.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -layout: page -title: 伺服器 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 內建伺服器 - -Hexo 使用 [Connect][1] 作為靜態檔案的伺服器。 - -編輯`_config.yml`中的`port`欄位調整伺服器的連接埠。 - -``` yaml -port: 4000 -``` - -執行以下命令啟動伺服器,按下`Ctrl+C`關閉伺服器。 - -**選項**: - -- **-p/--port**:連接埠 -- **-s/--static**:僅處理靜態檔案 - -``` bash -hexo server -hexo server -p 12345 -``` - -### 記錄器 - -編輯`_config.yml`中的`logger`欄位啟動記錄器。編輯`logger_format`欄位可調整記錄的顯示內容,參考 [Connect][4] 以獲得更多資訊。 - -``` yaml -logger: true -logger_format: -``` - -## Pow - -[Pow][2] 是由Node.js所建立的Mac環境專用的零配置Rack伺服器,不過它也能用於處理一般的靜態檔案。 - -### 安裝 - -執行以下命令即可完成安裝。 - -``` bash -curl get.pow.cx | sh -``` - -### 使用 - -在`~/.pow`建立連結即可使用。 - -``` bash -cd ~/.pow -ln -s /path/to/myapp -``` - -完成後,網站即會出現在`http://myapp.dev`,網址根據連結名稱而有所不同。 - -參考 [Pow][3] 以獲得更多資訊。 - -[1]: https://github.com/senchalabs/connect -[2]: http://pow.cx/ -[3]: http://pow.cx/manual.html -[4]: http://www.senchalabs.org/connect/logger.html \ No newline at end of file diff --git a/source/zh-TW/docs/setup.md b/source/zh-TW/docs/setup.md deleted file mode 100644 index dda233362f..0000000000 --- a/source/zh-TW/docs/setup.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -layout: page -title: 建立 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -安裝完成後,在你喜愛的資料夾下,執行以下指令,Hexo 即會自動在目標資料夾建立網站所需要的所有檔案。 - -``` bash -hexo init <folder> -``` - -建立完成後,資料夾結構如下: - -``` plain -|-- .gitignore -|-- _config.yml -|-- package.json -|-- public -|-- scaffolds -|-- scripts -|-- source -| |-- _posts - |-- hello-world.md -| |-- _drafts -|-- themes - |-- light -``` - -### _config.yml - -全域的設定檔案。 - -### package.json - -應用程式資料。**請勿刪除**,若不幸刪除,請依照以下內容重建檔案。 - -``` json -{ - "name": "hexo", - "version": "0.0.1", - "private": true, - "engines": { - "node": ">0.6.0", - "npm": ">1.1.0" - }, - "dependencies": {} -} -``` - -### public - -靜態檔案資料夾。 - -### scaffolds - -[骨架][2] 資料夾。 - -### scripts - -[腳本][3] 資料夾。 - -### source - -在此資料夾內的檔案會被處理並另存至`public`資料夾。名稱開頭為`.`(點)或`_`(底線)的檔案或資料夾會被忽略,除了`_posts`資料夾以外。 - -### themes - -主題資料夾。Hexo 的預設主題為 [Light][1]。 - -[1]: https://github.com/tommy351/hexo-theme-light -[2]: writing.html -[3]: scripts.html \ No newline at end of file diff --git a/source/zh-TW/docs/tag-plugins.md b/source/zh-TW/docs/tag-plugins.md deleted file mode 100644 index 5ab0896b82..0000000000 --- a/source/zh-TW/docs/tag-plugins.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -layout: page -title: 標籤外掛 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -標籤外掛(Tag Plugin)與文章中的標籤(Tag)不同,標籤外掛用於在文章內快速加入特定內容。 - -## Block Quote - -插入 Block Quote。 - -{% raw %} -<pre><code>{% blockquote [author[, source]] [link] [source_link_title] %} -content -{% endblockquote %} -</code></pre> -{% endraw %} - -**別名:**`quote` - -[參考][1] - -## Code Block - -插入程式碼區塊。 - -{% raw %} -<pre><code>{% codeblock [title] [lang:language] [url] [link text] %} -content -{% endcodeblock %} -</code></pre> -{% endraw %} - -**別名:**`code` - -[參考][2] - -## Backtick Code Block - -插入程式碼區塊。 - - ``` [language] [title] [url] [link text] - content - ``` - -[參考][3] - -## Pull Quote - -插入 Pull Quote。 - -{% raw %} -<pre><code>{% pullquote [class_name] %} -content -{% endpullquote %} -</code></pre> -{% endraw %} - -[參考][4] - -## jsFiddle - -插入 jsFiddle。 - -{% raw %} -<pre><code>{% jsfiddle shorttag [tabs] [skin] [width] [height] %} -</code></pre> -{% endraw %} - -[參考][5] - -## Gist - -插入 Gist。 - -{% raw %} -<pre><code>{% gist gist_id [filename] %} -</code></pre> -{% endraw %} - -[參考][6] - -## Image Tag - -插入圖片。 - -{% raw %} -<pre><code>{% img [class names] /path/to/image [width] [height] [title text [alt text]] %} -</code></pre> -{% endraw %} - -[參考][7] - -## Youtube - -插入 Youtube 影片。 - -{% raw %} -<pre><code>{% youtube video_id %} -</code></pre> -{% endraw %} - -## Vimeo - -插入 Vimeo 影片。 - -{% raw %} -<pre><code>{% vimeo video_id %} -</code></pre> -{% endraw %} - -## Raw - -逸脫處理。(請去掉反斜線) - -{% raw %} -<pre><code>{% raw %} -{% endraw /%} -</code></pre> -{% endraw %} - -[1]: http://octopress.org/docs/plugins/blockquote/ -[2]: http://octopress.org/docs/plugins/codeblock/ -[3]: http://octopress.org/docs/plugins/backtick-codeblock/ -[4]: http://octopress.org/docs/plugins/pullquote/ -[5]: http://octopress.org/docs/plugins/jsfiddle-tag/ -[6]: http://octopress.org/docs/plugins/gist-tag/ -[7]: http://octopress.org/docs/plugins/image-tag/ \ No newline at end of file diff --git a/source/zh-TW/docs/template-data.md b/source/zh-TW/docs/template-data.md deleted file mode 100644 index a83525fbf7..0000000000 --- a/source/zh-TW/docs/template-data.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -layout: page -title: 樣板資料 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 全域 - -- **[site](#site)** - 網站全域資料 -- **[page](#page)** - 目前頁面的資料,內容根據不同頁面而有所差異 -- **config** - [全域設定][3],即`_config.yml`的內容 -- **theme** - 主題設定,即主題資料夾內`_config.yml`的內容,根據不同主題而有所差異 -- **__**(雙底線) - 取得 [國際化(i18n)][9] 字串 -- **layout** - 布局 -- **cache** - 快取 - -<a name="site"></a> -## site - -網站全域資料,在沒有掛載其他擴充套件的情況下,**site** 擁有以下內容: - -- **posts** - 所有文章 -- **pages** - 所有分頁 -- **categories** - 所有分類 -- **tags** - 所有標籤 - -<a name="page"></a> -## page - -目前頁面的資料,內容根據不同頁面而有所差異。 - -### 文章(post, page, …) - -- **title** - 標題 -- **date** - 發表日期([Moment.js][7] 物件) -- **updated** - 更新日期([Moment.js][7] 物件) -- **categories** - 分類([Model][5] 物件) -- **tags** - 標籤([Model][5] 物件) -- **comments** - 是否開啟留言功能 -- **layout** - 布局 -- **content** - 內文 -- **excerpt** - 摘要(內文中`<!--more-->`之前的內容) -- **source** - 檔案原始位置 -- **path** - 路徑 -- **ctime** - 檔案建立時間([Moment.js][7] 物件) -- **mtime** - 檔案修改時間([Moment.js][7] 物件) -- **prev** - 前一篇文章 -- **next** - 後一篇文章 - -以及使用者在文章設定中所設定的其他變數。**page** 和 **post** 的差別不大,在於 **page** 沒有 `categories`, `tags`, `prev` 和 `next` 屬性。 - -<a name="index"></a> -### 首頁(index) - -**啟用分頁功能**: - -- **per_page** - 每頁顯示的文章數量 -- **total** - 文章總數量 -- **current** - 目前頁碼 -- **current_url** - 目前頁的連結 -- **posts** - 文章([Model][5] 物件) -- **prev** - 上頁頁碼 -- **prev_link** - 上頁連結 -- **next** - 下頁頁碼 -- **next_link** - 下頁連結 - -**關閉分頁功能**: - -[Model][5] 物件。 - -### 彙整(archive) - -與 [首頁布局](#index) 相同,僅增加下列變數: - -- **archive** - 恆為 `true` -- **year** - 彙整年份 -- **month** - 彙整月份 - -### 分類(category) - -與 [首頁布局](#index) 相同,僅增加下列變數: - -- **category** - 分類名稱 - -### 標籤(tag) - -與 [首頁布局](#index) 相同,僅增加下列變數: - -- **tag** - 標籤名稱 - -[3]: configure.html -[5]: collection.html#model -[7]: http://momentjs.com/ -[9]: global-variables.html#i18n \ No newline at end of file diff --git a/source/zh-TW/docs/theme-development.md b/source/zh-TW/docs/theme-development.md deleted file mode 100644 index 186300486e..0000000000 --- a/source/zh-TW/docs/theme-development.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -layout: page -title: 主題開發 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 結構 - -``` plain -|-- _config.yml -|-- languages -|-- layout -|-- source -``` - -### _config.yml - -主題的設定檔案。 - -參考:[設定][1] - -### languages - -主題的語言檔案。 - -參考:[國際化(i18n)][2] - -### layout - -樣板資料夾。你可使用 [EJS][4] 或 [Swig][5] 處理模版檔案,或安裝 [Renderer 外掛][8] 以使用你喜愛的樣板引擎。 - -基礎布局: - -- **archive** - 網誌彙整,若無此樣板則使用 **index** 布局。 -- **category** - 分類彙整,若無此樣板則使用 **archive** 布局。 -- **index** - 首頁 -- **page** - 分頁,若無此樣板則使用 **index** 布局。 -- **post** - 文章,若無此樣板則使用 **index** 布局。 -- **tag** - 標籤彙整,若無此樣板則使用 **archive** 布局。 - -你也可以在主題中自定其他布局,例如`link`或`photo`之類的,若找不到自定的布局的話,則會根據 Generator 的不同,使用相對應的布局代替。 - -*(至少要有**index**布局)* - -### source - -原始檔資料夾,CSS、JavaScript等檔案(Asset)應放置於此資料夾。此資料夾內的檔案在經過處理後會被複製至`public`資料夾,檔案或資料夾名稱開頭為`.`(點)或`_`(底線)的會被忽略。 - -Hexo 內建 [Stylus][6] 及 [nib][7] 支援,你可安裝 [Renderer 外掛][8] 讓 Hexo 支援更多檔案格式。 - -## 參考 - -你可參考預設主題 [Light][3] 來製作主題。 - -[1]: configure.html -[2]: global-variables.html#i18n -[3]: https://github.com/tommy351/hexo-theme-light -[4]: https://github.com/visionmedia/ejs -[5]: http://paularmstrong.github.com/swig/ -[6]: http://learnboost.github.com/stylus/ -[7]: http://visionmedia.github.com/nib/ -[8]: ../plugins/#renderer \ No newline at end of file diff --git a/source/zh-TW/docs/writing.md b/source/zh-TW/docs/writing.md deleted file mode 100644 index bed4e94dff..0000000000 --- a/source/zh-TW/docs/writing.md +++ /dev/null @@ -1,142 +0,0 @@ ---- -layout: page -title: 寫作 -lang: zh-TW -date: 2012-11-01 18:13:30 ---- - -## 建立 - -執行以下指令。 - - hexo new [layout] <title> - -`layout` 參數可忽略,預設為 [全域設定][2] 的 `default_layout` 設定。 - -``` -hexo new "New Post" -> source/_posts/new-post.md -hexo new page "New Page" -> source/new-page/index.md -hexo new draft "New Draft" -> source/_drafts/new-draft.md -``` - -### 檔案名稱 - -你可在 [全域設定][2] 的 `new_post_name` 設定調整新建檔案的名稱,預設為 `:title.md`。 - -- `:title` - 文章標題(文章的預設網址) -- `:year` - 發表年份(4位數) -- `:month` - 發表月份(2位數) -- `:day` - 發表日期(2位數) - -如果你想要讓文章依日期排列,可設定為 `:year-:month-:day-:title.md`。 - -## 設定 - -文章最前面有一段用 `---` 包裹的區塊,稱為 [YAML Front Matter][1]。你可使用 YAML 格式設定文章。以下是預設內容,你可隨自己喜好增減內容。 - -- **layout** - 布局(選填) -- **title** - 標題 -- **date** - 發表日期(預設為檔案建立日期) -- **updated** - 更新日期(選填,預設為檔案最後修改日期) -- **comments** - 留言功能(選填,預設開啟) -- **tags** - 標籤(選填,不適用於分頁) -- **categories** - 分類(選填,不適用於分頁) -- **permalink** - 覆寫預設網址(選填) - -## 分類 - -分類為文章與 `source/_posts` 的相對位址,具有階層性。你也可在檔案內設定 `categories` 屬性,該屬性的內容會加入至原本分類的後面。例如: - -- `source/_posts/title.md` - 無分類 -- `source/_posts/Fruits/title.md` - Fruit -- `source/_posts/Fruits/Apple/title.md` - Fruit, Apple - -``` yaml -# 單一分類 -categories: Fruits - -# 多重分類 -categories: Fruits/Apple - -categories: [Fruits, Apple] - -categories: -- Fruits -- Apple -``` - -### 分類別名 - -你可在 [全域設定][2] 的 `categories_map` 設定調整分類別名,例如: - -- `categories/遊戲/` - categories/games/ -- `categories/日記/` - categories/diary/ - -``` yaml -categories_map: - 遊戲: games - 日記: diary -``` - -## 標籤 - -``` yaml -# 單一標籤 -tags: Apple - -# 多重標籤 -tags: [Apple, Banana] - -tags: -- Apple -- Banana -``` - -### 標籤別名 - -你可在 [全域設定][2] 的 `tags_map` 設定調整標籤別名,例如: - -- `tags/遊戲/` - tags/games/ -- `tags/日記/` - tags/diary/ - -``` yaml -tags_map: - 遊戲: games - 日記: diary -``` - -## 骨架 - -骨架是文章建立時的預設模版,建立文章時會根據骨架(Scaffold)的內容建立文章。 - -### 範例 - -在 `scaffolds` 資料夾內建立 `photo.md`。 - -{% raw %} -<pre><code>layout: {{ layout }} -title: {{ title }} -date: {{ date }} -tags: ---- -</code></pre> -{% endraw %} - -並執行以下命令: - -``` -hexo new photo "New Gallery" -``` - -Hexo 即會依照以上內容建立新檔案。 - -### 使用 - -骨架(Scaffold)使用 Swig 處理,變數以雙大括號包裹。以下是變數內容: - -- **layout** - 布局名稱 -- **title** - 文章標題 -- **date** - 發表日期 - -[1]: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter -[2]: configure.html \ No newline at end of file diff --git a/source/zh-TW/index.md b/source/zh-TW/index.md deleted file mode 100644 index 51b45f3ccf..0000000000 --- a/source/zh-TW/index.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -layout: index -title: Node.js 網誌框架 -subtitle: 快速、簡單且功能強大的 Node.js 網誌框架。 -date: 2012-11-01 18:13:30 -lang: zh-TW ---- - -## 功能 - -- 不可思議的快速 ─ 只要一眨眼靜態檔案即生成完成 -- 支援 [Markdown][1] -- 僅需一道指令即可佈署到 [GitHub Pages][2] 和 [Heroku][3] -- 已移植 [Octopress][4] 外掛 -- 高擴展性、自訂性 -- 相容於 Windows, Mac & Linux - -## 安裝 - -``` bash -npm install -g hexo -``` - -## 更新 - -``` bash -npm update -g -``` - -## 開始 - -建立專案: - -``` bash -hexo init project -cd project -``` - -建立新文章: - -``` bash -hexo new "New Post" -``` - -生成靜態檔案: - -``` bash -hexo generate -``` - -啟動伺服器: - -``` bash -hexo server -``` - -## 下一步 - -有興趣嗎?瀏覽 [文件][5] 瞭解如何使用! - -[1]: http://daringfireball.net/projects/markdown/ -[2]: http://pages.github.com/ -[3]: http://heroku.com/ -[4]: http://octopress.org/ -[5]: docs/ \ No newline at end of file diff --git a/themes/hexo-flat/_config.yml b/themes/hexo-flat/_config.yml new file mode 100644 index 0000000000..8e6e8b7e99 --- /dev/null +++ b/themes/hexo-flat/_config.yml @@ -0,0 +1,2 @@ +addthis: ra-4daee9911f9dfcb4 +google_analytics: UA-4910098-7 \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/after_footer.ejs b/themes/hexo-flat/layout/_partial/after_footer.ejs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/themes/hexo-flat/layout/_partial/footer.ejs b/themes/hexo-flat/layout/_partial/footer.ejs new file mode 100644 index 0000000000..1e70ee7992 --- /dev/null +++ b/themes/hexo-flat/layout/_partial/footer.ejs @@ -0,0 +1,21 @@ +<% var base = config.root + (page.lang ? page.lang + '/' : '') %> +<div id="copyright">© <%= moment().year() %> <a href="http://zespia.tw/" class="footer-link">SkyArrow</a></div> +<nav id="footer-nav"> + <ul> + <li class="footer-nav-item"> + <a href="<%- base %>" class="footer-link">Home</a> + </li> + <li class="footer-nav-item"> + <a href="<%- base %>docs/" class="footer-link">Docs</a> + </li> + <li class="footer-nav-item"> + <a href="https://github.com/tommy351/hexo/wiki/Plugins" class="footer-link">Plugins</a> + </li> + <li class="footer-nav-item"> + <a href="https://github.com/tommy351/hexo/wiki/Themes" class="footer-link">Themes</a> + </li> + <li class="footer-nav-item"> + <a href="https://github.com/tommy351/hexo" class="footer-link">Source</a> + </li> + </ul> +</nav> \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/google_analytics.ejs b/themes/hexo-flat/layout/_partial/google_analytics.ejs new file mode 100644 index 0000000000..8f23d46287 --- /dev/null +++ b/themes/hexo-flat/layout/_partial/google_analytics.ejs @@ -0,0 +1,13 @@ +<% if (theme.google_analytics){ %> +<script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', '<%= theme.google_analytics %>']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); +</script> +<% } %> \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/head.ejs b/themes/hexo-flat/layout/_partial/head.ejs new file mode 100644 index 0000000000..78a88b94eb --- /dev/null +++ b/themes/hexo-flat/layout/_partial/head.ejs @@ -0,0 +1,13 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title><%= config.title %> - <% if (page.title){ %><%= page.title %><% } %> + + + + + + + <%- partial('google_analytics') %> + \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/header.ejs b/themes/hexo-flat/layout/_partial/header.ejs new file mode 100644 index 0000000000..b0b5b23511 --- /dev/null +++ b/themes/hexo-flat/layout/_partial/header.ejs @@ -0,0 +1,20 @@ +<% var base = config.root + (page.lang ? page.lang + '/' : '') %> +

+ +

+ \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/share.ejs b/themes/hexo-flat/layout/_partial/share.ejs new file mode 100644 index 0000000000..1286018f87 --- /dev/null +++ b/themes/hexo-flat/layout/_partial/share.ejs @@ -0,0 +1,9 @@ + + + +Tweet + + + + + \ No newline at end of file diff --git a/themes/hexo-flat/layout/_partial/sidebar.ejs b/themes/hexo-flat/layout/_partial/sidebar.ejs new file mode 100644 index 0000000000..56ccaf5837 --- /dev/null +++ b/themes/hexo-flat/layout/_partial/sidebar.ejs @@ -0,0 +1,82 @@ + \ No newline at end of file diff --git a/themes/hexo-flat/layout/index.ejs b/themes/hexo-flat/layout/index.ejs new file mode 100644 index 0000000000..5f22c8354d --- /dev/null +++ b/themes/hexo-flat/layout/index.ejs @@ -0,0 +1,85 @@ +css: index +--- + +<%- partial('_partial/head') %> + + + +
+
+
+

Features

+
+
+
+ Incredibly Fast +
+ Incredibly Fast +
With V8 engine, Hexo is much faster than any other static file generators.
+
+
+
+ Markdown Support +
+ Markdown Support +
Markdown is easy-to-read & easy-to-write. You only need to focus on your contents.
+
+
+
+ Fast Deploy +
+ Fast Deploy +
You can deploy your site to GitHub/Heroku with only one command.
+
+
+
+ Easy Migrate +
+ Easy Migrate +
Plugins for Octopress are ported to Hexo. You can migrate from Jekyll/Octopress to Hexo easliy.
+
+
+
+
+
+
+
+

Getting Started

+
+

It's easy as cake to install Hexo on your computer.

+

Before installing Hexo, you should install Git & Node.js first. For more info, check the link below.

+
+ More info +
+
+
$ npm install hexo -g
+
$ hexo init blog
+
$ cd blog
+
# Create new post
+
$ hexo new "New Post"
+
# Generate
+
$ hexo generate
+
# Server
+
$ hexo server
+
+
+
+
+ + + \ No newline at end of file diff --git a/themes/hexo-flat/layout/page.ejs b/themes/hexo-flat/layout/page.ejs new file mode 100644 index 0000000000..c5df02031c --- /dev/null +++ b/themes/hexo-flat/layout/page.ejs @@ -0,0 +1,27 @@ +css: page +--- + +<%- partial('_partial/head') %> + + +
+ +
+
+
+
+

<%- page.title %>

+
+
<%- page.content %>
+
+ +
+ + + \ No newline at end of file diff --git a/themes/hexo-flat/source/css/_base.styl b/themes/hexo-flat/source/css/_base.styl new file mode 100644 index 0000000000..6bc7747a55 --- /dev/null +++ b/themes/hexo-flat/source/css/_base.styl @@ -0,0 +1,25 @@ +@import "nib" + +global-reset() + +// Color +color-font = #444 +color-meta = #999 +color-border = #ddd +color-main = #33b5e5 + +// Font +font-default = "Helvetica Neue", Helvetica, Arial, sans-serif +font-title = Lato, "Helvetica Neue", Helvetica, Arial, sans-serif +font-serif = "Georgia", serif +font-mono = Monaco, Menlo, Consolas, monospace + +body + font 14px font-default + +.inner + margin 0 auto + width 1000px + +@import "_partial/header" +@import "_partial/footer" \ No newline at end of file diff --git a/themes/hexo-flat/source/css/_partial/footer.styl b/themes/hexo-flat/source/css/_partial/footer.styl new file mode 100644 index 0000000000..b75dc7b98b --- /dev/null +++ b/themes/hexo-flat/source/css/_partial/footer.styl @@ -0,0 +1,23 @@ +#footer + clearfix() + padding 50px 0 + font-family font-title + font-weight 300 + border-top 1px solid color-border + +.footer-link + text-decoration none + color color-meta + &:hover + color color-main + +#copyright + float left + color color-meta + +#footer-nav + float right + +.footer-nav-item + float left + margin-left 30px \ No newline at end of file diff --git a/themes/hexo-flat/source/css/_partial/header.styl b/themes/hexo-flat/source/css/_partial/header.styl new file mode 100644 index 0000000000..ff6b326a32 --- /dev/null +++ b/themes/hexo-flat/source/css/_partial/header.styl @@ -0,0 +1,29 @@ +#header + clearfix() + padding 40px 0 + font-family font-title + +#logo-wrap + float left + +#logo + font-size 35px + line-height 35px + font-weight bold + text-transform lowercase + text-decoration none + +#main-nav + float right + +.main-nav-item + float left + margin-left 40px + +.main-nav-link + text-decoration none + line-height 35px + font-weight 300 + border-bottom 2px solid transparent + padding-bottom 5px + font-size 16px \ No newline at end of file diff --git a/themes/hexo-flat/source/css/images/home/easy-migrate.jpg b/themes/hexo-flat/source/css/images/home/easy-migrate.jpg new file mode 100644 index 0000000000..cee9e35711 Binary files /dev/null and b/themes/hexo-flat/source/css/images/home/easy-migrate.jpg differ diff --git a/themes/hexo-flat/source/css/images/home/fast-deploy.jpg b/themes/hexo-flat/source/css/images/home/fast-deploy.jpg new file mode 100644 index 0000000000..1c8c764615 Binary files /dev/null and b/themes/hexo-flat/source/css/images/home/fast-deploy.jpg differ diff --git a/themes/hexo-flat/source/css/images/home/incredibly-fast.jpg b/themes/hexo-flat/source/css/images/home/incredibly-fast.jpg new file mode 100644 index 0000000000..5eec89319a Binary files /dev/null and b/themes/hexo-flat/source/css/images/home/incredibly-fast.jpg differ diff --git a/themes/hexo-flat/source/css/images/home/markdown-support.jpg b/themes/hexo-flat/source/css/images/home/markdown-support.jpg new file mode 100644 index 0000000000..032aeec73b Binary files /dev/null and b/themes/hexo-flat/source/css/images/home/markdown-support.jpg differ diff --git a/themes/hexo-flat/source/css/index.styl b/themes/hexo-flat/source/css/index.styl new file mode 100644 index 0000000000..7e234ad438 --- /dev/null +++ b/themes/hexo-flat/source/css/index.styl @@ -0,0 +1,126 @@ +@import "_base" + +#logo +.main-nav-link + color #fff + +.main-nav-link + &:hover + border-color #fff + +#banner-wrap + background color-main + border-bottom 2px solid darken(color-main, 5%) + +#banner + margin 0 auto + width 1000px + padding 40px 0 80px + font-family font-title + +#banner-text + font-weight 300 + line-height 1.3 + color #fff + font-size 50px + +#banner-entry + clearfix() + margin-top 40px + +#banner-button + text-transform uppercase + text-decoration none + display block + font-weight bold + padding 15px 30px + border 3px solid #fff + color #fff + float left + &:hover + background #fff + color color-main + +#banner-share + margin 15px 0 0 50px + float left + +.section-wrap + border-bottom 1px solid color-border + +.section + clearfix() + +.section-title + color color-main + font 300 2em font-title + margin 40px 0 + +.section-entry + clearfix() + margin-bottom 50px + color color-font + line-height 1.6em + p + margin-bottom 1.6em + +.feature-block + float left + width 220px + margin-right 40px + &:last-child + margin-right 0 + +.feature-block-title + font-weight 300 + font-size 1.4em + line-height 1.1em + font-family font-title + text-align center + display block + +.feature-block-entry + margin-top 1.6em + display none + +.feature-block-img + text-align center + margin-bottom 20px + +#get-started-entry + float left + width 450px + +#get-started-code + font-family font-mono + float right + width 450px + padding 40px 30px + line-height 1.6em + color #666 + border-left 1px solid #ddd + border-right 1px solid #ddd + background #eee + box-shadow 0 0 5px #ddd inset + .prompt + color color-main + .comment + color #999 + margin-top 1.6em + +#more-info + float left + padding 15px 30px + background color-main + color #fff + text-transform uppercase + text-decoration none + display block + font-family font-title + font-weight bold + margin-top -15px + &:hover + background darken(color-main, 10%) + +#footer + border-top none \ No newline at end of file diff --git a/themes/hexo-flat/source/css/page.styl b/themes/hexo-flat/source/css/page.styl new file mode 100644 index 0000000000..bb605aa7b2 --- /dev/null +++ b/themes/hexo-flat/source/css/page.styl @@ -0,0 +1,66 @@ +@import "_base" + +#header-wrap + border-top 5px solid color-main + +#header + border-bottom 1px solid color-main + +#logo +.main-nav-link + color color-main + +.main-nav-link + &:hover + border-color color-main + +#content + clearfix() + padding 40px 0 + +#main-col + float right + width 760px + +#article-header + padding-bottom 20px + margin-bottom 40px + border-bottom 1px solid color-border + +#article-title + font-size 2em + color color-main + font-weight 300 + font-family font-title + +#article-entry + line-height 1.6em + color color-font + +#sidebar + float left + font-family font-title + width 200px + +.side-nav-child + border 1px solid color-border + margin 10px 0 + +.side-nav-title-link + background #ccc + color #fff + display block + font-weight bold + padding 10px 20px + text-decoration none + text-transform uppercase + +.side-nav-child-link + color #999 + font-weight 300 + padding 10px 20px + text-decoration none + display block + &:hover + background color-main + color #fff \ No newline at end of file diff --git a/themes/hexo2/_config.yml b/themes/hexo2/_config.yml new file mode 100644 index 0000000000..330640d5a5 --- /dev/null +++ b/themes/hexo2/_config.yml @@ -0,0 +1,36 @@ +menu: + Docs: docs/ + #API: api/ + Plugins: https://github.com/tommy351/hexo/wiki/Plugins + Themes: https://github.com/tommy351/hexo/wiki/Themes + #Blog: blog/ + +doc_sidebar: + Getting Started: + Installation: installation.html + Setup: setup.html + Configuration: configuration.html + Commands: commands.html + Migration: migration.html + Basic Usage: + Writing: writing.html + Generating: generating.html + Tag Plugins: tag-plugins.html + Server: server.html + Deployment: deployment.html + Customization: + Permalinks: permalinks.html + Themes: themes.html + Variables: variables.html + Pagination: pagination.html + Helpers: helpers.html + i18n: i18n.html + Advanced: + Models: models.html + Events: events.html + Plugins: plugins.html + Miscellaneous: + Troubleshooting: troubleshooting.html + Contributing: contributing.html + +google_analytics: UA-4910098-7 \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/after-footer.ejs b/themes/hexo2/layout/_partial/after-footer.ejs new file mode 100644 index 0000000000..48b9e51ced --- /dev/null +++ b/themes/hexo2/layout/_partial/after-footer.ejs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/footer.ejs b/themes/hexo2/layout/_partial/footer.ejs new file mode 100644 index 0000000000..94acfde5e1 --- /dev/null +++ b/themes/hexo2/layout/_partial/footer.ejs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/google-analytics.ejs b/themes/hexo2/layout/_partial/google-analytics.ejs new file mode 100644 index 0000000000..8f23d46287 --- /dev/null +++ b/themes/hexo2/layout/_partial/google-analytics.ejs @@ -0,0 +1,13 @@ +<% if (theme.google_analytics){ %> + +<% } %> \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/head.ejs b/themes/hexo2/layout/_partial/head.ejs new file mode 100644 index 0000000000..2fb003e1da --- /dev/null +++ b/themes/hexo2/layout/_partial/head.ejs @@ -0,0 +1,13 @@ + + + + + <%= config.title %> - <% if (page.title){ %><%= page.title %><% } %> + + + + + + + <%- partial('google-analytics') %> + \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/header.ejs b/themes/hexo2/layout/_partial/header.ejs new file mode 100644 index 0000000000..2dec3f2c78 --- /dev/null +++ b/themes/hexo2/layout/_partial/header.ejs @@ -0,0 +1,11 @@ +

+ +

+ + +
Fork
+
\ No newline at end of file diff --git a/themes/hexo2/layout/_partial/share.ejs b/themes/hexo2/layout/_partial/share.ejs new file mode 100644 index 0000000000..711d9d5a4d --- /dev/null +++ b/themes/hexo2/layout/_partial/share.ejs @@ -0,0 +1,13 @@ + + + + + + + +Tweet + + + + + \ No newline at end of file diff --git a/themes/hexo2/layout/_partial/sidebar.ejs b/themes/hexo2/layout/_partial/sidebar.ejs new file mode 100644 index 0000000000..5f33f948e0 --- /dev/null +++ b/themes/hexo2/layout/_partial/sidebar.ejs @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/themes/hexo2/layout/index.ejs b/themes/hexo2/layout/index.ejs new file mode 100644 index 0000000000..266e351ad1 --- /dev/null +++ b/themes/hexo2/layout/index.ejs @@ -0,0 +1,36 @@ +index: true +--- + +
+
+

A fast, simple & powerful blog framework
powered by Node.js

+ Getting Started +
+ <%- partial('_partial/share') %> +
+
+
+ +
+
+
+

Blazing fast

+
Hexo is powered by Node.js and supports multi-thread generating. Hundreds of files take only less than a minute to generate.
+
+
+

Easy writing

+
Hexo supports GitHub Flavored Markdown and all Octopress plugins and highly Jekyll/Octopress compatible.
+
+
+

High extensibility

+
Hexo supports EJS, Swig & Stylus. You can install more plugins for Haml, Jade, Less supports.
+
+
+
+ +
+
+
$ npm install -g hexo
+ Install now +
+
\ No newline at end of file diff --git a/themes/hexo2/layout/layout.ejs b/themes/hexo2/layout/layout.ejs new file mode 100644 index 0000000000..3541e25ebb --- /dev/null +++ b/themes/hexo2/layout/layout.ejs @@ -0,0 +1,18 @@ +<%- partial('_partial/head') %> + + +
+ <%- body %> +
+ + <%- partial('_partial/after-footer') %> + + \ No newline at end of file diff --git a/themes/hexo2/layout/page.ejs b/themes/hexo2/layout/page.ejs new file mode 100644 index 0000000000..faaf6f4bd2 --- /dev/null +++ b/themes/hexo2/layout/page.ejs @@ -0,0 +1,17 @@ +index: false +--- + +
+
+ <% if (!page.hide_title){ %> +

<%= page.title %>

+ <% } %> +
<%- page.content %>
+ +
+ <%- partial('_partial/sidebar') %> +
\ No newline at end of file diff --git a/themes/hexo2/source/css/_partial/footer.styl b/themes/hexo2/source/css/_partial/footer.styl new file mode 100644 index 0000000000..f7fddc164f --- /dev/null +++ b/themes/hexo2/source/css/_partial/footer.styl @@ -0,0 +1,15 @@ +#footer + background: #eee + padding: 30px 0 + border-top: 1px solid color-border + +#copyright + color: color-grey + line-height: 1.5em + font-family: font-title + font-weight: 300 + a + color: color-main + text-decoration: none + &:hover + text-decoration: underline \ No newline at end of file diff --git a/themes/hexo2/source/css/_partial/header.styl b/themes/hexo2/source/css/_partial/header.styl new file mode 100644 index 0000000000..a0412a7e41 --- /dev/null +++ b/themes/hexo2/source/css/_partial/header.styl @@ -0,0 +1,62 @@ +header-height = 60px + +#header + clearfix() + background: linear-gradient(top, lighten(color-main, 5%), color-main) + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) + font-family: font-title + &.normal + background: linear-gradient(top, lighten(color-main, 10%), color-main) + box-shadow: 0 0 10px rgba(0, 0, 0, 0.3) + border-bottom: 1px solid darken(color-main, 10%) + +#logo-wrap + float: left + +#logo + font-size: 30px + line-height: header-height + font-weight: bold + color: #fff + text-decoration: none + text-transform: lowercase + +#main-nav + float: left + margin-left: 50px + +.main-nav-link + float: left + padding: 0 20px + color: #fff + text-decoration: none + font-weight: 300 + line-height: header-height + font-size: 15px + &:hover + background: linear-gradient(top, darken(color-main, 10%), color-main) + +#fork-github-wrap + display: block + float: right + height: header-height + text-decoration: none + color: #fff + &:hover + #fork-github + background: linear-gradient(top, lighten(color-main, 25%), lighten(color-main, 10%)) + &:active + #fork-github + background: linear-gradient(top, color-main, lighten(color-main, 5%)) + box-shadow: 0 0 3px rgba(0, 0, 0, 0.2) inset + +#fork-github + padding: 6px 15px + line-height: 1em + margin-top: (header-height / 2) - 14px + border: 1px solid darken(color-main, 10%) + background: linear-gradient(top, lighten(color-main, 15%), lighten(color-main, 8%)) + border-radius: 3px + font-weight: 300 + .icon-code-fork + padding-right: 10px \ No newline at end of file diff --git a/themes/hexo2/source/css/_partial/highlight.styl b/themes/hexo2/source/css/_partial/highlight.styl new file mode 100644 index 0000000000..7ac40e2c68 --- /dev/null +++ b/themes/hexo2/source/css/_partial/highlight.styl @@ -0,0 +1,96 @@ +// https://github.com/chriskempson/tomorrow-theme +highlight-background = #fff +highlight-current-line = #efefef +highlight-selection = #d6d6d6 +highlight-foreground = #4d4d4c +highlight-comment = #8e908c +highlight-red = #c82829 +highlight-orange = #f5871f +highlight-yellow = #eab700 +highlight-green = #718c00 +highlight-aqua = #3e999f +highlight-blue = #4271ae +highlight-purple = #8959a8 + +.page-entry + code, pre + font-family: font-mono + color: highlight-foreground + background: #eee + border-radius: 4px + border: 1px solid color-border + code + margin: 0 3px + font-size: 0.85em + padding: 2px 5px + pre + padding: 10px 15px + +figure.highlight + background: #eee + border: 1px solid color-border + border-radius: 4px + padding: 10px 15px + color: highlight-foreground + overflow: auto + figcaption + clearfix() + margin: -10px -15px 0 + background: linear-gradient(top, color-border, #eee) + font-size: 0.85em + padding: 5px 15px + color: color-grey + a + float: right + pre + padding: 0 + border: none + background: none + .comment + .title + color: highlight-comment + .variable + .attribute + .tag + .regexp + .ruby .constant + .xml .tag .title + .xml .pi + .xml .doctype + .html .doctype + .css .id + .css .class + .css .pseudo + color: highlight-red + .number + .preprocessor + .built_in + .literal + .params + .constant + color: highlight-orange + .class + .ruby .class .title + .css .rules .attribute + color: highlight-green + .string + .value + .inheritance + .header + .ruby .symbol + .xml .cdata + color: highlight-green + .css .hexcolor + color: highlight-aqua + .function + .python .decorator + .python .title + .ruby .function .title + .ruby .title .keyword + .perl .sub + .javascript .title + .coffeescript .title + color: highlight-blue + .keyword + .javascript .function + color: highlight-purple \ No newline at end of file diff --git a/themes/hexo2/source/css/_partial/index.styl b/themes/hexo2/source/css/_partial/index.styl new file mode 100644 index 0000000000..50d11ebb62 --- /dev/null +++ b/themes/hexo2/source/css/_partial/index.styl @@ -0,0 +1,99 @@ +intro-margin = 50px +intro-column = 3 +intro-width = (body-width - (intro-margin * (intro-column - 1))) / intro-column + +#hero + background: linear-gradient(top, color-main, darken(color-main, 25%)) + padding: 40px 0 + color: #fff + font-family: font-title + text-align: center + +#hero-title + font-weight: 300 + font-size: 50px + line-height: 1.25em + text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) + +#hero-button + margin-top: 30px + padding: 10px 30px + font-weight: bold + border: 2px solid #fff + border-radius: 4px + display: inline-block + text-transform: uppercase + color: color-main + text-decoration: none + background: linear-gradient(top, #fff, #eee) + text-shadow: 0 1px 1px #fff + box-shadow: 0 0 10px rgba(0, 0, 0, 0.3) + &:hover + background: #fff + &:active + background: linear-gradient(top, #ddd, #eee) + +#hero-share + margin-top: 50px + +#version-badge + margin-right: 20px + +#intro-wrap + clearfix() + padding: 50px 0 + +.intro + float: left + margin-left: intro-margin + width: intro-width + &:nth-child({intro-column}n + 1) + margin-left: 0 + +.intro-title + font-family: font-title + font-weight: 300 + font-size: 25px + +.intro-desc + font-size: 16px + margin-top: 1.5em + line-height: 1.5em + color: color-sub + a + color: color-link + text-decoration: none + &:hover + text-decoration: underline + +#install-wrap + clearfix() + padding: 30px 0 + border-top: 1px solid color-border + +#install-command + float: left + font-size: 20px + font-family: font-mono + line-height: 39px + .dollar + color: color-main + +#install-button + float: right + text-decoration: none + color: #fff + background: linear-gradient(top, lighten(color-main, 10%), color-main) + font-family: font-title + font-weight: bold + text-transform: uppercase + padding: 10px 30px + border-radius: 4px + display: block + border: 1px solid color-main + text-shadow: 0 1px 2px darken(color-main, 10%) + &:hover + background: linear-gradient(top, lighten(color-main, 15%), lighten(color-main, 5%)) + &:active + background: linear-gradient(top, color-main, darken(color-main, 10%)) + box-shadow: 0 0 5px rgba(0, 0, 0, 0.3) inset \ No newline at end of file diff --git a/themes/hexo2/source/css/_partial/page.styl b/themes/hexo2/source/css/_partial/page.styl new file mode 100644 index 0000000000..6d686029e9 --- /dev/null +++ b/themes/hexo2/source/css/_partial/page.styl @@ -0,0 +1,204 @@ +page-title = 35px +line-height = 1.6em +sidebar-width = 150px +sidebar-margin = 30px + +note-tip = hsl(40, 100%, 50%) +note-info = hsl(200, 100%, 50%) +note-warn = hsl(0, 100%, 50%) + +.page + float: left + width: body-width - sidebar-width - (sidebar-margin * 2) + border-right: 1px solid color-border + padding: 50px sidebar-margin 50px 0 + +.page-title + font-family: font-title + font-weight: 300 + font-size: page-title + margin-bottom: 40px + line-height: page-title + color: color-main + +.page-entry + line-height: line-height + p, ol, ul, dl, table, blockquote, iframe, .highlight + margin: line-height 0 + h1 + font-size: 2em + h2 + font-size: 1.5em + h3 + font-size: 1.3em + h1, h2, h3, h4, h5, h6 + line-height: 1em + margin: 1em 0 + font-family: font-title + font-weight: bold + h1, h2 + padding-top: 1em + border-top: 1px solid color-border + a + color: color-link + text-decoration: none + &:hover + text-decoration: underline + strong + font-weight: bold + em + font-style: italic + ul, ol, dl + margin-left: 20px + ul, ol, dl + margin-top: 0 + margin-bottom: 0 + p + margin: 0 + figure.highlight + margin: 1em 0 + ul + list-style: disc + ol + list-style: decimal + dl + list-style: square + li + margin-bottom: 0.5em + blockquote + border: 1px solid color-border + border-left: 4px solid color-border + padding: 0 20px + position: relative + margin-left: 45px + &:before + content: "\f10d" + position: absolute + left: -45px + top: 21px + font-size: 25px + font-family: font-icon + width: 25px + height: 25px + text-align: center + color: color-border + footer + margin: 1em 0 + font-style: italic + cite + &:before + content: "—" + padding: 0 0.3em + a + color: color-grey + .note + &:before + top: 14px + &.tip + border-left-color: note-tip + &:before + content: "\f0eb" + color: note-tip + &.info + border-left-color: note-info + &:before + content: "\f05a" + color: note-info + &.warn + border-left-color: note-warn + &:before + content: "\f06a" + color: note-warn + .note-title + margin: 1em 0 + display: block + font-family: font-title + line-height: 1em + font-size: 1.3em + table + width: 100% + border: 1px solid color-border + th + font-weight: bold + th, td + padding: 5px 15px + tr + &:nth-child(2n) + background: #eee + +#section-nav + clearfix() + border-top: 1px solid color-border + padding-top: line-height + margin-top: line-height * 2 + position: relative + +.section-nav-link + color: color-main + font-family: font-title + text-decoration: none + text-transform: uppercase + font-weight: bold + position: relative + +#section-nav-prev + float: left + .icon-chevron-left + padding-right: 10px + +#section-nav-next + float: right + .icon-chevron-right + padding-left: 10px + +#last-updated + position: absolute + top: 24px + left: 0 + width: 100% + text-align: center + font-size: 0.8em + color: color-grey + +#sidebar + float: right + width: sidebar-width + sidebar-margin - 1px + border-left: 1px solid color-border + margin-left: -1px + padding-bottom: 50px + font-family: font-title + +.sidebar-title + font-weight: bold + display: block + padding: 0 0 10px sidebar-margin - 1px + margin-top: 50px + margin-bottom: 10px + text-transform: uppercase + border-bottom: 1px solid color-border + color: color-main + +.sidebar-link + display: block + text-decoration: none + color: color-sub + padding: 10px 0 10px sidebar-margin - 1px + position: relative + &:hover + color: color-link + &.current + font-weight: bold + position: relative + &:before, &:after + content: "" + &:before, &:after + position: absolute + top: 12px + border-style: solid + border-width: 8px + border-color: transparent transparent transparent color-border + &:before + left: 0 + &:after + left: -1px + border-left-color: #fff \ No newline at end of file diff --git a/themes/hexo2/source/css/style.styl b/themes/hexo2/source/css/style.styl new file mode 100644 index 0000000000..dc5f3dac56 --- /dev/null +++ b/themes/hexo2/source/css/style.styl @@ -0,0 +1,35 @@ +@import "nib" + +global-reset() + +// Color +color-default = #444 +color-sub = #666 +color-main = hsl(273, 35%, 50%) +color-grey = #999 +color-border = #ddd +color-link = #0088cc + +// Font +font-default = "Helvetica Neue", Helvetica, Arial, sans-serif +font-mono = Monaco, Menlo, Consolas, monospace +font-title = Lato, font-default +font-icon = FontAwesome + +// Variable +body-width = 1000px + +body + color: color-default + font: 14px font-default + +.inner + clearfix() + width: body-width + margin: 0 auto + +@import "_partial/header" +@import "_partial/index" +@import "_partial/page" +@import "_partial/footer" +@import "_partial/highlight" \ No newline at end of file