Skip to content

Commit

Permalink
fixed #35, fixed #36
Browse files Browse the repository at this point in the history
  • Loading branch information
codefine committed Dec 20, 2018
1 parent f7eb906 commit 4a27724
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 73 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
hexo-theme-mellow
=================
[![](https://img.shields.io/badge/release-v1.3.9-blue.svg?style=flat-square)](https://github.com/codefine/hexo-theme-mellow/releases)
[![](https://img.shields.io/badge/release-v1.4.0-blue.svg?style=flat-square)](https://github.com/codefine/hexo-theme-mellow/releases)
[![](https://img.shields.io/badge/document-CN-green.svg?style=flat-square)](https://github.com/codefine/hexo-theme-mellow/wiki)
[![](https://img.shields.io/badge/preview-Michael.Lu's%20blog-ff69b4.svg?style=flat-square)](https://blog.lujingtao.com)
[![Join the chat at https://gitter.im/hexo-theme-mellow/Lobby](https://badges.gitter.im/hexo-theme-mellow/Lobby.svg)](https://gitter.im/codefine/hexo-theme-mellow?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
Expand Down Expand Up @@ -36,7 +36,7 @@ Material Design 风格的Hexo主题,基于 **Hexo 3.0+** & **Node 7.x+** 制

## FAQ

初次使用时`hexo g`报错,大部分情况是因为**缺少依赖**。前往[wiki-主题安装](https://github.com/codefine/hexo-theme-mellow/wiki/1.-%E4%B8%BB%E9%A2%98%E5%AE%89%E8%A3%85)查看如何安装依赖。
初次使用时`hexo g`报错,大部分情况是因为**缺少依赖**,或者依赖版本问题。前往[wiki-主题安装](https://github.com/codefine/hexo-theme-mellow/wiki/1.-%E4%B8%BB%E9%A2%98%E5%AE%89%E8%A3%85)查看如何安装依赖。

## Community

Expand Down
115 changes: 55 additions & 60 deletions layout/_partial/post.ejs
Original file line number Diff line number Diff line change
@@ -1,61 +1,56 @@
<article id="<%= post.layout %>-<%= post.slug %>"
class="post-article article-type-<%= post.layout %>" itemprop="blogPost">
<div class="post-card">
<h1 class="post-card-title"><%- post.title %></h1>
<div class="post-meta">
<%- partial('post/date', {date_format: config.date_format}) %>
<%- partial('post/category') %>
<%- partial('post/visitor') %>
<%- partial('post/comment-count') %>
<%- partial('post/music') %>
</div>
<div class="post-content" id="post-content" itemprop="postContent">
<%
post.content = post.content.replace(/<img([^>]+)>/g, function(img) {
var src = img.replace(/<img.+src(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
var title = img.replace(/<img.+title(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
var alt = img.replace(/<img.+alt(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
title = title !== img && title ? title : (alt !== img && alt ? alt : "");
return `<a rel=${post.title} href="${src}" title="${title}" data-fancybox="images">${img}</a>`;
});
post.content = post.content.replace(/<table class="table">(.+)<\/table>/, function(match, $1) {
$1 = $1.replace(/<br>/g, '');
return `<table>${$1}</table>`;
});
%>
<%- post.content.replace(/<p>}<\/p>/g, '</div>')
.replace(/<p>@([\w-]+){<\/p>/g, function(match, $1){
return '<div class="'+ $1 +'">'
}) %>
</div>
<%- partial('post/copyright') %>
<% if (post.reward || typeof post.reward === "undefined") {
if (theme.reward.alipay || theme.reward.wechat) { %>
<%- partial('post/reward-btn') %>
<% } %>
<% } %>
<div class="post-footer">
<%- partial('post/tag') %>
<%- partial('post/share-fab') %>
</div>
<% if (post.comment || typeof post.comment === "undefined") { %>
<%- partial('post/comment') %>
<% } %>
</div>
<%- partial('post/nav') %>
<% if (page.repo) { %>
<%- partial('post/repo') %>
<% } %>
<%- partial('post/toc', { post: page}) %>
</article>
<% if (post.reward || typeof post.reward === "undefined") {
if (theme.reward.alipay || theme.reward.wechat) { %>
<%- partial('post/reward') %>
<% }
} %>
class="post-article article-type-<%= post.layout %>" itemprop="blogPost">
<div class="post-card">
<h1 class="post-card-title"><%- post.title %></h1>
<div class="post-meta">
<%- partial('post/date', {date_format: config.date_format}) %>
<%- partial('post/category') %>
<%- partial('post/visitor') %>
<%- partial('post/comment-count') %>
<%- partial('post/music') %>
</div>
<div class="post-content" id="post-content" itemprop="postContent">
<%
post.content = post.content.replace(/<img([^>]+)>/g, function(img) {
var src = img.match(/src="([^"]+)"/)[1];
var title = img.match(/title="([^"]+)"/) ? img.match(/title="([^"]+)"/)[1] : '';
var alt = img.match(/alt="([^"]+)"/) ? img.match(/alt="([^"]+)"/)[1] : '';
title = title !== img && title ? title : (alt !== img && alt ? alt : "");
return `<a rel=${post.title} href="${src}" title="${title}" data-fancybox="images">${img}</a>`;
});
post.content = post.content.replace(/<table class="table">(.+)<\/table>/, function(match, $1) {
$1 = $1.replace(/<br>/g, '');
return `<table>${$1}</table>`;
});
%>
<%- post.content.replace(/<p>}<\/p>/g, '</div>')
.replace(/<p>@([\w-]+){<\/p>/g, function(match, $1){
return '<div class="'+ $1 +'">'
}) %>
</div>
<%- partial('post/copyright') %>
<% if (post.reward || typeof post.reward === "undefined") {
if (theme.reward.alipay || theme.reward.wechat) { %>
<%- partial('post/reward-btn') %>
<% } %>
<% } %>
<div class="post-footer">
<%- partial('post/tag') %>
<%- partial('post/share-fab') %>
</div>
<% if (post.comment || typeof post.comment === "undefined") { %>
<%- partial('post/comment') %>
<% } %>
</div>
<%- partial('post/nav') %>
<% if (page.repo) { %>
<%- partial('post/repo') %>
<% } %>
<%- partial('post/toc', { post: page}) %>
</article>
<% if (post.reward || typeof post.reward === "undefined") {
if (theme.reward.alipay || theme.reward.wechat) { %>
<%- partial('post/reward') %>
<% }
} %>

1 change: 0 additions & 1 deletion layout/_partial/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<script type="text/javascript" src="<%- url_for(theme_js('/js/blog', cache)) %>"></script>

<!-- third-party -->
<%- partial("_third-party/swipebox") %>

<% if (page.repo) { %>
<%- partial("_third-party/github_repo") %>
Expand Down
12 changes: 3 additions & 9 deletions layout/page.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
page.reward = 'reward' in page ? !!theme.reward && !!page.reward : !!theme.reward;
page.slug = 'hexo-page-' + page.path.replace(/\/index\.html$/,'').split('/').join('-');
page.content = page.content.replace(/<img([^>]+)>/g, function(img) {
var src = img.replace(/<img.+src(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
var title = img.replace(/<img.+title(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
var alt = img.replace(/<img.+alt(="([^"]+)")*.+>/, function($1, $2, $3) {
return $3;
});
var src = img.match(/src="([^"]+)"/)[1];
var title = img.match(/title="([^"]+)"/) ? img.match(/title="([^"]+)"/)[1] : '';
var alt = img.match(/alt="([^"]+)"/) ? img.match(/alt="([^"]+)"/)[1] : '';
title = title !== img && title ? title : (alt !== img && alt ? alt : "");
return `<a rel=${page.title} href="${src}" title="${title}" data-fancybox="images">${img}</a>`;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-mellow",
"version": "1.3.9",
"version": "1.4.0",
"description": "Material Design theme for Hexo.",
"keywords": [
"hexo",
Expand Down

0 comments on commit 4a27724

Please sign in to comment.