Skip to content

Commit

Permalink
相片集 Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
nexmoe committed Jan 31, 2021
1 parent b611764 commit 7936fab
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
8 changes: 8 additions & 0 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
<% if (theme.cdn.copy) { %>
<script src="<%- theme.cdn.copy %>"></script>
<% } %> <%- js_auto_version('js/app') %>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/jquery.justifiedGallery.min.js"></script>
<script>
$(".justified-gallery").justifiedGallery({
rowHeight: 200,
margins: 10,
});
</script>
1 change: 1 addition & 0 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<link rel="shortcut icon" href="<%= theme.favicon.href %>" type="<%= theme.favicon.type %>" />
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/combine/npm/[email protected]/styles/atom-one-dark.css,gh/nexmoe/nexmoe.github.io@latest/lib/mdui_043tiny/css/mdui.css,gh/nexmoe/nexmoe.github.io@latest/lib/iconfont/iconfont.css,gh/fancyapps/[email protected]/dist/jquery.fancybox.min.css?v=233" crossorigin>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/justifiedGallery.min.css">
<% if (theme.iconlib) { %>
<link rel="stylesheet" href="<%= theme.iconlib %>">
<% } %>
Expand Down
21 changes: 21 additions & 0 deletions scripts/tag/gallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";

hexo.extend.tag.register(
"gallery",
function (args, content) {
return `<div class="justified-gallery">${hexo.render
.renderSync({
text: content,
engine: "markdown",
})
.replace(/<br>/gi, "")
.replace(/<p>/gi, "")
.replace(/<p\/?>/gi, "")
.replace(
/<img.*?src="(.*?)" alt="(.*?)".*?\/?>/gi,
'<div><img alt="$2" src="$1" data-src="$1" data-fancybox="gallery"></div>'
)}
</div>`;
},
{ ends: true }
);
9 changes: 9 additions & 0 deletions source/css/_partial/article.styl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ article table.nexmoe-album img {
object-fit: cover;
}

.justified-gallery {
margin: -10px;
}

.jg-entry {
border-radius: 10px;
overflow hidden
}

article img {
display: block;
border-radius: 10px;
Expand Down
2 changes: 1 addition & 1 deletion source/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ $("table")
function search() {
window.open($("#search_form").attr("action_e") + " " + $("#search_value").val());
return false;
}
}

0 comments on commit 7936fab

Please sign in to comment.