推荐文章

i18n
xaoxuu 6 years ago
parent 5d90c9965e
commit e12efcea6f
  1. 5
      README.md
  2. 4
      _config.yml
  3. 54
      layout/_partial/article.ejs
  4. 11
      layout/_partial/post/recommended_posts.ejs

@ -9,7 +9,7 @@
## 依赖库
```bash
npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autoprefixer hexo-generator-json-content
npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autoprefixer hexo-generator-json-content hexo-recommended-posts
```
@ -26,6 +26,7 @@ npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autop
- 优化了颜色搭配,方便更换主题色。
- 一些UI细节,如调整搜索框长度使之与右边卡片等宽、优化了在手机端的显示效果。
- 增加对来必力评论系统的支持。
- 增加了推荐文章列表,增加流量。
@ -59,7 +60,7 @@ disqus_shortname: xaoxuu
# change to work dir
cd /your_blog_dir/
# install dependencies
npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autoprefixer hexo-generator-json-content
npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autoprefixer hexo-generator-json-content hexo-recommended-posts
# download source
git clone https://github.com/xaoxuu/hexo-theme-material-x themes/material-x
```

@ -84,3 +84,7 @@ contacts:
# - name: Twitter
# badget: "@xaoxuu"
# url: https://www.twitter.com/xaoxuu
# 推荐文章 npm install hexo-recommended-posts --save
recommended_posts:
enabled: true # 根目录的_config.yml中的recommended_posts/autoDisplay: 要设置为false

@ -34,6 +34,7 @@
</div>
<% } %>
<% if(post.prev || post.next){ %>
<div class="art-item-footer">
<% if(post.prev){ %>
@ -51,31 +52,41 @@
</section>
<% if (post.comments && config.livere_shortname){ %>
<section id="comments">
<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTU4Ny82MTU1">
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
</article>
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
<br>
<article class="post white-box article-type-<%= post.layout %>>">
<section class="article typo">
<% if (post.comments && config.livere_shortname){ %>
<section id="comments">
<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTU4Ny82MTU1">
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
</section>
<% } %>
<% if (post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">⚠无法加载评论系统,请确保您的网络能够正常访问 <a href="https://disqus.com">Disqus</a> 。</div>
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
</section>
<% } %>
<% if (post.comments && config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread">⚠无法加载评论系统,请确保您的网络能够正常访问 <a href="https://disqus.com">Disqus</a> 。</div>
</section>
<% } %>
<% if (post && theme.recommended_posts.enabled) { %>
<%- partial('post/recommended_posts', {page: post, site: site}) %>
<% } %>
</section>
<% } %>
</article>
<script>
@ -84,3 +95,4 @@
tools: true
}
</script>
<!-- recommended posts -->

@ -0,0 +1,11 @@
<% var post_list = recommended_posts(page, site) %>
<% if(post_list.length > 0) { %>
<div class="recommended_posts">
<h4>推荐文章</h4>
<ul>
<% post_list.forEach(function(link) { %>
<li><a href="<%= link.permalink %>"><%= link.title %></a></li>
<% }) %>
</ul>
</div>
<% } %>
Loading…
Cancel
Save