From a57263b6fd3aad855797973aecb98e33f19799fc Mon Sep 17 00:00:00 2001 From: Ourai Lin Date: Fri, 7 Apr 2023 11:26:03 +0800 Subject: [PATCH] feat(hexo): support content slot --- bin/build.js | 1 + src/hexo/_config.yml | 6 +++--- src/hexo/themes/lime/layout/_ksio/layouts/default.ejs | 7 ++++++- src/hexo/themes/lime/layout/_ksio/layouts/doc.ejs | 3 +-- src/hexo/themes/lime/layout/_ksio/layouts/page.ejs | 2 +- src/hexo/themes/lime/layout/_ksio/slots/content.ejs | 1 + src/hexo/themes/lime/source/stylesheets/pages/doc.scss | 1 + src/hexo/themes/lime/source/stylesheets/pages/post.scss | 1 + src/shared/stylesheets/pages/{doc.scss => _doc.scss} | 0 src/shared/stylesheets/pages/{post.scss => _post.scss} | 1 - src/shared/stylesheets/pages/{posts.scss => _posts.scss} | 0 11 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 src/hexo/themes/lime/layout/_ksio/slots/content.ejs create mode 100644 src/hexo/themes/lime/source/stylesheets/pages/doc.scss create mode 100644 src/hexo/themes/lime/source/stylesheets/pages/post.scss rename src/shared/stylesheets/pages/{doc.scss => _doc.scss} (100%) rename src/shared/stylesheets/pages/{post.scss => _post.scss} (98%) rename src/shared/stylesheets/pages/{posts.scss => _posts.scss} (100%) diff --git a/bin/build.js b/bin/build.js index 7950855..c861e06 100644 --- a/bin/build.js +++ b/bin/build.js @@ -19,6 +19,7 @@ function copyAssets(distRoot, polyfill) { }); const distStyleDirPath = `${distRoot}/stylesheets/ksio/`; + const shareSnsStyleFilePath = `${distStyleDirPath}/vendors/share.scss`; const shareSnsStyleFileContent = readData(shareSnsStyleFilePath); diff --git a/src/hexo/_config.yml b/src/hexo/_config.yml index 5cabc58..3f476c2 100644 --- a/src/hexo/_config.yml +++ b/src/hexo/_config.yml @@ -165,7 +165,7 @@ ksio: type: posts values: ksio_asset_css: - - stylesheets/ksio/pages/post + - stylesheets/pages/post ksio_asset_js: - javascripts/ksio/vendors/jquery.timeago - javascripts/ksio/vendors/jquery.timeago.zh-CN @@ -177,8 +177,8 @@ ksio: values: layout: ksio/doc ksio_asset_css: - - stylesheets/ksio/pages/post - - stylesheets/ksio/pages/doc + - stylesheets/pages/post + - stylesheets/pages/doc ksio_asset_js: - javascripts/ksio/vendors/jquery.timeago - javascripts/ksio/vendors/jquery.timeago.zh-CN diff --git a/src/hexo/themes/lime/layout/_ksio/layouts/default.ejs b/src/hexo/themes/lime/layout/_ksio/layouts/default.ejs index 4d5f43c..db8217c 100644 --- a/src/hexo/themes/lime/layout/_ksio/layouts/default.ejs +++ b/src/hexo/themes/lime/layout/_ksio/layouts/default.ejs @@ -7,8 +7,13 @@ <%- js('javascripts/ksio/vendors/jquery-1.11.3.min') %> <%- js('javascripts/ksio/vendors/bootstrap.min') %> - + <% const bodyClass = ['Page'] %> + <% if (page.ksio_slot_banner || page.banner) { %> + <% bodyClass.push('has-headerImage') %> + <% } %> + <%- body %> + <% [].concat(page.ksio_asset_js || []).forEach(jsPath => { %><%- js(jsPath) %><% }) %> diff --git a/src/hexo/themes/lime/layout/_ksio/layouts/doc.ejs b/src/hexo/themes/lime/layout/_ksio/layouts/doc.ejs index 3cf15ad..c448693 100644 --- a/src/hexo/themes/lime/layout/_ksio/layouts/doc.ejs +++ b/src/hexo/themes/lime/layout/_ksio/layouts/doc.ejs @@ -12,10 +12,9 @@
<%- partial('_ksio/slots/header') %>
-
<%- page.content %>
+
<%- partial('_ksio/slots/content') %>
<%- partial(theme.footer && theme.footer.partial || '_ksio/partials/footer') %> - diff --git a/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs b/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs index 8cc6071..871a811 100644 --- a/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs +++ b/src/hexo/themes/lime/layout/_ksio/layouts/page.ejs @@ -7,7 +7,7 @@
<%- partial('_ksio/slots/header') %>
-
<%- page.content %>
+
<%- partial('_ksio/slots/content') %>
<% if (page.siblings === true) { %> diff --git a/src/hexo/themes/lime/layout/_ksio/slots/content.ejs b/src/hexo/themes/lime/layout/_ksio/slots/content.ejs new file mode 100644 index 0000000..df54b5f --- /dev/null +++ b/src/hexo/themes/lime/layout/_ksio/slots/content.ejs @@ -0,0 +1 @@ +<%- page.ksio_slot_content ? partial(page.ksio_slot_content) : page.content %> diff --git a/src/hexo/themes/lime/source/stylesheets/pages/doc.scss b/src/hexo/themes/lime/source/stylesheets/pages/doc.scss new file mode 100644 index 0000000..6d32b21 --- /dev/null +++ b/src/hexo/themes/lime/source/stylesheets/pages/doc.scss @@ -0,0 +1 @@ +@import "../ksio/pages/doc"; diff --git a/src/hexo/themes/lime/source/stylesheets/pages/post.scss b/src/hexo/themes/lime/source/stylesheets/pages/post.scss new file mode 100644 index 0000000..e91f1bd --- /dev/null +++ b/src/hexo/themes/lime/source/stylesheets/pages/post.scss @@ -0,0 +1 @@ +@import "../ksio/pages/post"; diff --git a/src/shared/stylesheets/pages/doc.scss b/src/shared/stylesheets/pages/_doc.scss similarity index 100% rename from src/shared/stylesheets/pages/doc.scss rename to src/shared/stylesheets/pages/_doc.scss diff --git a/src/shared/stylesheets/pages/post.scss b/src/shared/stylesheets/pages/_post.scss similarity index 98% rename from src/shared/stylesheets/pages/post.scss rename to src/shared/stylesheets/pages/_post.scss index 9ac40e4..e45a98e 100644 --- a/src/shared/stylesheets/pages/post.scss +++ b/src/shared/stylesheets/pages/_post.scss @@ -1,5 +1,4 @@ @import "../../helper"; -@import "../syntax-highlighting"; diff --git a/src/shared/stylesheets/pages/posts.scss b/src/shared/stylesheets/pages/_posts.scss similarity index 100% rename from src/shared/stylesheets/pages/posts.scss rename to src/shared/stylesheets/pages/_posts.scss