Skip to content

Commit

Permalink
feat(hexo): basic layouts for pages and posts
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Mar 29, 2023
1 parent 9f64bea commit b4ed72c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 13 deletions.
10 changes: 10 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/layouts/default.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="<%= config.language %>" dir="ltr">
<head>
<%- partial('_ksio/partials/head') %>
<%- css('stylesheets/global') %>
<%- js('javascripts/ksio/vendors/jquery-1.11.3.min') %>
<%- js('javascripts/ksio/vendors/bootstrap.min') %>
</head>
<body class="Page" itemscope itemtype="http:https://schema.org/WebPage"><%- body %></body>
</html>
54 changes: 54 additions & 0 deletions src/hexo/themes/lime/layout/_ksio/layouts/page.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<%- 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>
<% } %>
<!-- 内容主体 -->
<div class="container">
<article class="Page-main Article">
<header class="Article-header">
<h1 class="Article-title"><%= page.title %></h1>
</header>
<div class="Article-content col-md-9"><%- page.content %></div>
<% if (page.siblings === true) { %>
<!-- 相邻文章 -->
<nav class="Article-siblings LightBox col-md-9">
<ul>
<% ['prev', 'next'].forEach(sibling_key => { %>
<% const sibling = page[sibling_key] %>
<% let class_name = `Sibling Sibling--${sibling_key}` %>
<% if (sibling && sibling.url) { %>
<% let sibling_image = "none" %>
<% if (sibling.banner) { %>
<% sibling_image = `url('${url_for(sibling.banner.url)}')` %>
<% } else { %>
<% class_name = `${class_name} u-noCover ` %>
<% } %>
<li class="<%= class_name %>">
<a href="<%= sibling.url %>" style="background-image: <%= sibling_image %>;">
<h3><%= sibling.title %></h3>
<p><%- truncate(escape_html(trim(strip_html(markdown(sibling.excerpt)))), 100) %></p>
</a>
</li>
<% } %>
<% }) %>
</ul>
</nav>
<% } %>
<% if (page.comments === true) { %>
<!-- 评论区 -->
<div class="Article-comments col-md-9"><!--% include ksio/widgets/disqus.html %--></div>
<% } %>
</article>
</div>
</main>
<%- partial(theme.footer && theme.footer.partial || '_ksio/partials/footer') %>
14 changes: 1 addition & 13 deletions src/hexo/themes/lime/layout/layout.ejs
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
<!DOCTYPE html>
<html lang="<%= config.language %>" dir="ltr">
<head>
<%- partial('_ksio/partials/head') %>
<%- css('stylesheets/global') %>
<% if (page.__index) { %>
<!--%- css('stylesheets/pages/home') %-->
<% } %>
<%- js('javascripts/ksio/vendors/jquery-1.11.3.min') %>
<%- js('javascripts/ksio/vendors/bootstrap.min') %>
</head>
<body class="Page" itemscope itemtype="http:https://schema.org/WebPage"><%- body %></body>
</html>
<%- partial('_ksio/layouts/default') %>
1 change: 1 addition & 0 deletions src/hexo/themes/lime/layout/page.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%- partial('_ksio/layouts/page') %>
1 change: 1 addition & 0 deletions src/hexo/themes/lime/layout/post.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%- partial('_ksio/layouts/page') %>

0 comments on commit b4ed72c

Please sign in to comment.