Skip to content

Commit e782fc5

Browse files
authored
Merge pull request scribd#24 from scribd/related-posts
Add related posts component
2 parents 54fb055 + 86dff5d commit e782fc5

28 files changed

+216
-53
lines changed

_includes/featured-post-hero.html

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,12 @@ <h2 class="hero__title">
5858
<section class="feat-post__secondary">
5959
<h3 class="section-heading mb-0 text-plum">Featured Series</h3>
6060
<ul class="post-list text-length-sm">
61-
{% assign featured-series = site.tags.featured-series | sort: 'date' %}
62-
{% for post in featured-series limit: 2 %}
63-
<li class="post-list__item">
64-
65-
<!-- Post title -->
66-
<h4 class="post-list__heading">
67-
<a href="{{ post.url | relative_url }}" class="link-text-color">
68-
{{ post.title | escape }}
69-
</a>
70-
</h4>
71-
72-
<!-- Post metadata -->
73-
<span class="post-list__author">
74-
<span class="visually-hidden">Author:</span>
75-
{%- if site.data.authors[post.author] -%}
76-
{{ site.data.authors[post.author].name}}
77-
{%- else -%}
78-
{{ post.author }}
79-
{%- endif -%}
80-
</span><!--
81-
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
82-
{%- assign date_format = site.date_format -%}
83-
{{ post.date | date: date_format }}</time>
8461

85-
</li>
62+
<!-- Pick a series to features using its unique tag - i.e. di-series -->
63+
{% assign featured-series = site.tags.di-series | sort: 'date' %}
64+
{% for post in featured-series limit: 2 %}
65+
<!-- Post item template -->
66+
{% include post-list-item.html %}
8667
{% endfor %}
8768
</ul>
8869

_includes/post-list-item.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<li class="post-list__item">
2+
3+
<!-- Post title -->
4+
<h4 class="post-list__heading">
5+
<a href="{{ post.url | relative_url }}" class="link-text-color">
6+
{{ post.title | escape }}
7+
</a>
8+
</h4>
9+
10+
<!-- Post metadata -->
11+
<span class="post-list__author">
12+
<span class="visually-hidden">Author:</span>
13+
{%- if site.data.authors[post.author] -%}
14+
{{ site.data.authors[post.author].name}}
15+
{%- else -%}
16+
{{ post.author }}
17+
{%- endif -%}
18+
</span><!--
19+
--><time class="post-list__date" datetime="{{ post.date | date_to_xmlschema }}">
20+
{%- assign date_format = site.date_format -%}
21+
{{ post.date | date: date_format }}</time>
22+
23+
</li>

_includes/related-posts.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{% assign maxRelated = 4 %} <!-- Maximum number of related posts to output -->
2+
{% assign minCommonTags = 1 %} <!-- Minimum number of common tags that have to match -->
3+
{% assign maxRelatedCounter = 0 %}
4+
5+
{% capture related_posts %}
6+
{% for post in site.posts %}
7+
{% assign sameTagCount = 0 %}
8+
{% assign commonTags = '' %}
9+
10+
{% for tag in post.tags %}
11+
{% if post.url != page.url %}
12+
{% if page.tags contains tag %}
13+
{% assign sameTagCount = sameTagCount | plus: 1 %}
14+
{% assign commonTags = commonTags %}
15+
{% endif %}
16+
{% endif %}
17+
{% endfor %}
18+
19+
{% if sameTagCount >= minCommonTags %}
20+
21+
<!-- Post item template -->
22+
{% include post-list-item.html %}
23+
{% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
24+
25+
{% if maxRelatedCounter >= maxRelated %}
26+
{% break %}
27+
{% endif %}
28+
29+
{% endif %}
30+
{% endfor %}
31+
{% endcapture %}
32+
33+
<!-- Render component if there are one or more related posts -->
34+
{% if maxRelatedCounter >= 1 %}
35+
<div class="related-posts bg-slate-100">
36+
<div class="related-posts__wrapper section-container">
37+
<h1 class="related-posts__title">Keep<br>Reading</h1>
38+
39+
<!-- Show related posts -->
40+
<ul class="post-list">
41+
{{ related_posts }}
42+
</ul>
43+
44+
<!-- Decorative arrows -->
45+
<svg class="related-posts__arrow svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
46+
<svg class="related-posts__arrow svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
47+
<svg class="related-posts__arrow svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
48+
</div>
49+
</div>
50+
{% endif %}

_layouts/post.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
<!-- Related jobs -->
2424
{% include related-jobs.html %}
25+
2526
</div>
2627
</div>
2728

29+
<!-- Related posts -->
30+
{% include related-posts.html %}
31+
2832
</article>

_posts/2018-01-05-neural-spelling-corrections.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ layout: post
33
title: "Neural Spelling Corrections and the Importance of Accuracy"
44
author: mattr
55
tags:
6+
- seq2seq
7+
- data
68
team: Data Science
79
---
810

_posts/2018-02-12-search-query-parsing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: "Search Query Parsing"
44
author: mattr
55
tags:
66
- search
7+
- data
78
team: Data Science
89
---
910

_posts/2018-03-20-scribds-ab-testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ layout: post
33
title: "Scribd's A/B Test Framework"
44
author: dfeldman
55
tags:
6+
- testing
7+
- data
68
team: Data Science
79
---
810

_posts/2018-04-18-bandits-for-the-win.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ layout: post
33
title: "Multi-armed bandits for the Win"
44
author: dfeldman
55
tags:
6+
- testing
7+
- data
68
team: Data Science
79
---
810

_posts/2018-05-10-introducting-weaver.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ author: theo
55
tags:
66
- swift
77
- weaver
8+
- dependency injection
89
team: iOS
910
---
1011

1112
A few months ago, I started developing a framework named [Weaver](https://github.com/scribd/Weaver) with one idea in mind; improve how we do Dependency Injection in our iOS application at [Scribd](https://www.scribd.com).
1213

13-
[**Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) basically means *“giving an object its instance variables”** ¹. *It seems like it’s not such a big deal, but as soon as a project gets bigger, it gets tricky. Initializers become too complex, passing down dependencies through several layers becomes time consuming and just figuring out where to get a dependency from can be hard enough to give up and finally use a singleton.
14+
**[Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection)** basically means *“giving an object its instance variables”** ¹. *It seems like it’s not such a big deal, but as soon as a project gets bigger, it gets tricky. Initializers become too complex, passing down dependencies through several layers becomes time consuming and just figuring out where to get a dependency from can be hard enough to give up and finally use a singleton.
1415

1516
However, **Dependency Injection is a fundamental aspect of software architecture, and there is no good reason not to do it properly**. In this article, I’ll discuss how Weaver makes it easy.
1617

_posts/2018-05-31-non-random-seo-test.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "Bootstrapping Your Way Through a Non-Random SEO Test"
44
author: katg
55
tags:
66
- seo
7+
- testing
8+
- data
79
team: Data Science
810
---
911

_posts/2018-06-02-unit-testing-designs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: "How Unit Testing Can Help Write Better Designs"
44
author: theo
55
tags:
66
- testing
7+
- abstraction
78
team: iOS
89
---
910

_posts/2018-07-03-anatomy-ebook-reader.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ layout: post
33
title: "Anatomy of an Accessible eBook Reader for the Web"
44
author: ugi
55
tags:
6+
- accessibility
7+
- design
68
team: Web Development
79
---
810

_posts/2018-09-24-live-collections-ios.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "Get Animated with LiveCollections for iOS"
44
author: stephane
55
tags:
66
- swift
7+
- live-collections
8+
- lc-series
79
team: iOS
810
---
911

_posts/2018-09-25-live-collections-single-section-views.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "LiveCollections Part 2: Single Section Views"
44
author: stephane
55
tags:
66
- swift
7+
- live-collections
8+
- lc-series
79
team: iOS
810
---
911

_posts/2018-10-10-live-collections-multi-section-views.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "LiveCollections Part 3: Multi-Section Views"
44
author: stephane
55
tags:
66
- swift
7+
- live-collections
8+
- lc-series
79
team: iOS
810
---
911

_posts/2018-10-24-dependency-injection-with-weaver-1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ author: theo
55
tags:
66
- swift
77
- weaver
8-
- featured-series
8+
- dependency injection
9+
- di-series
910
team: iOS
1011
---
1112

_posts/2018-11-20-live-collections-carousels.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "LiveCollections Part 4: A Table of Carousels"
44
author: stephane
55
tags:
66
- swift
7+
- live-collections
8+
- lc-series
79
team: iOS
810
---
911

_posts/2018-11-27-live-collections-data-factories.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "LiveCollections Part 5: Data Factories, Non-Unique Data, and Advanced F
44
author: stephane
55
tags:
66
- swift
7+
- live-collections
8+
- lc-series
79
team: iOS
810
---
911

_posts/2019-01-30-dependency-injection-with-weaver-part-2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ author: theo
55
tags:
66
- swift
77
- weaver
8-
- featured-series
8+
- dependency injection
9+
- di-series
910
team: iOS
1011
---
1112

_posts/2019-02-07-calculating-customer-lifetime-revenue.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ layout: post
33
title: Calculating Customer Lifetime Revenue
44
author: bclearly
55
tags:
6-
- ltv
6+
- ltr
7+
- data
78
team: Data Science
89
---
910

_posts/2019-03-04-experiments-with-seq2seq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ title: 'Experiments with Seq2seq: Data Dependency'
44
author: siweiz
55
tags:
66
- machinelearning
7-
- deeplearning
7+
- seq2seq
8+
- data
89
team: Data Science
910
---
1011

_posts/2019-03-28-scribd-core-platform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: post
33
title: "What Core Platform does at Scribd"
44
author: rtyler
55
tags:
6+
- scribd
67
team: Core Platform
78
---
89

_posts/2019-08-22-platform-engineering-at-scribd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ layout: post
33
title: Zooming out to Platform Engineering at Scribd
44
author: rtyler
55
tags:
6+
- scribd
67
- dataeng
8+
- data
79
team: Core Platform
810
---
911

_posts/2019-08-28-real-time-data-platform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: rtyler
55
tags:
66
- kafka
77
- aws
8-
- featured
8+
- data
99
team: Core Platform
1010
---
1111

_posts/2019-11-25-building-the-library.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: "We're building the largest library in history"
44
author: rtyler
55
tags:
66
- featured
7+
- scribd
78
- 2020
89
---
910

0 commit comments

Comments
 (0)