Skip to content

Commit

Permalink
feat(hexo): 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Apr 7, 2023
1 parent db39681 commit 46cad76
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/layouts/hack.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<%- partial('_ksio/layouts/index') %>
<% } else if (is_post()) { %>
<%- partial('_ksio/layouts/post') %>
<% } else if (page.ksio_page_404) { %>
<%- partial('_ksio/pages/404') %>
<% } else { %>
<%- partial('_ksio/layouts/page') %>
<% } %>
1 change: 1 addition & 0 deletions src/hexo/themes/lime/layout/_ksio/pages/404.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>孩子,迷路了吧?来让蜀黍<a href="<%= config.root || '/' %>">送你回家</a>。</p>
7 changes: 7 additions & 0 deletions src/hexo/themes/lime/scripts/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hexo.extend.generator.register('404', () => {
return {
path: '404.html',
layout: ['page', 'index'],
data: { title: '警察局', ksio_page_404: true },
};
});
2 changes: 1 addition & 1 deletion src/hexo/themes/lime/scripts/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function resolvePageConfig(page, defaults) {
return mergeValues(resolveValuesFromLayout(resolved.layout || page.layout, layoutDefaults), resolved);
}

hexo.extend.filter.register('template_locals', function(locals) {
hexo.extend.filter.register('template_locals', locals => {
if (locals.config.ksio && locals.config.ksio.defaults ) {
locals.page = { ...locals.page, ...resolvePageConfig(locals.page, locals.config.ksio.defaults) };
}
Expand Down

0 comments on commit 46cad76

Please sign in to comment.