forked from raytaylorlin/site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "News" section. Modify the style of header.
- Loading branch information
Showing
30 changed files
with
365 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
# Basic | ||
# Hexo Configuration | ||
## Docs: http://hexo.io/docs/configuration.html | ||
## Source: https://github.com/tommy351/hexo/ | ||
|
||
# Site | ||
title: Hexo | ||
subtitle: Hexo is a fast, simple & powerful blog framework powered by Node.js. | ||
description: Hexo is a fast, simple & powerful blog framework powered by Node.js. | ||
url: http://hexo.io | ||
author: SkyArrow | ||
email: [email protected] | ||
language: | ||
|
||
# Permalink | ||
# URL | ||
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' | ||
url: http://hexo.io | ||
root: / | ||
permalink: :category/:title/ | ||
permalink: news/:year/:month/:day/:title/ | ||
tag_dir: tags | ||
archive_dir: archives | ||
category_dir: posts | ||
archive_dir: news | ||
category_dir: categories | ||
code_dir: downloads/code | ||
|
||
# Directory | ||
source_dir: source | ||
public_dir: public | ||
|
||
# Writing | ||
new_post_name: :year-:month-:day-: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 | ||
external_link: true # Open external links in new tab | ||
max_open_file: 100 | ||
multi_thread: true | ||
filename_case: 0 | ||
render_drafts: false | ||
post_asset_folder: false | ||
relative_link: false | ||
highlight: | ||
enable: true | ||
line_number: false | ||
tab_replace: | ||
|
||
# Category & Tag | ||
default_category: uncategorized | ||
category_map: | ||
tag_map: | ||
|
||
# Archives | ||
# 2: Paginate result | ||
|
@@ -22,46 +54,38 @@ category: 2 | |
tag: 2 | ||
|
||
# Server | ||
# Hexo uses Connect to serve static files | ||
# Reference: http://www.senchalabs.org/connect/ | ||
## Hexo uses Connect as a server | ||
## You can customize the logger format as defined in | ||
## http://www.senchalabs.org/connect/logger.html | ||
port: 4000 | ||
server_ip: 0.0.0.0 | ||
logger: false | ||
logger_format: | ||
|
||
# Date / Time format | ||
# Hexo uses Moment.js to parse and display date | ||
# Reference: http://momentjs.com/docs/#/displaying/format/ | ||
date_format: MMM D, YYYY | ||
## 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: 0 | ||
pagination_dir: page | ||
|
||
# Disqus | ||
disqus_shortname: hexojs | ||
|
||
# Extensions | ||
plugins: | ||
## Plugins: https://github.com/tommy351/hexo/wiki/Plugins | ||
## Themes: https://github.com/tommy351/hexo/wiki/Themes | ||
theme: hexo3 | ||
exclude_generator: | ||
- category | ||
- tag | ||
- home | ||
- post | ||
- archive | ||
|
||
# Enhancement | ||
auto_spacing: false | ||
titlecase: false | ||
highlight: | ||
enable: true | ||
line_number: false | ||
tab_replace: ' ' | ||
|
||
# Deployment | ||
# Type: github, heroku | ||
# Read documentaion for more information | ||
## Docs: http://hexo.io/docs/deployment.html | ||
deploy: | ||
type: github | ||
repo: https://github.com/hexojs/hexojs.github.io.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
title: Hexo 2.7 Released | ||
--- | ||
Hexo 2.7 has been released with three new features. I'm going to introduce them below. | ||
|
||
## Fragment Caching | ||
|
||
Although Hexo is fast, it may become slow if you have thousands of source files or complicated categories or tags. Before the data model upgraded, I borrowed a feature from Ruby on Rails: **Fragment Caching**. | ||
|
||
Fragment Caching saves contents within a fragment and serves the cache when the next request come in. A fragment will only be processed once. It can reduce database queries and decrease generation time significantly. For instance, a Hexo site with 300+ source files needs 6 minutes to generate. In Hexo 2.7, it only need 10 seconds! | ||
|
||
It can be used in header, footer, sidebar or static contents that won't be changed during generating. For example: | ||
|
||
``` js | ||
<%- fragment_cache('header', function(){ | ||
return '<header></header>'; | ||
}); | ||
``` | ||
|
||
By using `fragment_cache` helper, contents in the function will be cached. | ||
|
||
Partial helper also supports Fragment Caching, you only need to add a `{cache: true}` option when using partial. | ||
|
||
``` js | ||
<%- partial('header', {}, {cache: true}) %> | ||
``` | ||
|
||
[Landscape] is updated and supports Fragment Caching now. You can check [this commit](https://github.com/hexojs/hexo-theme-landscape/commit/d2aedda61571d6994eb72d784ceda2f59d2a8631) to see what's changed. | ||
|
||
## Relative Link | ||
|
||
Relative Link is supported since Hexo 2.7. But your theme needs some modifications to support it. However, it's not as hard as you think. You just need to replace the following contents in templates | ||
|
||
``` js | ||
<%- config.root %><%- path %> | ||
``` | ||
|
||
with `url_for` helper. | ||
|
||
``` js | ||
<%- url_for(path) %> | ||
``` | ||
|
||
`url_for` helper will add `config.root` automatically for you. If you enable `relative_link` setting, it'll add a relative path. | ||
|
||
[Landscape] is updated for Relative Link. You can check [this commit](https://github.com/hexojs/hexo-theme-landscape/commit/d29cbb83356373af27e7b98643f29a27804364af) to see what's changed. | ||
|
||
## Server Middleware | ||
|
||
Server Middleware would be familiar if you have ever used [Connect] or [Express] before. [Connect] passes a request through functions called **middleware**. You can make response to the coming in request in middleware. | ||
|
||
In Hexo, middleware is served as a type of filter. You can add middleware by registering a new filter. For example: | ||
|
||
``` js | ||
hexo.extend.filter.register('server_middleware', function(app){ | ||
app.use(function(req, res, next){ | ||
res.setHeader('X-Powered-By', 'Hexo'); | ||
next(); | ||
}); | ||
}); | ||
``` | ||
|
||
This middleware add a header `X-Powered-By` and passes the request to the next middleware. | ||
|
||
[Landscape]: https://github.com/hexojs/hexo-theme-landscape | ||
[Connect]: http://www.senchalabs.org/connect/ | ||
[Express]: http://expressjs.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<article class="post<% if (full){ %> full<% } %>" itemscope itemtype="http://schema.org/Article"> | ||
<header class="post-header"> | ||
<%- partial('post/title') %> | ||
<%- partial('post/date') %> | ||
</header> | ||
<% if (full){ %> | ||
<div class="page-entry" itemprop="articleBody"> | ||
<%- post.content %> | ||
</div> | ||
<% } %> | ||
<% if (!index){ %> | ||
<%- partial('comment') %> | ||
<% } %> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% if (page.comments && config.disqus_shortname){ %> | ||
<section id="comments"> | ||
<div id="disqus_thread"> | ||
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> | ||
</div> | ||
</section> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<header id="page-banner"> | ||
<div class="outer"> | ||
<div id="page-banner-inner" class="inner"> | ||
<h1 id="page-title">News</h1> | ||
<a href="<%- url_for('atom.xml') %>" title="Subscribe for latest news" id="news-subscribe-link"></a> | ||
</div> | ||
</div> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="post-date-wrap"> | ||
<a href="<%- url_for(post.path) %>" class="post-date"> | ||
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= date(post.date) %></time> | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% if (post.link){ %> | ||
<h1 itemprop="name"> | ||
<a class="post-title" href="<%- url_for(post.link) %>" target="_blank" itemprop="url"><%= post.title %></a> | ||
</h1> | ||
<% } else if (post.title){ %> | ||
<% if (index){ %> | ||
<h1 itemprop="name"> | ||
<a class="post-title" href="<%- url_for(post.path) %>"><%= post.title %></a> | ||
</h1> | ||
<% } else { %> | ||
<h1 class="post-title" itemprop="name"> | ||
<%= post.title %> | ||
</h1> | ||
<% } %> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% page.title = 'News' %> | ||
<%- partial('_partial/news-banner') %> | ||
|
||
<div id="post-list" class="outer"> | ||
<div class="inner"> | ||
<% page.posts.each(function(post, i){ %> | ||
<%- partial('_partial/article', {post: post, full: i === 0, index: true}) %> | ||
<% }) %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.