From fc68fbe9a32261a51220b6a936e5fb421343a342 Mon Sep 17 00:00:00 2001
From: Mimi <1119186082@qq.com>
Date: Thu, 30 Jul 2020 17:33:12 +0800
Subject: [PATCH] Refactor group-pictures using flex layout
---
layout/_macro/post.njk | 4 ++-
scripts/tags/group-pictures.js | 6 ++--
.../_common/components/post/post-gallery.styl | 9 ++++--
.../scaffolding/tags/group-pictures.styl | 28 +++++++++++--------
test/tags/group-pictures.js | 8 +++---
5 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/layout/_macro/post.njk b/layout/_macro/post.njk
index 7fa5cf0..720ca51 100644
--- a/layout/_macro/post.njk
+++ b/layout/_macro/post.njk
@@ -18,7 +18,9 @@
{%- if post.photos and post.photos.length %}
{%- for photo in post.photos %}
-
+
+
 }})
+
{%- endfor %}
{%- endif %}
diff --git a/scripts/tags/group-pictures.js b/scripts/tags/group-pictures.js
index 4c20c73..0490759 100644
--- a/scripts/tags/group-pictures.js
+++ b/scripts/tags/group-pictures.js
@@ -82,7 +82,7 @@ const templates = {
dispatch: function(pictures, group, layout) {
const rule = LAYOUTS[group] ? LAYOUTS[group][layout] : null;
- return rule ? this.getHTML(groupBy(rule, pictures)) : templates.defaults(pictures);
+ return rule ? this.getHTML(groupBy(rule, pictures)) : this.defaults(pictures);
},
/**
@@ -113,10 +113,8 @@ const templates = {
},
getColumnHTML: function(pictures) {
- const columnWidth = 100 / pictures.length;
- const columnStyle = `style="width: ${columnWidth}%;"`;
return pictures.map(picture => {
- return `