diff --git a/layout/_partial/main/post_list/post_card.ejs b/layout/_partial/main/post_list/post_card.ejs
index 0bdeb63..71a46ea 100755
--- a/layout/_partial/main/post_list/post_card.ejs
+++ b/layout/_partial/main/post_list/post_card.ejs
@@ -49,4 +49,7 @@ if (post.categories && post.categories.length > 0) {
<%- layoutCats() %>
<% } %>
<% } %>
+ <% if (post.pin) { %>
+
+ <% } %>
diff --git a/layout/index.ejs b/layout/index.ejs
index a86280e..32c4fec 100755
--- a/layout/index.ejs
+++ b/layout/index.ejs
@@ -9,76 +9,97 @@ if (page.menu_id == undefined) {
if (page.title && page.wiki) {
page.robots = 'noindex,follow';
}
-function layout_h1() {
+
+function layout_post_card(type, post, content) {
+ var el = '';
+ el += '';
+ el += '';
+ el += content;
+ el += '';
+ return el;
+}
+
+function layout_posts(partial) {
+ var el = '';
+ el += '
';
if (is_home()) {
- return '';
+ // pinned posts
+ if (page.current == 1) {
+ var pinned = site.posts.filter(function(post){
+ return post.pin != undefined;
+ }).sort((config.index_generator && config.index_generator.order_by) || '-date');
+ pinned.forEach((post, i) => {
+ el += layout_post_card('post', post, partial(post));
+ });
+ }
+ // unpinned posts
+ page.posts.each(function(post){
+ if (post.pin == undefined) {
+ el += layout_post_card('post', post, partial(post));
+ }
+ })
+ } else {
+ el += '
';
+ el += __('page.filter', config.title, page.category || page.tag, page.posts.length);
+ el += '
';
+ page.posts.each(function(post){
+ el += layout_post_card('post', post, partial(post));
+ })
+ }
+ el += '';
+ return el;
+}
+
+function layout_wikis(partial) {
+ var el = '';
+ var wikis = [];
+ if (page.title && page.wiki) {
+ // filtered wikis
+ page.wiki.forEach((wiki, i) => {
+ site.pages.filter(function (p) {
+ return p.layout == 'wiki' && p.wiki == wiki && p.description;
+ }).limit(1).each(function(post) {
+ wikis.push(post);
+ });
+ });
+ el += '';
+ el += '
' + __("page.wiki", config.title, wikis.length, page.title) + '
';
+ wikis.forEach(function(wiki) {
+ el += layout_post_card('wiki', wiki, partial(wiki));
+ });
+ el += '';
+ } else {
+ // all wikis
+ wikis = site.pages.filter(function (p) {
+ if (p.layout == 'wiki' && p.wiki && p.description) {
+ if (p.order == undefined) {
+ p.order = 0;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }).sort('order');
+ el += '';
+ el += '
' + __("page.wiki", config.title, wikis.length, __('btn.wiki')) + '
';
+ wikis.forEach(function(wiki) {
+ el += layout_post_card('wiki', wiki, partial(wiki));
+ });
+ el += '';
}
- var el = '';
- el += __('page.filter', config.title, page.category || page.tag, page.posts.length);
- el += '
';
return el;
}
%>
+
<% if (page.menu_id == 'post') { %>
<%- partial('_partial/main/navbar/list_post') %>
- <% if (page.posts) { %>
-
- <%- layout_h1() %>
- <% page.posts.each(function(post){ %>
-
-
- <%- partial('_partial/main/post_list/post_card', {post: post}) %>
-
-
- <% }) %>
- <%- partial('_partial/main/post_list/paginator') %>
-
- <% } %>
+ <%- layout_posts(function(post){
+ return partial('_partial/main/post_list/post_card', {post: post})
+ }) %>
+ <%- partial('_partial/main/post_list/paginator') %>
<% } else if (page.menu_id == 'wiki') { %>
- <% function outputExcerpt(post) { %>
-
-
- <%- partial('_partial/main/post_list/wiki_card', {post: post}) %>
-
-
- <% } %>
<%- partial('_partial/main/navbar/list_wiki') %>
- <% if (page.title && page.wiki) { %>
-
- <%
- var wikis = [];
- page.wiki.forEach((wiki, i) => {
- site.pages.filter(function (p) {
- return p.layout == 'wiki' && p.wiki == wiki && p.description;
- }).limit(1).each(function(post) {
- wikis.push(post);
- });
- });
- %>
-
<%- __('page.wiki', config.title, wikis.length, page.title) %>
- <% wikis.forEach(function(post) { %>
- <%- outputExcerpt(post) %>
- <% }); %>
-
- <% } else { %>
-
- <%
- var wikis = [];
- wikis = site.pages.filter(function (p) {
- if (p.layout == 'wiki' && p.wiki && p.description) {
- if (p.order == undefined) {
- p.order = 0;
- }
- return true;
- } else {
- return false;
- }
- }).sort('order');
- %>
-
<%- __('page.wiki', config.title, wikis.length, __('btn.wiki')) %>
- <% wikis.forEach(function(post) { %>
- <%- outputExcerpt(post) %>
- <% }); %>
-
- <% } %>
+ <%- layout_wikis(function(post){
+ return partial('_partial/main/post_list/wiki_card', {post: post})
+ }) %>
<% } %>
diff --git a/source/css/_layout/post_list.styl b/source/css/_layout/post_list.styl
index 28f0c31..6935602 100644
--- a/source/css/_layout/post_list.styl
+++ b/source/css/_layout/post_list.styl
@@ -25,9 +25,17 @@
overflow: hidden
background: var(--card)
.meta.cap
+ display: flex
+ flex-wrap: wrap
+ align-items: center
margin-bottom: 0.5rem
span+span
margin-left: 0.5rem
+ span.pin
+ line-height: 0
+ img
+ object-fit: contain
+ height: 1.5em
.post-list .post-card:hover
box-shadow: 0 2px 8px 0px rgba(0, 0, 0, 0.04), 0 4px 16px 0px rgba(0, 0, 0, 0.04)
.preview img