Skip to content

Commit 6957063

Browse files
Cleaned up post list component
1 parent 06d8449 commit 6957063

File tree

10 files changed

+74
-145
lines changed

10 files changed

+74
-145
lines changed

assets/built/screen.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/built/screen.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/screen.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ button.gh-form-input {
294294
padding: 0 max(4vmin, 20px);
295295
}
296296

297+
.gh-outer .gh-outer {
298+
padding: 0;
299+
}
300+
297301
.gh-inner {
298302
margin: 0 auto;
299303
max-width: var(--container-width);

author.hbs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,6 @@
3636
</section>
3737
{{/author}}
3838

39-
<section class="gh-container is-{{#match @custom.post_feed_style "List"}}list{{else}}grid{{/match}}{{#if @custom.show_sidebar}} has-sidebar{{/if}}{{#unless @custom.show_images_in_feed}} no-image{{/unless}}">
40-
<div class="gh-container-inner gh-inner">
41-
42-
<main class="gh-main">
43-
<div class="gh-feed">
44-
{{#foreach posts}}
45-
{{> "post-card"}}
46-
{{/foreach}}
47-
</div>
48-
</main>
49-
50-
{{#if @custom.show_sidebar}}
51-
<aside class="gh-sidebar">
52-
<section class="gh-about">
53-
{{#if @site.icon}}
54-
<img class="gh-about-icon" src="{{@site.icon}}" alt="{{@site.title}}">
55-
{{/if}}
56-
<h3 class="gh-about-title is-title">{{@site.title}}</h3>
57-
{{#if @site.description}}
58-
<p class="gh-about-description is-body">{{@site.description}}</p>
59-
{{/if}}
60-
{{#if @site.members_enabled}}
61-
{{#unless @member}}
62-
<button class="gh-button">Subscribe</button>
63-
{{/unless}}
64-
{{/if}}
65-
</section>
66-
</aside>
67-
{{/if}}
68-
69-
</div>
70-
</section>
39+
{{> "components/post-list" feed="archive" postFeedStyle=@custom.post_feed_style showTitle=false showSidebar=@custom.show_sidebar}}
7140

7241
</main>

home.hbs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
{{> "components/featured" showFeatured=@custom.highlight_featured_posts limit=4}}
88
{{/match}}
99

10-
1110
{{> "components/cta"}}
1211

13-
14-
{{> "components/post-list" postListStyle=@custom.post_feed_style}}
12+
{{> "components/post-list" feed="home" postFeedStyle=@custom.post_feed_style showTitle=true showSidebar=@custom.show_sidebar}}

index.hbs

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,6 @@
11
{{!< default}}
22
{{!-- The tag above means: insert everything in this file into the body of the default.hbs template --}}
33

4-
<main class="gh-main gh-outer">
5-
6-
<section class="gh-container is-{{#match @custom.post_feed_style "List"}}list{{else}}grid{{/match}}{{#if @custom.show_sidebar}} has-sidebar{{/if}}{{#unless @custom.show_images_in_feed}} no-image{{/unless}}">
7-
<div class="gh-container-inner gh-inner">
8-
9-
<h2 class="gh-container-title">Latest</h2>
10-
11-
<main class="gh-main">
12-
<div class="gh-feed">
13-
{{#match pagination.page 2}}
14-
{{#get "posts" include="authors" limit=@config.posts_per_page as |recent|}}
15-
{{#foreach recent}}
16-
{{> "post-card"}}
17-
{{/foreach}}
18-
{{/get}}
19-
{{/match}}
20-
{{#foreach posts}}
21-
{{> "post-card"}}
22-
{{/foreach}}
23-
</div>
24-
</main>
25-
26-
{{#if @custom.show_sidebar}}
27-
<aside class="gh-sidebar">
28-
<section class="gh-about">
29-
{{#if @site.icon}}
30-
<img class="gh-about-icon" src="{{@site.icon}}" alt="{{@site.title}}">
31-
{{/if}}
32-
<h3 class="gh-about-title is-title">{{@site.title}}</h3>
33-
{{#if @site.description}}
34-
<p class="gh-about-description is-body">{{@site.description}}</p>
35-
{{/if}}
36-
{{#if @site.members_enabled}}
37-
{{#unless @member}}
38-
<button class="gh-button">Subscribe</button>
39-
{{/unless}}
40-
{{/if}}
41-
</section>
42-
</aside>
43-
{{/if}}
44-
45-
</div>
46-
</section>
47-
4+
<main class="gh-main">
5+
{{> "components/post-list" feed="index" postFeedStyle=@custom.post_feed_style showTitle=true showSidebar=@custom.show_sidebar}}
486
</main>

partials/components/post-list.hbs

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,82 @@
1-
<section class="gh-container is-{{#match @custom.post_feed_style "List"}}list{{else}}grid{{/match}}{{#if @custom.show_sidebar}} has-sidebar{{/if}}{{#unless @custom.show_images_in_feed}} no-image{{/unless}} gh-outer">
1+
{{!--
2+
Parameters:
3+
* feed (index, home, archive, recent)
4+
* postFeedStyle (list, grid)
5+
* showTitle (true, false)
6+
* showSidebar (true, false)
7+
--}}
8+
9+
<section class="gh-container is-{{#match postFeedStyle "List"}}list{{else}}grid{{/match}}{{#if showSidebar}} has-sidebar{{/if}}{{#unless @custom.show_images_in_feed}} no-image{{/unless}} gh-outer">
210
<div class="gh-container-inner gh-inner">
311

4-
<h2 class="gh-container-title">Latest</h2>
12+
{{#if showTitle}}
13+
<h2 class="gh-container-title">
14+
{{#unless title}}Latest{{else}}{{title}}{{/unless}}
15+
</h2>
16+
{{/if}}
517

618
<main class="gh-main">
719
<div class="gh-feed">
8-
{{#match @custom.header_style "Highlight"}}
9-
{{#match posts.length ">=" 10}}
10-
{{#foreach posts from="11" limit="9"}}
11-
{{> "post-card"}}
12-
{{/foreach}}
20+
21+
{{#match feed "home"}}
22+
{{#match @custom.header_style "Highlight"}}
23+
{{#match posts.length ">=" 10}}
24+
{{#foreach posts from="11" limit="9"}}
25+
{{> "post-card"}}
26+
{{/foreach}}
27+
{{else}}
28+
{{#foreach posts limit="9"}}
29+
{{> "post-card"}}
30+
{{/foreach}}
31+
{{/match}}
32+
{{else match @custom.header_style "Magazine"}}
33+
{{#match posts.length ">=" 7}}
34+
{{#foreach posts from="8" limit="9"}}
35+
{{> "post-card"}}
36+
{{/foreach}}
37+
{{else}}
38+
{{#foreach posts limit="9"}}
39+
{{> "post-card"}}
40+
{{/foreach}}
41+
{{/match}}
1342
{{else}}
1443
{{#foreach posts limit="9"}}
1544
{{> "post-card"}}
1645
{{/foreach}}
1746
{{/match}}
18-
{{else match @custom.header_style "Magazine"}}
19-
{{#match posts.length ">=" 7}}
20-
{{#foreach posts from="8" limit="9"}}
21-
{{> "post-card"}}
22-
{{/foreach}}
23-
{{else}}
24-
{{#foreach posts limit="9"}}
25-
{{> "post-card"}}
26-
{{/foreach}}
47+
{{/match}}
48+
49+
{{#match feed "index"}}
50+
{{#match pagination.page 2}}
51+
{{#get "posts" include="authors" limit=@config.posts_per_page as |recent|}}
52+
{{#foreach recent}}
53+
{{> "post-card"}}
54+
{{/foreach}}
55+
{{/get}}
2756
{{/match}}
28-
{{else}}
29-
{{#foreach posts limit="9"}}
57+
{{#foreach posts}}
58+
{{> "post-card"}}
59+
{{/foreach}}
60+
{{/match}}
61+
62+
{{#match feed "archive"}}
63+
{{#foreach posts}}
3064
{{> "post-card"}}
3165
{{/foreach}}
3266
{{/match}}
67+
68+
{{#match feed "recent"}}
69+
{{#get "posts" include="authors" filter="id:-{{post.id}}" limit="4" as |next|}}
70+
{{#foreach next}}
71+
{{> "post-card"}}
72+
{{/foreach}}
73+
{{/get}}
74+
{{/match}}
75+
3376
</div>
3477
</main>
3578

36-
{{#if @custom.show_sidebar}}
79+
{{#if showSidebar}}
3780
<aside class="gh-sidebar">
3881
<section class="gh-about">
3982
{{#if @site.icon}}

partials/recent-posts.hbs

Lines changed: 0 additions & 12 deletions
This file was deleted.

post.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060

6161
{{/post}}
6262

63-
{{> "recent-posts"}}
63+
{{> "components/post-list" feed="recent" postFeedStyle="Grid" title="Read more" showTitle=true showSidebar=false}}

tag.hbs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,6 @@
1515
</section>
1616
{{/tag}}
1717

18-
<section class="gh-container is-{{#match @custom.post_feed_style "List"}}list{{else}}grid{{/match}}{{#if @custom.show_sidebar}} has-sidebar{{/if}}{{#unless @custom.show_images_in_feed}} no-image{{/unless}}">
19-
<div class="gh-container-inner gh-inner">
20-
21-
<main class="gh-main">
22-
<div class="gh-feed">
23-
{{#foreach posts}}
24-
{{> "post-card"}}
25-
{{/foreach}}
26-
</div>
27-
</main>
28-
29-
{{#if @custom.show_sidebar}}
30-
<aside class="gh-sidebar">
31-
<section class="gh-about">
32-
{{#if @site.icon}}
33-
<img class="gh-about-icon" src="{{@site.icon}}" alt="{{@site.title}}">
34-
{{/if}}
35-
<h3 class="gh-about-title is-title">{{@site.title}}</h3>
36-
{{#if @site.description}}
37-
<p class="gh-about-description is-body">{{@site.description}}</p>
38-
{{/if}}
39-
{{#if @site.members_enabled}}
40-
{{#unless @member}}
41-
<button class="gh-button">Subscribe</button>
42-
{{/unless}}
43-
{{/if}}
44-
</section>
45-
</aside>
46-
{{/if}}
47-
48-
</div>
49-
</section>
18+
{{> "components/post-list" feed="archive" postFeedStyle=@custom.post_feed_style showTitle=false showSidebar=@custom.show_sidebar}}
5019

5120
</main>

0 commit comments

Comments
 (0)