fix generator

This commit is contained in:
xaoxuu 2021-02-22 14:12:34 +08:00
parent 342ee89f14
commit c8fa05f5cb
4 changed files with 57 additions and 33 deletions

View File

@ -5,6 +5,7 @@
<% } else { %>
<a href='/'><%- __('btn.recent_publish') %></a>
<% } %>
<% if (site.categories && site.categories.length > 0) { %>
<% if (page.category) { %>
<a class='active' href='<%- url_for(config.category_dir) %>'><%- __('btn.category') + __('symbol.colon') + page.category %></a>
<% } else if (page.layout == 'categories') { %>
@ -12,6 +13,8 @@
<% } else { %>
<a href='<%- url_for(config.category_dir) %>'><%- __('btn.categories') %></a>
<% } %>
<% } %>
<% if (site.tags && site.tags.length > 0) { %>
<% if (page.tag) { %>
<a class='active' href='<%- url_for(config.tag_dir) %>'><%- __('btn.tag') + __('symbol.colon') + page.tag %></a>
<% } else if (page.layout == 'tags') { %>
@ -19,10 +22,13 @@
<% } else { %>
<a href='<%- url_for(config.tag_dir) %>'><%- __('btn.tags') %></a>
<% } %>
<% } %>
<% if (site.posts && site.posts.length > 0) { %>
<% if (is_archive()) { %>
<a class='active' href='<%- url_for(config.archive_dir) %>'><%- __('btn.archives') %></a>
<% } else { %>
<a href='<%- url_for(config.archive_dir) %>'><%- __('btn.archives') %></a>
<% } %>
<% } %>
</nav>
</div>

View File

@ -3,9 +3,13 @@
*/
hexo.extend.generator.register('categories', function (locals) {
if (locals.categories && locals.categories.length > 0) {
return {
path: hexo.config.category_dir + '/index.html',
data: locals.posts,
layout: ['categories']
}
} else {
return {};
}
});

View File

@ -2,10 +2,14 @@
* tags v1 | https://github.com/xaoxuu/hexo-theme-stellar/
*/
hexo.extend.generator.register('tags', function (locals) {
hexo.extend.generator.register('tags', function (locals) {
if (locals.tags && locals.tags.length > 0) {
return {
path: hexo.config.tag_dir + '/index.html',
data: locals.posts,
layout: ['tags']
}
} else {
return {};
}
});

View File

@ -3,9 +3,19 @@
*/
hexo.extend.generator.register('wiki', function (locals) {
var hasWiki = false;
locals.pages.forEach((page, i) => {
if (page.layout == 'wiki') {
hasWiki = true;
}
});
if (hasWiki) {
return {
path: (hexo.config.wiki_dir || 'wiki') + '/index.html',
data: locals.posts,
layout: ['wiki']
}
} else {
return {};
}
});