From 8ce5dd6454c283a029b878516a0cd0a1938c9b98 Mon Sep 17 00:00:00 2001 From: Ourai Lin Date: Tue, 4 Apr 2023 16:56:52 +0800 Subject: [PATCH] feat(hexo): customizable slots --- src/hexo/themes/lime/layout/_ksio/layouts/page.ejs | 14 ++++---------- src/hexo/themes/lime/layout/_ksio/slots/aside.ejs | 1 + src/hexo/themes/lime/layout/_ksio/slots/banner.ejs | 11 +++++++++++ src/hexo/themes/lime/layout/_ksio/slots/footer.ejs | 6 ++++++ src/hexo/themes/lime/layout/_ksio/slots/header.ejs | 10 ++++++++++ .../themes/lime/layout/_ksio/widgets/share.ejs | 2 +- 6 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 src/hexo/themes/lime/layout/_ksio/slots/aside.ejs create mode 100644 src/hexo/themes/lime/layout/_ksio/slots/banner.ejs create mode 100644 src/hexo/themes/lime/layout/_ksio/slots/footer.ejs create mode 100644 src/hexo/themes/lime/layout/_ksio/slots/header.ejs diff --git a/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs b/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs index ba16218..8cc6071 100644 --- a/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs +++ b/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs @@ -1,21 +1,14 @@ <%- partial(theme.header && theme.header.partial || '_ksio/partials/header') %>
- <% if (page.banner) { %> - - - <% } %> + <%- partial('_ksio/slots/banner') %>
-

<%= page.title %>

+ <%- partial('_ksio/slots/header') %>
<%- page.content %>
+
<%- partial('_ksio/slots/footer') %>
<% if (page.siblings === true) { %>
+ <%- partial('_ksio/slots/aside') %>
<%- partial(theme.footer && theme.footer.partial || '_ksio/partials/footer') %> diff --git a/src/hexo/themes/lime/layout/_ksio/slots/aside.ejs b/src/hexo/themes/lime/layout/_ksio/slots/aside.ejs new file mode 100644 index 0000000..9d457f1 --- /dev/null +++ b/src/hexo/themes/lime/layout/_ksio/slots/aside.ejs @@ -0,0 +1 @@ +<% if ( page.ksio_slot_aside ) { %>
<%- partial(page.ksio_slot_aside) %>
<% } %> diff --git a/src/hexo/themes/lime/layout/_ksio/slots/banner.ejs b/src/hexo/themes/lime/layout/_ksio/slots/banner.ejs new file mode 100644 index 0000000..6f0299c --- /dev/null +++ b/src/hexo/themes/lime/layout/_ksio/slots/banner.ejs @@ -0,0 +1,11 @@ +<% if (page.ksio_slot_banner) { %> + <%- partial(page.ksio_slot_banner) %> +<% } else if (page.banner) { %> + + +<% } %> diff --git a/src/hexo/themes/lime/layout/_ksio/slots/footer.ejs b/src/hexo/themes/lime/layout/_ksio/slots/footer.ejs new file mode 100644 index 0000000..d6c4368 --- /dev/null +++ b/src/hexo/themes/lime/layout/_ksio/slots/footer.ejs @@ -0,0 +1,6 @@ +<% if ( page.ksio_slot_footer ) { %> + <%- partial(page.ksio_slot_footer) %> +<% } else { %> + <%- partial('_ksio/widgets/share') %> + <%- partial('_ksio/widgets/toc') %> +<% } %> diff --git a/src/hexo/themes/lime/layout/_ksio/slots/header.ejs b/src/hexo/themes/lime/layout/_ksio/slots/header.ejs new file mode 100644 index 0000000..b2a4310 --- /dev/null +++ b/src/hexo/themes/lime/layout/_ksio/slots/header.ejs @@ -0,0 +1,10 @@ +<% if ( page.ksio_slot_header ) { %> + <%- partial(page.ksio_slot_header) %> +<% } else { %> + <% if ( page.ksio_slot_title ) { %> +

<%- partial(page.ksio_slot_title) %>

+ <% } else { %> +

<%= page.title %>

+ <% } %> + <% if ( page.ksio_slot_meta ) { %><%- partial(page.ksio_slot_meta) %><% } %> +<% } %> diff --git a/src/hexo/themes/lime/layout/_ksio/widgets/share.ejs b/src/hexo/themes/lime/layout/_ksio/widgets/share.ejs index 410f7a5..6acec3b 100644 --- a/src/hexo/themes/lime/layout/_ksio/widgets/share.ejs +++ b/src/hexo/themes/lime/layout/_ksio/widgets/share.ejs @@ -1,4 +1,4 @@ -<% if (site.ksio.social.share !== false) { %> +<% if ((theme.social || {}).share !== false && page.ksio_shareable !== false) { %>

分享到