Skip to content

Commit

Permalink
Merge pull request #44 from jpazureid/wahaniya-dev
Browse files Browse the repository at this point in the history
Update themes
  • Loading branch information
watahani authored May 1, 2023
2 parents 6d48a1d + fb3aa6d commit cea945c
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 63 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,24 @@ root_tag_generator:
github:
url: https://github.com/jpazureid/blog/
posts_dir: articles
default_branch: main
show_additional_info: true

# https://hexo.io/docs/helpers#toc
toc:
# if true, toc will be auto display in all article which has more than one h2 tag
enabled: false
min_depth: 1
max_depth: 4
list_number: false


# show disclaimer in all article by default. disableDisclaimer of article's option set true hide.
# ex)
# ---
# title: Article Title
# date: 2020-04-30 10:00
# disableDisclaimer: true
# ---
disclaimer: ※本情報の内容(添付文書、リンク先などを含む)は、作成日時点でのものであり、予告なく変更される場合があります。
```
2 changes: 0 additions & 2 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
</script>
<% } %>

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<%- js('js/script') %>
<%- partial('gauges-analytics') %>
20 changes: 18 additions & 2 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<%- partial('post/title', {class_name: 'article-title'}) %>
</header>
<div class="article-share">
Last Update:
Published:
<%- partial('post/date', {class_name: 'article-date-single', date_format: null}) %>
<% if (github && config.github.show_additional_info) { %>
<%- partial('post/githubinfo', {class_name: 'article-date-single', source_url: github.sourceUrl }) %>
<% } %>
<%- partial('post/category') %>
<% if(github){
%>
Expand All @@ -27,7 +30,20 @@
<a href="<%- url_for(post.path) %>#more"><%= theme.excerpt_link %></a>
</p>
<% } %>
<% } else { %>
<% } else {
if (post.toc && !post.toc.enabled){
//disabled toc for this post
} else if ((config.toc && config.toc.enabled) || (post.toc && post.toc.enabled)){
var tocOptions = Object.assign({}, config.toc, post.toc);
%>
<% var tocContent =toc (post.content, tocOptions);
if (tocContent) { %>
<div class="toc-wrapper">
<h2 id="toc-header" class="toc-header">この記事の内容</h2>
<%- tocContent %>
</div>
<% }
} %>
<%- post.content %>
<% } %>
<% if (!post.disableDisclaimer && config.disclaimer){ %>
Expand Down
3 changes: 3 additions & 0 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<% } %>
<div class="outer">
<div id="footer-info" class="inner">
<a href="https://privacy.microsoft.com/ja-jp/privacystatement" target="_blank" rel=”noopener”>Privacy & Cookies</a> |
<a href="https://www.microsoft.com/ja-jp/legal/intellectualproperty/copyright" target="_blank" rel=”noopener”>Terms of use</a> |
<a href="https://www.microsoft.com/ja-jp/legal/intellectualproperty/trademarks" target="_blank" rel=”noopener”>Trademarks</a> |
&copy; <%= date(new Date(), 'YYYY') %> <%= config.author || config.title %><br>
<%= __('powered_by') %> <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
Expand Down
6 changes: 3 additions & 3 deletions layout/_partial/google-analytics.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<% if (theme.google_analytics){ %>
<% if (config.google_analytics){ %>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= theme.google_analytics %>"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= config.google_analytics %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%= theme.google_analytics %>');
gtag('config', '<%= config.google_analytics %>');
</script>
<!-- End Google Analytics -->
<% } %>
1 change: 1 addition & 0 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<% } %>
<%- css('css/style') %>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
49 changes: 49 additions & 0 deletions layout/_partial/post/githubinfo.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/ Last update: <a id="update-time" class="<%= class_name %>"></a>
/ Contributors: <ul style="display: inline-block; list-style:none" id="contributors" class="github-contributors"> </ul>

<script type="text/javascript">
const sourceUrl = "<%- source_url %>";
const urlParts = sourceUrl.split("/");
const user = urlParts[3];
const repo = urlParts[4];
const filePath = urlParts.slice(7).join("/");
const apiUrl = `https://api.github.com/repos/${user}/${repo}/commits?path=${filePath}`;
function formatDate(date) {
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
return year + '-' + month + '-' + day;
}
$.getJSON(apiUrl, function (data) {
const commit = data[0];
const updateDate = new Date(commit.commit.author.date);
const localDate = formatDate(updateDate);
const contributors = new Map();
data.reverse().forEach(function (commit) {
if (commit.author == null) {
return;
} else {
const name = commit.author.login;
const url = commit.author.html_url;
const avatar = commit.author.avatar_url;
contributors.set(name, { name, url, avatar });
}
});
$("#update-time").text(localDate);
$("#update-time").href = commit.html_url;
Array.from(contributors, ([_, value]) => value).reverse().forEach(function (contributor) {
$("#contributors").append(`<li class="contributor-avatar"><a href="https://github.com/${contributor.name}" title="${contributor.name}"><img src="${contributor.avatar}" alt="${contributor.name}"/></a></li>`);
});
});
</script>
113 changes: 60 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cea945c

Please sign in to comment.