Skip to content

允许每个md文件调用独立的css文件 #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -499,8 +499,8 @@ index:
slogan:
enable: true

# 为空则按 hexo config.subtitle 显示
# If empty, text based on `subtitle` in hexo config
# 为空则按 hexo config.subtitle 显示,支持列表格式来实现随机选择一行文字显示
# If empty, text based on `subtitle` in hexo config, support list format to random selection of a row for display
text: "An elegant Material-Design theme for Hexo"

# 通过 API 接口作为首页副标题的内容,必须返回的是 JSON 格式,如果请求失败则按 text 字段显示,该功能必须先开启 typing 打字机功能
@@ -779,11 +779,16 @@ utterances:
# See: https://disqus.com
disqus:
shortname:
# 以下为 Disqusjs 支持, 国内用户如果想使用 Disqus 建议配合使用
# The following are Disqusjs configurations, please ignore if DisqusJS is not required
# 以下为 Disqusjs 支持, 国内用户如果想使用 Disqus 建议配合使用,支持填入多个 apikey,建议自行搭建 api 端点
# The following are Disqusjs configurations, please ignore if DisqusJS is not required, it supports filling in multiple apikeys, it is recommended to build the API endpoint by yourself
# See: https://github.com/SukkaW/DisqusJS
disqusjs: false
apikey:
apikey:
- 'KEY1'
#- 'KEY2'
api: https://disqus.skk.moe/disqus/
admin:
adminLabel:

# Gitalk
# 基于 GitHub Issues
7 changes: 6 additions & 1 deletion layout/_partials/comments/disqus.ejs
Original file line number Diff line number Diff line change
@@ -8,7 +8,12 @@
Fluid.utils.createScript('<%= url_join(theme.static_prefix.disqusjs, 'disqus.js') %>', function() {
new DisqusJS({
shortname: '<%= theme.disqus.shortname %>',
apikey: '<%= theme.disqus.apikey %>'
apikey: <%- JSON.stringify(theme.disqus.apikey) %>,
api: '<%= theme.disqus.api %>',
url: '<%= page.permalink %>',
identifier: '<%= url_for(page.path) %>',
admin: '<%= theme.disqus.admin %>',
adminLabel: '<%= theme.disqus.adminLabel %>'
});
});
});
26 changes: 20 additions & 6 deletions layout/_partials/css.ejs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

<% var css_snippets = deduplicate(page.css_snippets) %>
<% for (var idx = 0; idx < css_snippets.length; idx++) { %>
<%- css_snippets[idx] %>
<%- css_snippets[idx] %>
<% } %>
<% page.css_snippets = [] %>

@@ -15,12 +15,26 @@
<%- css_ex(theme.static_prefix.internal_css, 'main.css') %>

<% if (theme.code.highlight.enable) { %>
<%- css_ex(theme.static_prefix.internal_css, 'highlight.css', 'id="highlight-css"') %>
<% if (theme.dark_mode.enable) { %>
<%- css_ex(theme.static_prefix.internal_css, 'highlight-dark.css', 'id="highlight-css-dark"') %>
<% } %>
<%- css_ex(theme.static_prefix.internal_css, 'highlight.css', 'id="highlight-css"') %>
<% if (theme.dark_mode.enable) { %>
<%- css_ex(theme.static_prefix.internal_css, 'highlight-dark.css', 'id="highlight-css-dark"') %>
<% } %>
<% } %>

<% if (theme.custom_css) { %>
<%- css(theme.custom_css) %>
<%- css(theme.custom_css) %>
<% } %>

<%
function toCamelCase(str) {
return str
.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, (match, index) =>
index === 0 ? match.toLowerCase() : match.toUpperCase()
)
.replace(/\s+/g, ''); // 去掉空格
}
%>

<% if (page.css) { %>
<%- css_ex(theme.static_prefix.internal_css, `${toCamelCase(page.css)}.css` ) %>
<% } %>
4 changes: 4 additions & 0 deletions layout/_partials/plugins/typed.ejs
Original file line number Diff line number Diff line change
@@ -40,6 +40,10 @@
typing(text);
}
})
<% } else if (Array.isArray(theme.index.slogan.text) && theme.index.slogan.text.length > 0) { %>
var texts = <%- JSON.stringify(theme.index.slogan.text) %>;
var idx = Math.floor(Math.random() * texts.length);
typing(texts[idx]);
<% } else { %>
typing(text);
<% } %>
9 changes: 3 additions & 6 deletions scripts/helpers/wordcount.js
Original file line number Diff line number Diff line change
@@ -5,13 +5,10 @@
const { stripHTML } = require('hexo-util');

const getWordCount = (post) => {
// post.origin is the original post content of hexo-blog-encrypt
const content = stripHTML(post.origin || post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '');

if (!post.wordcount) {
const zhCount = (content.match(/[\u4E00-\u9FA5]/g) || []).length;
const enCount = (content.replace(/[\u4E00-\u9FA5]/g, '').match(/[a-zA-Z0-9_\u0392-\u03c9\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|\w+/g) || []).length;
post.wordcount = zhCount + enCount
// post.origin is the original post content of hexo-blog-encrypt
const content = stripHTML(post.origin || post.content).replace(/[\s\r\n]/g, '');
post.wordcount = content.length;
}
return post.wordcount;
};
8 changes: 8 additions & 0 deletions source/js/events.js
Original file line number Diff line number Diff line change
@@ -30,8 +30,16 @@ Fluid.events = {
}
});
jQuery('#navbar-toggler-btn').on('click', function() {
var $this = jQuery(this);
if ($this.data('animating')) {
return;
}
$this.data('animating', true);
jQuery('.animated-icon').toggleClass('open');
jQuery('#navbar').toggleClass('navbar-col-show');
setTimeout(function() {
$this.data('animating', false);
}, 300);
});
},

6 changes: 3 additions & 3 deletions source/js/umami-view.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 从配置文件中获取 umami 的配置
const website_id = CONFIG.web_analytics.umami.website_id;
// 拼接请求地址
const request_url = `${CONFIG.web_analytics.umami.api_server}/websites/${website_id}/stats`;
const request_url = `${CONFIG.web_analytics.umami.api_server}/api/websites/${website_id}/stats`;

const start_time = new Date(CONFIG.web_analytics.umami.start_time).getTime();
const end_time = new Date().getTime();
@@ -31,7 +31,7 @@ const request_header = {
method: "GET",
headers: {
"Content-Type": "application/json",
"x-umami-api-key": "oZKCH3msvqt10VlXKwoJvHclmaS4bVx0",
"Authorization": "Bearer " + token,
},
};

@@ -40,7 +40,7 @@ async function siteStats() {
try {
const response = await fetch(`${request_url}?${params}`, request_header);
const data = await response.json();
const uniqueVisitors = data.uniques.value; // 获取独立访客数
const uniqueVisitors = data.visitors.value; // 获取独立访客数
const pageViews = data.pageviews.value; // 获取页面浏览量

let pvCtn = document.querySelector("#umami-site-pv-container");