Skip to content

Commit 6be89ee

Browse files
committed
Add related post side bar and table of contents collapse
1 parent e1f4677 commit 6be89ee

File tree

7 files changed

+109
-33
lines changed

7 files changed

+109
-33
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="border p-5 bg-lightblue">
2+
<div class="row justify-content-between">
3+
<div class="col-md-6 mb-2 mb-md-0">
4+
<h5 class="font-weight-bold">Join Newsletter</h5>
5+
Get the latest tutorials right in your inbox. We never spam!
6+
</div>
7+
<div class="col-md-6">
8+
<div class="row">
9+
<form action="{{site.mailchimp-list}}" method="post" name="mc-embedded-subscribe-form" class="wj-contact-form validate w-100" target="_blank" novalidate>
10+
<div class="mc-field-group">
11+
12+
<input type="email" placeholder="Enter e-mail address" name="EMAIL" class="required email form-control w-100" id="mce-EMAIL" autocomplete="on" required>
13+
14+
15+
<button type="submit" value="Subscribe" name="subscribe" class="heart btn btn-success btn-block w-100 mt-2">Subscribe</button>
16+
17+
</div>
18+
</form>
19+
</div>
20+
</div>
21+
</div>
22+
</div>

_includes/related_posts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="relatedPosts">
22

3-
<h4>You May Also Enjoy</h4>
3+
<h4>You May Also Like</h4>
44

55
{% assign maxRelated = 6 %}
66
{% assign minCommonTags = 2 %}

_includes/related_posts_sidebar.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<div class="related-posts-sidebar ">
2+
3+
<h4>Related Tutorials</h4>
4+
5+
{% assign maxRelated = 25 %}
6+
{% assign minCommonTags = 2 %}
7+
{% assign maxRelatedCounter = 0 %}
8+
9+
<ul>
10+
{% for post in site.posts %}
11+
12+
{% assign sameTagCount = 0 %}
13+
{% assign commonTags = '' %}
14+
15+
{% for category in post.categories %}
16+
{% if post.url != page.url %}
17+
{% if page.categories contains category %}
18+
{% assign sameTagCount = sameTagCount | plus: 1 %}
19+
{% capture tagmarkup %} <span class="label label-default">{{ category }}</span> {% endcapture %}
20+
{% assign commonTags = commonTags | append: tagmarkup %}
21+
{% endif %}
22+
{% endif %}
23+
{% endfor %}
24+
25+
{% if sameTagCount >= minCommonTags %}
26+
<li>
27+
<div>
28+
<p><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></p><!-- {{ commonTags }} -->
29+
</div>
30+
</li>
31+
{% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
32+
{% if maxRelatedCounter >= maxRelated %}
33+
{% break %}
34+
{% endif %}
35+
{% endif %}
36+
{% endfor %}
37+
</ul>
38+
</div>

_layouts/post.html

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
<div class="container">
1111
<div class="row">
1212

13-
<!-- Post Share -->
14-
<div class="col-md-2 pl-0">
13+
<!-- Post Share
14+
<div class="col-md-1 pl-0">
1515
{% include share.html %}
1616
</div>
17+
-->
18+
19+
<!-- Post Share -->
20+
<div class="col-md-3" pl-0>
21+
{% include related_posts_sidebar.html %}
22+
</div>
1723

1824
<!-- Post -->
1925
{% assign author = site.authors[page.author] %}
@@ -60,43 +66,41 @@ <h1 class="posttitle">{{ page.title }}</h1>
6066
{% if page.beforetoc %}
6167
<p><em>{{page.beforetoc}}</em></p>
6268
{% endif %}
69+
<!-- commented default toc , added colaapsable below
6370
<div class="toc mt-4 mb-4 lead">
6471
<h3 class="font-weight-bold">Summary</h3>
6572
{% include toc.html html=content %}
6673
</div>
74+
-->
75+
<div id="accordion">
76+
<div class="card">
77+
<div class="card-header" id="headingTwo">
78+
<h5 class="mb-0">
79+
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
80+
Table of Contents
81+
</button>
82+
</h5>
83+
</div>
84+
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
85+
<div class="card-body">
86+
{% include toc.html html=content %}
87+
</div>
88+
</div>
89+
</div>
90+
</div>
91+
6792
{% endif %}
6893
<!-- End Toc -->
6994
{{content}}
7095

7196
<!-- ==============================Related Post include=================================-->
7297
{% include related_posts.html %}
7398
<!-- ==============================Related Post include=================================-->
74-
<!-- Mailchimp Subscribe Form -->
99+
<!-- ==============================Mailchimp Subscribe Form=============================-->
75100
{% if site.mailchimp-list %}
76-
<div class="border p-5 bg-lightblue">
77-
<div class="row justify-content-between">
78-
<div class="col-md-6 mb-2 mb-md-0">
79-
<h5 class="font-weight-bold">Join Newsletter</h5>
80-
Get the latest tutorials right in your inbox. We never spam!
81-
</div>
82-
<div class="col-md-6">
83-
<div class="row">
84-
<form action="{{site.mailchimp-list}}" method="post" name="mc-embedded-subscribe-form" class="wj-contact-form validate w-100" target="_blank" novalidate>
85-
<div class="mc-field-group">
86-
87-
<input type="email" placeholder="Enter e-mail address" name="EMAIL" class="required email form-control w-100" id="mce-EMAIL" autocomplete="on" required>
88-
89-
90-
<button type="submit" value="Subscribe" name="subscribe" class="heart btn btn-success btn-block w-100 mt-2">Subscribe</button>
91-
92-
</div>
93-
</form>
94-
</div>
95-
</div>
96-
</div>
97-
</div>
101+
{% include mailchimp_newsletter_box.html %}
98102
{% endif %}
99-
<!-- End Mailchimp Subscribe Form -->
103+
<!-- =============================End Mailchimp Subscribe Form========================== -->
100104

101105
</div>
102106

@@ -158,6 +162,7 @@ <h5 class="font-weight-bold">Join Newsletter</h5>
158162
</div>
159163
<!-- End Post -->
160164

165+
161166
</div>
162167
</div>
163168
<!-- End Article
@@ -168,7 +173,10 @@ <h5 class="font-weight-bold">Join Newsletter</h5>
168173
{% if page.comments != false %}
169174
<div class="container">
170175
<div id="comments" class="row justify-content-center mb-5">
171-
<div class="col-md-8">
176+
<div class="col-md-3">
177+
178+
</div>
179+
<div class="col-md-9">
172180
{% include disqus.html %}
173181
</div>
174182
</div>

_posts/collections/arraylist/2021-11-24-arraylist-in-java.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "ArrayList In Java"
44
author: gaurav
55
categories: [Collections, ArrayList]
66

7+
toc: true
8+
79
description: "In this article, we will see ArrayList in Java. How to create an ArrayList? Its various type of constructors for creating an ArrayList object. Also, some important features with an example."
810
---
911
In this article, we will see ArrayList in Java. How to create an ArrayList? Its various type of constructors for creating an ArrayList object. Also, some important features with an example.

_posts/groovy/2020-12-31-hello-world-in-groovy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: gaurav
55
image: assets/images/2020-12-31/groovy-logo.webp
66
categories: [ Groovy]
77
description: "In this article you will say 'Hello' to Groovy. We will see the installation and 'the' most important 'Hello World!' program."
8-
featured: true
8+
featured: false
99
---
1010
In this article, you will say 'Hello' to Groovy. We will see the installation and 'the' most important "Hello World!" program. 🙂
1111

assets/css/screen.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ Copyright: Sal, WowThemes.net, https://www.wowthemes.net
44
License: https://www.wowthemes.net/freebies-license/
55
*/
66
@media screen and (min-width:1500px) {
7-
html { font-size:18px; } /* Increase the font size on higher resolutions */
8-
.container {max-width:80%;}
7+
html { font-size:19px; } /* Increase the font size on higher resolutions */
8+
.container {max-width:90%;}
99
}
1010
.mainheading {
1111
padding: 1rem 0rem;
1212
}
1313

1414
a {
15-
color: #00ab6b;
15+
color: #6C63FF;
1616
transition: all 0.2s;
1717
}
1818

1919
a:hover {
20-
color: #038252;
20+
color: #9400d3;
2121
text-decoration: none;
2222
}
2323

@@ -786,6 +786,12 @@ iframe {
786786
.jumbotron.fortags .row {
787787
margin: 0;
788788
}
789+
790+
.related-posts-sidebar {
791+
top: 100px;
792+
margin-left: -120px;
793+
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
794+
}
789795
}
790796

791797
.jumbotron.fortags {

0 commit comments

Comments
 (0)