Skip to content

Commit

Permalink
feat(hexo): customizable slots
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Apr 4, 2023
1 parent 6acae93 commit 8ce5dd6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/hexo/themes/lime/layout/_ksio/layouts/page.ejs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<%- partial(theme.header && theme.header.partial || '_ksio/partials/header') %>
<main class="Page-content">
<% if (page.banner) { %>
<!-- 页面横幅 -->
<div class="Page-banner hidden-xs" style="background-image: url('<%= url_for(banner.url) %>');">
<figure class="sr-only">
<%- image_tag(page.banner.url, { alt: page.banner.description || '' }) %>
<figcaption><%= page.banner.description %></figcaption>
</figure>
</div>
<% } %>
<%- partial('_ksio/slots/banner') %>
<!-- 内容主体 -->
<div class="container">
<article class="Page-main Article">
<header class="Article-header">
<h1 class="Article-title"><%= page.title %></h1>
<%- partial('_ksio/slots/header') %>
</header>
<div class="Article-content col-md-9"><%- page.content %></div>
<footer class="Article-footer col-md-3"><%- partial('_ksio/slots/footer') %></footer>
<% if (page.siblings === true) { %>
<!-- 相邻文章 -->
<nav class="Article-siblings LightBox col-md-9">
Expand Down Expand Up @@ -49,6 +42,7 @@
<div class="Article-comments col-md-9"><%- partial('_ksio/widgets/comment') %></div>
<% } %>
</article>
<%- partial('_ksio/slots/aside') %>
</div>
</main>
<%- partial(theme.footer && theme.footer.partial || '_ksio/partials/footer') %>
1 change: 1 addition & 0 deletions src/hexo/themes/lime/layout/_ksio/slots/aside.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<% if ( page.ksio_slot_aside ) { %><div class="Page-sidebar col-md-3"><%- partial(page.ksio_slot_aside) %></div><% } %>
11 changes: 11 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/slots/banner.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% if (page.ksio_slot_banner) { %>
<%- partial(page.ksio_slot_banner) %>
<% } else if (page.banner) { %>
<!-- 页面横幅 -->
<div class="Page-banner hidden-xs" style="background-image: url('<%= url_for(banner.url) %>');">
<figure class="sr-only">
<%- image_tag(page.banner.url, { alt: page.banner.description || '' }) %>
<figcaption><%= page.banner.description %></figcaption>
</figure>
</div>
<% } %>
6 changes: 6 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/slots/footer.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if ( page.ksio_slot_footer ) { %>
<%- partial(page.ksio_slot_footer) %>
<% } else { %>
<%- partial('_ksio/widgets/share') %>
<%- partial('_ksio/widgets/toc') %>
<% } %>
10 changes: 10 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/slots/header.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if ( page.ksio_slot_header ) { %>
<%- partial(page.ksio_slot_header) %>
<% } else { %>
<% if ( page.ksio_slot_title ) { %>
<h1 class="Article-title"><%- partial(page.ksio_slot_title) %></h1>
<% } else { %>
<h1 class="Article-title"><%= page.title %></h1>
<% } %>
<% if ( page.ksio_slot_meta ) { %><%- partial(page.ksio_slot_meta) %><% } %>
<% } %>
2 changes: 1 addition & 1 deletion src/hexo/themes/lime/layout/_ksio/widgets/share.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if (site.ksio.social.share !== false) { %>
<% if ((theme.social || {}).share !== false && page.ksio_shareable !== false) { %>
<div class="Widget Widget--share">
<div class="Widget-body">
<p>分享到<i class="fa fa-share-alt"></i></p>
Expand Down

0 comments on commit 8ce5dd6

Please sign in to comment.